diff options
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/androidTest')
4 files changed, 81 insertions, 21 deletions
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 3b6101b..7a6233d 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 @@ -187,11 +187,8 @@ public class OlmAccountTest { assertTrue(OlmAccount.JSON_KEY_ONE_TIME_KEY +" object is missing", null!=generatedKeysJsonObj); // test the count of the generated one time keys: - Iterator<String> generatedKeysIt = generatedKeysJsonObj.keys(); - while(generatedKeysIt.hasNext()){ - generatedKeysIt.next(); - oneTimeKeysCount++; - } + oneTimeKeysCount = generatedKeysJsonObj.length(); + assertTrue("Expected count="+GENERATION_ONE_TIME_KEYS_NUMBER+" found="+oneTimeKeysCount,GENERATION_ONE_TIME_KEYS_NUMBER==oneTimeKeysCount); } catch (JSONException e) { 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 ac369e2..8fc0694 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 @@ -168,9 +168,14 @@ public class OlmGroupSessionTest { mBobInboundGroupSession.releaseSession(); } + @Test + public void test14CheckUnreleaseedCount() { + assertTrue(0==mAliceOutboundGroupSession.getUnreleasedCount()); + assertTrue(0==mBobInboundGroupSession.getUnreleasedCount()); + } @Test - public void test14SerializeOutboundSession() { + public void test15SerializeOutboundSession() { OlmOutboundGroupSession outboundGroupSessionRef=null; OlmOutboundGroupSession outboundGroupSessionSerial; @@ -219,21 +224,24 @@ public class OlmGroupSessionTest { outboundGroupSessionRef.releaseSession(); outboundGroupSessionSerial.releaseSession(); + + assertTrue(0==outboundGroupSessionRef.getUnreleasedCount()); + assertTrue(0==outboundGroupSessionSerial.getUnreleasedCount()); } catch (FileNotFoundException e) { - Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); + Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); } catch (ClassNotFoundException e) { - Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); } catch (OlmException e) { - Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage()); } catch (IOException e) { - Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage()); } catch (Exception e) { - Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception Msg==" + e.getMessage()); } } @Test - public void test15SerializeInboundSession() { + public void test16SerializeInboundSession() { OlmOutboundGroupSession aliceOutboundGroupSession=null; OlmInboundGroupSession bobInboundGroupSessionRef=null; OlmInboundGroupSession bobInboundGroupSessionSerial; @@ -290,16 +298,20 @@ public class OlmGroupSessionTest { aliceOutboundGroupSession.releaseSession(); bobInboundGroupSessionRef.releaseSession(); bobInboundGroupSessionSerial.releaseSession(); + + assertTrue(0==aliceOutboundGroupSession.getUnreleasedCount()); + assertTrue(0==bobInboundGroupSessionRef.getUnreleasedCount()); + assertTrue(0==bobInboundGroupSessionSerial.getUnreleasedCount()); } catch (FileNotFoundException e) { - Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); + Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage()); } catch (ClassNotFoundException e) { - Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage()); } catch (OlmException e) { - Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage()); } catch (IOException e) { - Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception IOException Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception IOException Msg==" + e.getMessage()); } catch (Exception e) { - Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception Msg==" + e.getMessage()); + Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception Msg==" + e.getMessage()); } } @@ -308,7 +320,7 @@ public class OlmGroupSessionTest { * This test validates random series are provide enough random values. */ @Test - public void test16MultipleOutboundSession() { + public void test17MultipleOutboundSession() { OlmOutboundGroupSession outboundGroupSession1; OlmOutboundGroupSession outboundGroupSession2; OlmOutboundGroupSession outboundGroupSession3; @@ -374,7 +386,23 @@ public class OlmGroupSessionTest { String sessionId8 = outboundGroupSession8.sessionKey(); assertFalse(sessionId7.equals(sessionId8)); - + outboundGroupSession1.releaseSession(); + outboundGroupSession2.releaseSession(); + outboundGroupSession3.releaseSession(); + outboundGroupSession4.releaseSession(); + outboundGroupSession5.releaseSession(); + outboundGroupSession6.releaseSession(); + outboundGroupSession7.releaseSession(); + outboundGroupSession8.releaseSession(); + + assertTrue(0==outboundGroupSession1.getUnreleasedCount()); + assertTrue(0==outboundGroupSession2.getUnreleasedCount()); + assertTrue(0==outboundGroupSession3.getUnreleasedCount()); + assertTrue(0==outboundGroupSession4.getUnreleasedCount()); + assertTrue(0==outboundGroupSession5.getUnreleasedCount()); + assertTrue(0==outboundGroupSession6.getUnreleasedCount()); + assertTrue(0==outboundGroupSession7.getUnreleasedCount()); + assertTrue(0==outboundGroupSession8.getUnreleasedCount()); } catch (OlmException e) { assertTrue("Exception in OlmOutboundGroupSession, Exception code=" + e.getExceptionCode(), 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 a011685..99127e1 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 @@ -137,9 +137,14 @@ public class OlmSessionTest { // release accounts bobAccount.releaseAccount(); aliceAccount.releaseAccount(); + assertTrue(0==bobAccount.getUnreleasedCount()); + assertTrue(0==aliceAccount.getUnreleasedCount()); + // release sessions bobSession.releaseSession(); aliceSession.releaseSession(); + assertTrue(0==bobSession.getUnreleasedCount()); + assertTrue(0==aliceSession.getUnreleasedCount()); } @@ -251,9 +256,14 @@ public class OlmSessionTest { // clean objects.. assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession)); bobAccount.releaseAccount(); - bobSession.releaseSession(); aliceAccount.releaseAccount(); + assertTrue(0==bobAccount.getUnreleasedCount()); + assertTrue(0==aliceAccount.getUnreleasedCount()); + + bobSession.releaseSession(); aliceSession.releaseSession(); + assertTrue(0==bobSession.getUnreleasedCount()); + assertTrue(0==aliceSession.getUnreleasedCount()); } @@ -302,9 +312,14 @@ public class OlmSessionTest { assertTrue(aliceSessionId.equals(bobSessionId)); aliceAccount.releaseAccount(); - aliceSession.releaseSession(); bobAccount.releaseAccount(); + assertTrue(0==aliceAccount.getUnreleasedCount()); + assertTrue(0==bobAccount.getUnreleasedCount()); + bobSession.releaseSession(); + aliceSession.releaseSession(); + assertTrue(0==bobSession.getUnreleasedCount()); + assertTrue(0==aliceSession.getUnreleasedCount()); } @Test @@ -360,8 +375,13 @@ public class OlmSessionTest { assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession)); aliceAccount.releaseAccount(); bobAccount.releaseAccount(); + assertTrue(0==aliceAccount.getUnreleasedCount()); + assertTrue(0==bobAccount.getUnreleasedCount()); + aliceSession.releaseSession(); bobSession.releaseSession(); + assertTrue(0==aliceSession.getUnreleasedCount()); + assertTrue(0==bobSession.getUnreleasedCount()); } // ******************************************************** @@ -486,9 +506,15 @@ public class OlmSessionTest { assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession)); bobAccount.releaseAccount(); aliceAccount.releaseAccount(); + assertTrue(0==bobAccount.getUnreleasedCount()); + assertTrue(0==aliceAccount.getUnreleasedCount()); + bobSession.releaseSession(); aliceSession.releaseSession(); aliceSessionDeserial.releaseSession(); + assertTrue(0==bobSession.getUnreleasedCount()); + assertTrue(0==aliceSession.getUnreleasedCount()); + assertTrue(0==aliceSessionDeserial.getUnreleasedCount()); } catch (FileNotFoundException e) { Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage()); @@ -589,8 +615,13 @@ public class OlmSessionTest { assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession)); aliceAccount.releaseAccount(); bobAccount.releaseAccount(); + assertTrue(0==aliceAccount.getUnreleasedCount()); + assertTrue(0==bobAccount.getUnreleasedCount()); + aliceSession.releaseSession(); bobSession.releaseSession(); + assertTrue(0==aliceSession.getUnreleasedCount()); + assertTrue(0==bobSession.getUnreleasedCount()); } } 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 d40c35a..9e03453 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 @@ -99,7 +99,10 @@ public class OlmUtilityTest { assertFalse(String.valueOf(errorMsg).isEmpty()); utility.releaseUtility(); + assertTrue(0==utility.getUnreleasedCount()); + account.releaseAccount(); + assertTrue(0==account.getUnreleasedCount()); } @@ -112,5 +115,6 @@ public class OlmUtilityTest { assertFalse(TextUtils.isEmpty(hashResult)); utility.releaseUtility(); + assertTrue(0==utility.getUnreleasedCount()); } } |