Search in sources :

Example 41 with ObjectFactory

use of com.opensymphony.xwork2.ObjectFactory in project Payara by payara.

the class Jaxb1MarshallingTestServlet method service.

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/html;charset=UTF-8");
    PrintWriter out = resp.getWriter();
    out.println("jaxb1 marshalling test: ");
    try {
        JAXBContext jc = JAXBContext.newInstance("jaxb1");
        Marshaller m = jc.createMarshaller();
        ObjectFactory of = new ObjectFactory();
        Catalog c = of.createCatalog();
        c.setSection("jaxb1 section");
        StringWriter sw = new StringWriter();
        m.marshal(c, sw);
        String s = sw.toString();
        if (s.contains("<catalog section=\"jaxb1 section\"/>"))
            out.println("marshalled OK");
        else {
            out.println("jaxb1 marshalling failed");
            System.err.println("Error in Jaxb1MarshallingTestServlet. Marshalling result: " + s);
        }
    } catch (JAXBException e) {
        out.println("jaxb1 marshalling failed: " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) ObjectFactory(jaxb1.ObjectFactory) StringWriter(java.io.StringWriter) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) Catalog(jaxb1.Catalog) PrintWriter(java.io.PrintWriter)

Example 42 with ObjectFactory

use of com.opensymphony.xwork2.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testStructWithSubstitutionGroupNil.

@Test
public void testStructWithSubstitutionGroupNil() throws Exception {
    if (!shouldRunTest("StructWithSubstitutionGroupNil")) {
        return;
    }
    StructWithSubstitutionGroupNil x = new StructWithSubstitutionGroupNil();
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<? extends SgBaseTypeA> element = objectFactory.createSg04NillableBaseElementA(null);
    x.setSg04NillableBaseElementA(element);
    StructWithSubstitutionGroupNil yOrig = new StructWithSubstitutionGroupNil();
    element = objectFactory.createSg04NillableBaseElementA(null);
    yOrig.setSg04NillableBaseElementA(element);
    Holder<StructWithSubstitutionGroupNil> y = new Holder<StructWithSubstitutionGroupNil>(yOrig);
    Holder<StructWithSubstitutionGroupNil> z = new Holder<StructWithSubstitutionGroupNil>();
    StructWithSubstitutionGroupNil ret;
    if (testDocLiteral) {
        ret = docClient.testStructWithSubstitutionGroupNil(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testStructWithSubstitutionGroupNil(x, y, z);
    } else {
        ret = rpcClient.testStructWithSubstitutionGroupNil(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect return value", equals(x, ret));
    }
}
Also used : ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) StructWithSubstitutionGroupNil(org.apache.type_test.types3.StructWithSubstitutionGroupNil) Test(org.junit.Test)

Example 43 with ObjectFactory

use of com.opensymphony.xwork2.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testStructWithSubstitutionGroupAbstract.

@Test
public void testStructWithSubstitutionGroupAbstract() throws Exception {
    if (!shouldRunTest("StructWithSubstitutionGroupAbstract")) {
        return;
    }
    SgDerivedTypeB derivedB = new SgDerivedTypeB();
    derivedB.setVarInt(new BigInteger("32"));
    derivedB.setVarString("foo");
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<SgDerivedTypeB> elementB = objectFactory.createSg03DerivedElementB(derivedB);
    SgDerivedTypeC derivedC = new SgDerivedTypeC();
    derivedC.setVarInt(new BigInteger("32"));
    derivedC.setVarFloat(3.14f);
    JAXBElement<SgDerivedTypeC> elementC = objectFactory.createSg03DerivedElementC(derivedC);
    StructWithSubstitutionGroupAbstract x = new StructWithSubstitutionGroupAbstract();
    x.setSg03AbstractBaseElementA(elementC);
    StructWithSubstitutionGroupAbstract yOrig = new StructWithSubstitutionGroupAbstract();
    yOrig.setSg03AbstractBaseElementA(elementB);
    Holder<StructWithSubstitutionGroupAbstract> y = new Holder<StructWithSubstitutionGroupAbstract>(yOrig);
    Holder<StructWithSubstitutionGroupAbstract> z = new Holder<StructWithSubstitutionGroupAbstract>();
    StructWithSubstitutionGroupAbstract ret;
    if (testDocLiteral) {
        ret = docClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    } else {
        ret = rpcClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect return value", equals(x, ret));
    }
}
Also used : SgDerivedTypeB(org.apache.type_test.types3.SgDerivedTypeB) ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) BigInteger(java.math.BigInteger) StructWithSubstitutionGroupAbstract(org.apache.type_test.types3.StructWithSubstitutionGroupAbstract) SgDerivedTypeC(org.apache.type_test.types3.SgDerivedTypeC) Test(org.junit.Test)

Example 44 with ObjectFactory

use of com.opensymphony.xwork2.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testChoiceWithSubstitutionGroupAbstract.

@Test
public void testChoiceWithSubstitutionGroupAbstract() throws Exception {
    if (!shouldRunTest("ChoiceWithSubstitutionGroupAbstract")) {
        return;
    }
    SgDerivedTypeB derivedB = new SgDerivedTypeB();
    derivedB.setVarInt(new BigInteger("32"));
    derivedB.setVarString("foo");
    SgDerivedTypeC derivedC = new SgDerivedTypeC();
    derivedC.setVarInt(new BigInteger("32"));
    derivedC.setVarFloat(3.14f);
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<? extends SgBaseTypeA> elementB = objectFactory.createSg03DerivedElementB(derivedB);
    JAXBElement<? extends SgBaseTypeA> elementC = objectFactory.createSg03DerivedElementC(derivedC);
    ChoiceWithSubstitutionGroupAbstract x = new ChoiceWithSubstitutionGroupAbstract();
    x.setSg03AbstractBaseElementA(elementC);
    ChoiceWithSubstitutionGroupAbstract yOrig = new ChoiceWithSubstitutionGroupAbstract();
    yOrig.setSg03AbstractBaseElementA(elementB);
    Holder<ChoiceWithSubstitutionGroupAbstract> y = new Holder<ChoiceWithSubstitutionGroupAbstract>(yOrig);
    Holder<ChoiceWithSubstitutionGroupAbstract> z = new Holder<ChoiceWithSubstitutionGroupAbstract>();
    ChoiceWithSubstitutionGroupAbstract ret;
    if (testDocLiteral) {
        ret = docClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    } else {
        ret = rpcClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect return value", equals(x, ret));
    }
}
Also used : SgDerivedTypeB(org.apache.type_test.types3.SgDerivedTypeB) ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) BigInteger(java.math.BigInteger) ChoiceWithSubstitutionGroupAbstract(org.apache.type_test.types3.ChoiceWithSubstitutionGroupAbstract) SgDerivedTypeC(org.apache.type_test.types3.SgDerivedTypeC) Test(org.junit.Test)

Example 45 with ObjectFactory

use of com.opensymphony.xwork2.ObjectFactory in project cxf by apache.

the class RMSoapOutInterceptorTest method setUpOutbound.

private void setUpOutbound() {
    ObjectFactory factory = new ObjectFactory();
    s1 = factory.createSequenceType();
    Identifier sid = factory.createIdentifier();
    sid.setValue("sequence1");
    s1.setIdentifier(sid);
    s1.setMessageNumber(ONE);
    s2 = factory.createSequenceType();
    sid = factory.createIdentifier();
    sid.setValue("sequence2");
    s2.setIdentifier(sid);
    s2.setMessageNumber(TEN);
    ack1 = factory.createSequenceAcknowledgement();
    SequenceAcknowledgement.AcknowledgementRange r = factory.createSequenceAcknowledgementAcknowledgementRange();
    r.setLower(ONE);
    r.setUpper(ONE);
    ack1.getAcknowledgementRange().add(r);
    ack1.setIdentifier(s1.getIdentifier());
    ack2 = factory.createSequenceAcknowledgement();
    r = factory.createSequenceAcknowledgementAcknowledgementRange();
    r.setLower(ONE);
    r.setUpper(TEN);
    ack2.getAcknowledgementRange().add(r);
    ack2.setIdentifier(s2.getIdentifier());
    ar1 = factory.createAckRequestedType();
    ar1.setIdentifier(s1.getIdentifier());
    ar2 = factory.createAckRequestedType();
    ar2.setIdentifier(s2.getIdentifier());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ObjectFactory(org.apache.cxf.ws.rm.v200702.ObjectFactory) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Aggregations

Test (org.junit.Test)15 JAXBElement (javax.xml.bind.JAXBElement)13 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)13 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)11 StringWriter (java.io.StringWriter)10 Marshaller (javax.xml.bind.Marshaller)10 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)10 BigInteger (java.math.BigInteger)9 JAXBContext (javax.xml.bind.JAXBContext)9 ArrayList (java.util.ArrayList)8 QName (javax.xml.namespace.QName)8 Holder (javax.xml.ws.Holder)7 ObjectFactory (org.apache.type_test.types3.ObjectFactory)7 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)6 ObjectFactory (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory)5 XStream (com.thoughtworks.xstream.XStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Writer (java.io.Writer)5 Ignore (jdk.nashorn.internal.ir.annotations.Ignore)5 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)5