use of alma.ACSErrTypeTest.wrappers.AcsJACSErrTest2Ex in project ACS by ACS-Community.
the class AcsJExceptionTest method testJCompletion.
/**
* Creates Completion objects from scratch, from other completion objects,
* with and without associated exception, and checks the values.
*/
public void testJCompletion() {
// a completion without associated exception
AcsJCompletion jcompl1 = new ACSErrTestOKAcsJCompletion();
assertEquals(ACSErrTypeTest.value, jcompl1.getType());
assertEquals(ACSErrTestOK.value, jcompl1.getCode());
assertFalse(jcompl1.isError());
assertTrue(jcompl1.getTimeStamp() > 0);
Completion corbacompl = jcompl1.toCorbaCompletion();
assertEquals(ACSErrTypeTest.value, corbacompl.type);
assertEquals(ACSErrTestOK.value, corbacompl.code);
assertTrue(corbacompl.previousError.length == 0);
assertEquals(UTCUtility.utcJavaToOmg(jcompl1.getTimeStamp()), corbacompl.timeStamp);
long timeMillisBeforeExceptionCreation = System.currentTimeMillis();
// completion with associated exception,
// trying to wrap the previous completion (which has no exception that could be wrapped)
AcsJCompletion jcompl2 = new ACSErrTest1AcsJCompletion(jcompl1);
assertTrue(jcompl2.isError());
AcsJException acsjex2 = jcompl2.getAcsJException();
assertTrue(acsjex2 instanceof AcsJACSErrTest1Ex);
assertNull(acsjex2.getCause());
// completion with associated exception,
// but this time trying to wrap the plain CORBA completion instead of its AcsJ-equivalent.
AcsJCompletion jcompl2b = new ACSErrTest2AcsJCompletion(corbacompl);
assertTrue(jcompl2b.isError());
AcsJException acsjex2b = jcompl2b.getAcsJException();
assertTrue(acsjex2b instanceof AcsJACSErrTest2Ex);
assertNull(acsjex2b.getCause());
// now wrapping a completion with exception with another completion with exception
AcsJCompletion jcompl3 = new ACSErrTest3AcsJCompletion(jcompl2);
assertTrue(jcompl3.isError());
AcsJException acsjex3 = jcompl3.getAcsJException();
assertTrue(acsjex3 instanceof AcsJACSErrTest3Ex);
Throwable acsjex_cause = acsjex3.getCause();
assertNotNull(acsjex_cause);
Throwable acsjex_cause2 = acsjex_cause.getCause();
assertNull(acsjex_cause2);
Completion corbacomp3 = jcompl3.toCorbaCompletion();
assertEquals(ACSErrTypeTest.value, corbacomp3.type);
assertEquals(ACSErrTest3.value, corbacomp3.code);
assertNotNull(corbacomp3.previousError);
assertEquals(1, corbacomp3.previousError.length);
ErrorTrace trace_3_1 = corbacomp3.previousError[0];
assertNotNull(trace_3_1);
ErrorTrace trace_3_0 = trace_3_1.previousError[0];
assertNotNull(trace_3_0);
assertEquals(0, trace_3_0.previousError.length);
// check the various timestamps
long timeMillisAfterExceptionCreation = System.currentTimeMillis();
assertTrue(timeMillisBeforeExceptionCreation <= acsjex2.getTimestampMillis());
assertTrue(timeMillisAfterExceptionCreation >= acsjex2.getTimestampMillis());
assertTrue(timeMillisBeforeExceptionCreation <= acsjex2b.getTimestampMillis());
assertTrue(timeMillisAfterExceptionCreation >= acsjex2b.getTimestampMillis());
long corbacomp3_millis = UTCUtility.utcOmgToJava(corbacomp3.timeStamp);
assertTrue(timeMillisBeforeExceptionCreation <= corbacomp3_millis);
assertTrue(timeMillisAfterExceptionCreation >= corbacomp3_millis);
long trace_3_0_millis = UTCUtility.utcOmgToJava(trace_3_0.timeStamp);
assertTrue(timeMillisBeforeExceptionCreation <= trace_3_0_millis);
assertTrue(timeMillisAfterExceptionCreation >= trace_3_0_millis);
}
Aggregations