Package org.apache.tuscany.sca.databinding

Examples of org.apache.tuscany.sca.databinding.TransformationContext


        context.setTargetDataType(targetDataType);
        return context;
    }

    public void testTransform1() {
        TransformationContext context = createTransformationContext(String.class, Node.class);
        Object node =
            mediator.mediate(IPO_XML, context.getSourceDataType(), context.getTargetDataType(), null);
        Assert.assertTrue(node instanceof Document);
        Element root = ((Document)node).getDocumentElement();
        Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO");
        Assert.assertEquals(root.getLocalName(), "purchaseOrder");
    }
View Full Code Here


        Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO");
        Assert.assertEquals(root.getLocalName(), "purchaseOrder");
    }

    public void testTransform2() {
        TransformationContext context = createTransformationContext(String.class, Writer.class);
        Writer writer = new StringWriter();
        mediator.mediate(IPO_XML, writer, context.getSourceDataType(), context.getTargetDataType(), null);
        String str = writer.toString();
        Assert.assertTrue(str != null && str.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
    }
View Full Code Here

            .contains("<xsl:root xmlns:xsl=\"http://foo.com\"><data>my json string</data></xsl:root>"));
    }

    public void testJSON2OMElement() throws Exception {
        JSON2OMElement t1 = new JSON2OMElement();
        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
    }
View Full Code Here

        service.setId("ID001");
        bean.setService(service);
        bean.setOtherService(service);
        QName name = new QName("http://ns1", "bean");
        JAXBElement<Object> element = new JAXBElement<Object>(name, Object.class, bean);
        TransformationContext tContext = new TransformationContextImpl();
        XMLStreamReader reader = new JAXB2XMLStreamReader().transform(element, tContext);

//        XMLStreamReader2String t2 = new XMLStreamReader2String();
//        String xml = t2.transform(reader, null);
        // System.out.println(xml);
View Full Code Here

    public void testTransform() throws Exception {
        Reader2JAXB t0 = new Reader2JAXB();

        DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        expect(tContext.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

        QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
        DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        expect(tContext.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

    public void testTransform3() throws Exception {

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        PurchaseOrderType po = new ObjectFactory().createPurchaseOrderType();
        Node node = t1.transform(po, tContext1);
View Full Code Here

    public void testTransform() throws Exception {
        Reader2JAXB t0 = new Reader2JAXB();

        DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

        QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
        DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

    public void testTransform3() throws Exception {

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        PurchaseOrderType po = new ObjectFactory().createPurchaseOrderType();
        Node node = t1.transform(po, tContext1);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.databinding.TransformationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.