From 13d3f4a1c78282c2ba3fcb3c0e29fe9e045c9e4e Mon Sep 17 00:00:00 2001 From: ylecollen Date: Mon, 9 Jan 2017 13:55:04 +0100 Subject: The serialization / deserialization unit test did not fail when there was an error --- .../androidTest/java/org/matrix/olm/OlmAccountTest.java | 8 +++++++- .../java/org/matrix/olm/OlmGroupSessionTest.java | 11 +++++++++++ .../androidTest/java/org/matrix/olm/OlmSessionTest.java | 5 +++++ .../androidTest/java/org/matrix/olm/OlmUtilityTest.java | 16 ++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'java/android/OlmLibSdk') diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java index 569b520..699d966 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java @@ -96,6 +96,7 @@ public class OlmAccountTest { mOlmAccount = new OlmAccount(); } catch (OlmException e) { e.printStackTrace(); + assertTrue("OlmAccount failed " + e.getMessage(), false); } assertNotNull(mOlmAccount); @@ -109,6 +110,7 @@ public class OlmAccountTest { mOlmAccount = new OlmAccount(); } catch (OlmException e) { e.printStackTrace(); + assertTrue("OlmAccount failed " + e.getMessage(), false); } assertNotNull(mOlmAccount); mIsAccountCreated = true; @@ -261,7 +263,7 @@ public class OlmAccountTest { FileOutputStream fileOutput; ObjectOutputStream objectOutput; OlmAccount accountRef = null; - OlmAccount accountDeserial; + OlmAccount accountDeserial = null; try { accountRef = new OlmAccount(); @@ -330,18 +332,22 @@ public class OlmAccountTest { } catch (FileNotFoundException e) { Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg=="+e.getMessage()); + assertTrue("test13Serialization failed " + e.getMessage(), false); } catch (ClassNotFoundException e) { Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage()); + assertTrue("test13Serialization failed " + e.getMessage(), false); } catch (IOException e) { Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage()); + assertTrue("test13Serialization failed " + e.getMessage(), false); } /*catch (OlmException e) { Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage()); }*/ catch (Exception e) { Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage()); + assertTrue("test13Serialization failed " + e.getMessage(), false); } } diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java index c532179..9be6375 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java @@ -175,6 +175,7 @@ public class OlmGroupSessionTest { try { result = mBobInboundGroupSession.decryptMessage(mAliceToBobMessage); } catch (Exception e) { + assertTrue(e.getMessage(), false); } // test decrypted message @@ -262,14 +263,19 @@ public class OlmGroupSessionTest { assertTrue(outboundGroupSessionSerial.isReleased()); } catch (FileNotFoundException e) { Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); + assertTrue(e.getMessage(), false); } catch (ClassNotFoundException e) { Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (OlmException e) { Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (IOException e) { Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (Exception e) { Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } } @@ -342,14 +348,19 @@ public class OlmGroupSessionTest { assertTrue(bobInboundGroupSessionSerial.isReleased()); } catch (FileNotFoundException e) { Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); + assertTrue(e.getMessage(), false); } catch (ClassNotFoundException e) { Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (OlmException e) { Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (IOException e) { Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception IOException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (Exception e) { Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } } diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java index ec2582f..bb24f7a 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java @@ -454,6 +454,7 @@ public class OlmSessionTest { bobSession = new OlmSession(); } catch (OlmException e) { e.printStackTrace(); + assertTrue(e.getMessage(), false); } assertTrue(0!=bobSession.getOlmSessionId()); @@ -803,18 +804,22 @@ public class OlmSessionTest { } catch (FileNotFoundException e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage()); + assertTrue(e.getMessage(), false); } catch (ClassNotFoundException e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } catch (IOException e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } /*catch (OlmException e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage()); }*/ catch (Exception e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage()); + assertTrue(e.getMessage(), false); } } diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java index bd53e6e..cc14e7c 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java +++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java @@ -95,7 +95,13 @@ public class OlmUtilityTest { assertTrue("fingerprint key missing",!TextUtils.isEmpty(fingerPrintKey)); // instantiate utility object - OlmUtility utility = new OlmUtility(); + OlmUtility utility = null; + + try { + utility = new OlmUtility(); + } catch (Exception e) { + assertTrue("failed to create OlmUtility", false); + } // verify signature boolean isVerified; @@ -145,7 +151,13 @@ public class OlmUtilityTest { @Test public void test02sha256() { - OlmUtility utility = new OlmUtility(); + OlmUtility utility = null; + + try { + utility = new OlmUtility(); + } catch (Exception e) { + assertTrue("OlmUtility creation failed", false); + } String msgToHash = "The quick brown fox jumps over the lazy dog"; String hashResult = utility.sha256(msgToHash); -- cgit v1.2.3