Search in sources :

Example 1 with ComponentWithBadNullsOperations

use of alma.jconttest.ComponentWithBadNullsOperations in project ACS by ACS-Community.

the class CorbaNullFinderTest method testNullFinderInContainerSealant.

/**
	 * Strictly speaking this is a test for {@link ContainerSealant}, but practically fits well in here.
	 */
public void testNullFinderInContainerSealant() throws Exception {
    // activate the null checker
    System.setProperty(ContainerSealant.CHECK_NULLS_CORBA_OUT_PROPERTYNAME, "true");
    // The test component, with the real interceptor around it
    LogRecordCollectingLogger collectingLogger = LogRecordCollectingLogger.getCollectingLogger("Collecting_" + getName());
    ComponentWithBadNullsImpl compImpl = new ComponentWithBadNullsImpl();
    ComponentWithBadNullsOperations sealedComponent = ContainerSealant.createContainerSealant(ComponentWithBadNullsOperations.class, compImpl, "InstanceForUnitTest", false, collectingLogger, null, null);
    // invocation of methodWithReturnData
    String instring = null;
    Struct1 instruct1 = ComponentWithBadNullsImpl.createGoodStruct1();
    instruct1.myenum1 = null;
    instruct1.mystring = null;
    StringHolder inoutstringHolder = new StringHolder();
    Struct1Holder inoutstruct1Holder = new Struct1Holder();
    StringHolder outstringHolder = new StringHolder();
    Struct1Holder outstruct1Holder = new Struct1Holder();
    sealedComponent.methodWithReturnData(instring, instruct1, inoutstringHolder, inoutstruct1Holder, outstringHolder, outstruct1Holder);
    // check the logs produced by the ContainerSealant who uses CorbaNullFinder
    LogRecord[] logRecords = collectingLogger.getCollectedLogRecords();
    assertEquals(3, logRecords.length);
    assertEquals("intercepted a call to 'InstanceForUnitTest#methodWithReturnData'.", logRecords[0].getMessage());
    assertTrue(logRecords[1].getMessage().startsWith("returning from InstanceForUnitTest#methodWithReturnData after"));
    System.out.println(logRecords[2].getMessage());
    assertEquals("Illegal null value in out parameter(s) of method methodWithReturnData:\n" + "  Parameter StringHolder: \n" + "    Null string in field StringHolder/value\n" + "  Parameter Struct1Holder: \n" + "    Null string in field Struct1Holder/value/mystring\n" + "    Null enum in field Struct1Holder/value/myenum1\n" + "  Parameter StringHolder: \n" + "    Null string in field StringHolder/value\n" + "  Parameter Struct1Holder: \n" + "    Null string in field Struct1Holder/value/mystring\n" + "    Null enum in field Struct1Holder/value/myenum1\n", logRecords[2].getMessage());
}
Also used : StringHolder(org.omg.CORBA.StringHolder) LogRecord(java.util.logging.LogRecord) Struct1Holder(alma.jconttest.ComponentWithBadNullsPackage.Struct1Holder) Struct1(alma.jconttest.ComponentWithBadNullsPackage.Struct1) LogRecordCollectingLogger(alma.acs.testsupport.LogRecordCollectingLogger) ComponentWithBadNullsOperations(alma.jconttest.ComponentWithBadNullsOperations) ComponentWithBadNullsImpl(alma.jconttest.ComponentWithBadNullsImpl.ComponentWithBadNullsImpl)

Aggregations

LogRecordCollectingLogger (alma.acs.testsupport.LogRecordCollectingLogger)1 ComponentWithBadNullsImpl (alma.jconttest.ComponentWithBadNullsImpl.ComponentWithBadNullsImpl)1 ComponentWithBadNullsOperations (alma.jconttest.ComponentWithBadNullsOperations)1 Struct1 (alma.jconttest.ComponentWithBadNullsPackage.Struct1)1 Struct1Holder (alma.jconttest.ComponentWithBadNullsPackage.Struct1Holder)1 LogRecord (java.util.logging.LogRecord)1 StringHolder (org.omg.CORBA.StringHolder)1