Search in sources :

Example 11 with Fixed

use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.

the class CorbaObjectReaderTest method testReadFixed.

@Test
public void testReadFixed() {
    if (System.getProperty("java.vendor").contains("IBM")) {
        // to the stream.
        return;
    }
    OutputStream oStream = orb.create_output_stream();
    // create the following fixed
    // fixed<5,2>
    oStream.write_fixed(new java.math.BigDecimal("12345.67").movePointRight(2));
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    Fixed fixedType = new Fixed();
    fixedType.setDigits(5);
    fixedType.setScale(2);
    // These values don't matter to the outcome of the test but are needed during construction
    QName fixedName = new QName("TestFixed");
    QName fixedIdlType = new QName("corbatm:TestFixed");
    TypeCode fixedTC = orb.create_fixed_tc((short) fixedType.getDigits(), (short) fixedType.getScale());
    CorbaFixedHandler obj = new CorbaFixedHandler(fixedName, fixedIdlType, fixedTC, fixedType);
    reader.readFixed(obj);
    assertTrue(obj.getValue().equals(new java.math.BigDecimal("12345.67")));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) InputStream(org.omg.CORBA.portable.InputStream) QName(javax.xml.namespace.QName) CorbaFixedHandler(org.apache.cxf.binding.corba.types.CorbaFixedHandler) OutputStream(org.omg.CORBA.portable.OutputStream) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) Test(org.junit.Test)

Example 12 with Fixed

use of org.apache.cxf.binding.corba.wsdl.Fixed in project cxf by apache.

the class CorbaFixedHandlerTest method testCorbaFixedHandler.

@Test
public void testCorbaFixedHandler() {
    Fixed fixedType = new Fixed();
    fixedType.setName("FixedType");
    fixedType.setDigits(3);
    fixedType.setScale(2);
    QName fixedName = new QName(fixedType.getName());
    QName fixedIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "FixedType", CorbaConstants.NP_WSDL_CORBA);
    TypeCode fixedTC = orb.create_fixed_tc((short) fixedType.getDigits(), (short) fixedType.getScale());
    CorbaFixedHandler obj = new CorbaFixedHandler(fixedName, fixedIdlType, fixedTC, fixedType);
    assertNotNull(obj);
    java.math.BigDecimal value = new java.math.BigDecimal(123.45);
    obj.setValue(value);
    assertTrue(value.equals(obj.getValue()));
    String valueData = obj.getValueData();
    assertTrue(valueData.equals(value.toString()));
    assertTrue(fixedType.getDigits() == obj.getDigits());
    assertTrue(fixedType.getScale() == obj.getScale());
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) Test(org.junit.Test)

Aggregations

Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)12 QName (javax.xml.namespace.QName)6 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)4 Alias (org.apache.cxf.binding.corba.wsdl.Alias)3 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)3 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)3 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)3 TypeCode (org.omg.CORBA.TypeCode)3 Array (org.apache.cxf.binding.corba.wsdl.Array)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 Union (org.apache.cxf.binding.corba.wsdl.Union)2 XmlSchemaFractionDigitsFacet (org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet)2 Test (org.junit.Test)2 AST (antlr.collections.AST)1 List (java.util.List)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 CorbaFixedHandler (org.apache.cxf.binding.corba.types.CorbaFixedHandler)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1