aboutsummaryrefslogtreecommitdiff
path: root/java/android
diff options
context:
space:
mode:
authorpedroGitt <pedro.contreiras@amdocs.com>2016-10-28 10:49:04 +0200
committerpedroGitt <pedro.contreiras@amdocs.com>2016-10-28 10:49:04 +0200
commit7a0d7cc36dfb2c1d7649af181160767a844e81f6 (patch)
treeabffb7d54e60aec4aac80954d9ef1c9b11cfeb5e /java/android
parent0d3c1a2a46589b004231b92f44d3bc8e327e0097 (diff)
Fix OlmException cast issue
- OlmException class extends now from IOException - update corresponding serializing unit tests - update
Diffstat (limited to 'java/android')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java61
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java6
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java21
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java6
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java6
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java6
6 files changed, 46 insertions, 60 deletions
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 eca070f..ac369e2 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
@@ -196,13 +196,12 @@ public class OlmGroupSessionTest {
FileInputStream fileInput = context.openFileInput(FILE_NAME_SERIAL_OUT_SESSION);
ObjectInputStream objectInput = new ObjectInputStream(fileInput);
outboundGroupSessionSerial = (OlmOutboundGroupSession) objectInput.readObject();
+ assertNotNull(outboundGroupSessionSerial);
objectInput.close();
// get sessions keys
String sessionKeyRef = outboundGroupSessionRef.sessionKey();
String sessionKeySerial = outboundGroupSessionSerial.sessionKey();
-
- // session keys sanity check
assertFalse(TextUtils.isEmpty(sessionKeyRef));
assertFalse(TextUtils.isEmpty(sessionKeySerial));
@@ -212,8 +211,6 @@ public class OlmGroupSessionTest {
// get sessions IDs
String sessionIdRef = outboundGroupSessionRef.sessionIdentifier();
String sessionIdSerial = outboundGroupSessionSerial.sessionIdentifier();
-
- // session ID sanity check
assertFalse(TextUtils.isEmpty(sessionIdRef));
assertFalse(TextUtils.isEmpty(sessionIdSerial));
@@ -222,21 +219,16 @@ public class OlmGroupSessionTest {
outboundGroupSessionRef.releaseSession();
outboundGroupSessionSerial.releaseSession();
- }
- catch (FileNotFoundException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage());
- }
- catch (ClassNotFoundException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
- }
- catch (IOException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
- }
- /*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());
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
+ } catch (ClassNotFoundException e) {
+ Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
+ } catch (OlmException e) {
+ Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage());
+ } catch (IOException e) {
+ Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage());
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception Msg==" + e.getMessage());
}
}
@@ -277,17 +269,16 @@ public class OlmGroupSessionTest {
objectOutput.close();
// deserialize session
- FileInputStream fileInput = context.openFileInput(FILE_NAME_SERIAL_OUT_SESSION);
+ FileInputStream fileInput = context.openFileInput(FILE_NAME_SERIAL_IN_SESSION);
ObjectInputStream objectInput = new ObjectInputStream(fileInput);
bobInboundGroupSessionSerial = (OlmInboundGroupSession)objectInput.readObject();
+ assertNotNull(bobInboundGroupSessionSerial);
objectInput.close();
// get sessions IDs
String aliceSessionId = aliceOutboundGroupSession.sessionIdentifier();
String sessionIdRef = bobInboundGroupSessionRef.sessionIdentifier();
String sessionIdSerial = bobInboundGroupSessionSerial.sessionIdentifier();
-
- // session ID sanity check
assertFalse(TextUtils.isEmpty(aliceSessionId));
assertFalse(TextUtils.isEmpty(sessionIdRef));
assertFalse(TextUtils.isEmpty(sessionIdSerial));
@@ -295,18 +286,20 @@ public class OlmGroupSessionTest {
// session IDs comparison
assertTrue(aliceSessionId.equals(sessionIdSerial));
assertTrue(sessionIdRef.equals(sessionIdSerial));
- }
- catch (FileNotFoundException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage());
- }
- catch (ClassNotFoundException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
- }
- catch (IOException e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
- }
- catch (Exception e) {
- Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage());
+
+ aliceOutboundGroupSession.releaseSession();
+ bobInboundGroupSessionRef.releaseSession();
+ bobInboundGroupSessionSerial.releaseSession();
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
+ } catch (ClassNotFoundException e) {
+ Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
+ } catch (OlmException e) {
+ Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage());
+ } catch (IOException e) {
+ Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception IOException Msg==" + e.getMessage());
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception Msg==" + e.getMessage());
}
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 321e194..876e651 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -69,9 +69,8 @@ public class OlmAccount implements Serializable {
* Kick off the serialization mechanism.
* @param aOutStream output stream for serializing
* @throws IOException exception
- * @throws OlmException exception
*/
- private void writeObject(ObjectOutputStream aOutStream) throws IOException, OlmException {
+ private void writeObject(ObjectOutputStream aOutStream) throws IOException {
aOutStream.defaultWriteObject();
// generate serialization key
@@ -94,9 +93,8 @@ public class OlmAccount implements Serializable {
* @param aInStream input stream
* @throws IOException exception
* @throws ClassNotFoundException exception
- * @throws OlmException exception
*/
- private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException, OlmException {
+ private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException {
aInStream.defaultReadObject();
StringBuffer errorMsg = new StringBuffer();
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java
index d548cf7..bac49f4 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java
@@ -16,10 +16,12 @@
package org.matrix.olm;
+import java.io.IOException;
+
/**
* Exception class to identify specific Olm SDK exceptions.
*/
-public class OlmException extends Exception {
+public class OlmException extends IOException {
// exception codes
public static final int EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION = 0;
public static final int EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION = 1;
@@ -37,18 +39,17 @@ public class OlmException extends Exception {
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION = 13;
// exception human readable messages
- public static final String EXCEPTION_MSG_NEW_OUTBOUND_GROUP_SESSION = "failed to create a new outbound group Session";
- public static final String EXCEPTION_MSG_NEW_INBOUND_GROUP_SESSION = "failed to create a new inbound group Session";
- public static final String EXCEPTION_MSG_INIT_OUTBOUND_GROUP_SESSION = "failed to initialize a new outbound group Session";
- public static final String EXCEPTION_MSG_INIT_INBOUND_GROUP_SESSION = "failed to initialize a new inbound group Session";
+ public static final String EXCEPTION_MSG_NEW_OUTBOUND_GROUP_SESSION = "createNewSession() failed";
+ public static final String EXCEPTION_MSG_NEW_INBOUND_GROUP_SESSION = "createNewSession() failed";
+ public static final String EXCEPTION_MSG_INIT_OUTBOUND_GROUP_SESSION = "initOutboundGroupSession() failed";
+ public static final String EXCEPTION_MSG_INIT_INBOUND_GROUP_SESSION = " initInboundGroupSessionWithSessionKey() failed";
public static final String EXCEPTION_MSG_INIT_NEW_ACCOUNT_DESERIALIZATION = "initNewAccount() failure";
- public static final String EXCEPTION_MSG_INIT_ACCOUNT_DESERIALIZATION = "initWithSerializedData() failure";
public static final String EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION = "invalid de-serialized parameters";
- public static final String EXCEPTION_MSG_INIT_ACCOUNT_CREATION = "Account constructor failure";
- public static final String EXCEPTION_MSG_INIT_SESSION_CREATION = "Session constructor failure";
+ public static final String EXCEPTION_MSG_INIT_ACCOUNT_CREATION = "initNewAccount() failed";
+ public static final String EXCEPTION_MSG_INIT_SESSION_CREATION = "initNewSession() failed";
- /** exception code to be taken from: {@link #EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION} {@link #EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION}
- * {@link #EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION} {@link #EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION}**/
+ /** exception code to be taken from: {@link #EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION}, {@link #EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION},
+ * {@link #EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION}, {@link #EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION}..**/
private final int mCode;
/** Human readable message description **/
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
index f7e1812..501d660 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
@@ -137,9 +137,8 @@ public class OlmInboundGroupSession implements Serializable {
* Kick off the serialization mechanism.
* @param aOutStream output stream for serializing
* @throws IOException exception
- * @throws OlmException exception
*/
- private void writeObject(ObjectOutputStream aOutStream) throws IOException, OlmException {
+ private void writeObject(ObjectOutputStream aOutStream) throws IOException {
aOutStream.defaultWriteObject();
// generate serialization key
@@ -162,9 +161,8 @@ public class OlmInboundGroupSession implements Serializable {
* @param aInStream input stream
* @throws IOException exception
* @throws ClassNotFoundException exception
- * @throws OlmException exception
*/
- private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException, OlmException {
+ private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException {
aInStream.defaultReadObject();
StringBuffer errorMsg = new StringBuffer();
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
index 8ba3bcb..37f89ea 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
@@ -63,9 +63,8 @@ public class OlmOutboundGroupSession implements Serializable {
* Kick off the serialization mechanism.
* @param aOutStream output stream for serializing
* @throws IOException exception
- * @throws OlmException exception
*/
- private void writeObject(ObjectOutputStream aOutStream) throws IOException, OlmException {
+ private void writeObject(ObjectOutputStream aOutStream) throws IOException {
aOutStream.defaultWriteObject();
// generate serialization key
@@ -88,9 +87,8 @@ public class OlmOutboundGroupSession implements Serializable {
* @param aInStream input stream
* @throws IOException exception
* @throws ClassNotFoundException exception
- * @throws OlmException exception
*/
- private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException, OlmException {
+ private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException {
aInStream.defaultReadObject();
StringBuffer errorMsg = new StringBuffer();
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
index 1237efd..9377838 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
@@ -52,9 +52,8 @@ public class OlmSession implements Serializable {
* Kick off the serialization mechanism.
* @param aOutStream output stream for serializing
* @throws IOException exception
- * @throws OlmException exception
*/
- private void writeObject(ObjectOutputStream aOutStream) throws IOException, OlmException {
+ private void writeObject(ObjectOutputStream aOutStream) throws IOException {
aOutStream.defaultWriteObject();
// generate serialization key
@@ -77,9 +76,8 @@ public class OlmSession implements Serializable {
* @param aInStream input stream
* @throws IOException exception
* @throws ClassNotFoundException exception
- * @throws OlmException exception
*/
- private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException, OlmException {
+ private void readObject(ObjectInputStream aInStream) throws IOException, ClassNotFoundException {
aInStream.defaultReadObject();
StringBuffer errorMsg = new StringBuffer();