Search in sources :

Example 1 with Struct1

use of alma.jconttest.ComponentWithBadNullsPackage.Struct1 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)

Example 2 with Struct1

use of alma.jconttest.ComponentWithBadNullsPackage.Struct1 in project ACS by ACS-Community.

the class ComponentWithBadNullsImpl method createGoodStruct1.

public static Struct1 createGoodStruct1() {
    Enum1 goodEnum1 = Enum1.MY_ONLY_VALUE;
    Struct1 goodStruct1 = new Struct1("goodstring", goodEnum1);
    return goodStruct1;
}
Also used : Enum1(alma.jconttest.ComponentWithBadNullsPackage.Enum1) Struct1(alma.jconttest.ComponentWithBadNullsPackage.Struct1)

Example 3 with Struct1

use of alma.jconttest.ComponentWithBadNullsPackage.Struct1 in project ACS by ACS-Community.

the class ComponentWithBadNullsImpl method createGoodStruct2.

/**
	 * Creates a valid instance of the IDL-defined {@link Struct2}.
	 */
public static Struct2 createGoodStruct2() {
    Struct1 goodStruct1 = createGoodStruct1();
    Struct1[] goodStruct1Array = new Struct1[1];
    goodStruct1Array[0] = goodStruct1;
    Struct2 goodStruct2 = new Struct2(goodStruct1, goodStruct1Array);
    return goodStruct2;
}
Also used : Struct1(alma.jconttest.ComponentWithBadNullsPackage.Struct1) Struct2(alma.jconttest.ComponentWithBadNullsPackage.Struct2)

Aggregations

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