use of alma.acs.exceptions.AcsJCompletion in project ACS by ACS-Community.
the class ErrorComponentImpl method completionFromCompletion.
/**
*
* @see alma.acsexmplErrorComponent.ErrorComponentOperations#completionFromCompletion(short)
*/
@Override
public Completion completionFromCompletion(short depth) {
AcsJCompletion completion = null;
if (depth <= 1) {
completion = internalCompletionMethod(depth);
return completion.toCorbaCompletion();
} else {
completion = internalCompletionMethod(depth - 1);
// here we show how to wrap the error from a given completion with a new completion
AcsJCompletion newCompletion = new GenericErrorAcsJCompletion(completion);
return newCompletion.toCorbaCompletion();
}
}
use of alma.acs.exceptions.AcsJCompletion in project ACS by ACS-Community.
the class ErrorComponentTest method testCompletionFromException.
public void testCompletionFromException() {
// depth == 0
AcsJCompletion comp = null;
try {
// call the component method
comp = AcsJCompletion.fromCorbaCompletion(errorComp.completionFromException((short) 0));
} catch (Throwable th) {
m_logger.info("Caught an unexpected Exception");
AcsJUnknownEx ex = new AcsJUnknownEx(th);
ex.log(m_logger);
fail("No exception should be thrown");
}
verifyErrorTrace(1, new AcsJGenericErrorEx(comp.getAcsJException()));
// depth > 0
short[] depths = new short[] { 1, 2, 3, 5, 13 };
for (int i = 0; i < depths.length; i++) {
try {
// call the component method
comp = AcsJCompletion.fromCorbaCompletion(errorComp.completionFromException((depths[i])));
} catch (Throwable th) {
m_logger.info("Caught an unexpected Exception at depth " + depths[i]);
AcsJUnknownEx ex = new AcsJUnknownEx(th);
ex.log(m_logger);
fail("No exception should be thrown");
}
verifyErrorTrace(depths[i] + 1, new AcsJGenericErrorEx(comp.getAcsJException()));
}
}
use of alma.acs.exceptions.AcsJCompletion in project ACS by ACS-Community.
the class MasterComponentTest method verifyCurrentState.
/**
* Helper method for the repeated task of getting the current state hierarchy and
* comparing it against the expected hierarchy.
* <p>
* This method is a replica of {@link StateChangeListener#verifyCurrentState(String[])}
* which is necessary for testing w/o using the synchronization facilities offered by <code>StateChangeListener</code>.
*/
private void verifyCurrentState(ROstringSeq statesProperty, String[] expectedHierarchy) {
CompletionHolder ch = new CompletionHolder();
String[] states = statesProperty.get_sync(ch);
AcsJCompletion statesSyncCompletion = AcsJCompletion.fromCorbaCompletion(ch.value);
assertFalse(statesSyncCompletion.isError());
assertEquals(ACSErrTypeOK.value, statesSyncCompletion.getType());
assertEquals(ACSErrOK.value, statesSyncCompletion.getCode());
assertNotNull(states);
// verify state
String expectedPath = AcsStateUtil.stateHierarchyNamesToString(expectedHierarchy);
String actualPath = AcsStateUtil.stateHierarchyNamesToString(states);
assertEquals("current states hierarchy was not as expected!", expectedPath, actualPath);
}
Aggregations