Package test

Examples of test.EchoString


    JAXBBlockFactory f = (JAXBBlockFactory)
      FactoryRegistry.getFactory(JAXBBlockFactory.class);
   
        // Create a jaxb object
        ObjectFactory factory = new ObjectFactory();
        EchoString jaxb = factory.createEchoString();
        jaxb.setInput("Hello World");
        JAXBBlockContext context = new JAXBBlockContext(EchoString.class.getPackage().getName());

        JAXBIntrospector jbi = JAXBUtils.getJAXBIntrospector(context.getJAXBContext());
        QName expectedQName = jbi.getElementName(jaxb);
   
    // On inbound, there will already be a XMLStreamReader (probably from OM)
    // which represents the message.  We will simulate this with inflow.
        StringWriter sw = new StringWriter();
        XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
        Marshaller marshaller = JAXBUtils.getJAXBMarshaller(context.getJAXBContext());
        marshaller.marshal(jaxb, writer);
        JAXBUtils.releaseJAXBMarshaller(context.getJAXBContext(), marshaller);
        writer.flush();
        sw.flush();
    StringReader sr = new StringReader(sw.toString());
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
   
    // Create a Block from the inflow. 
    Block block = f.createFrom(inflow, context, null);
       
    // Assume that we need to find the QName (perhaps to identify the operation and
    // determine if handlers are installed).   This is not very perfomant since
    // it causes an underlying parse of the String...but we need to support this.
    QName qName = block.getQName();
    assertTrue("Expected: " + expectedQName + " but found: " + qName, expectedQName.equals(qName));
   
    // Assuming no handlers are installed, the next thing that will happen
    // is the proxy code will ask for the business object.
    Object bo = block.getBusinessObject(true);
    assertTrue(bo instanceof EchoString);
   
    // The block should be consumed
    assertTrue(block.isConsumed());
   
    // Check for accuracy
    assertTrue("Unexpected:" + ((EchoString)bo).getInput(), ((EchoString)bo).getInput().equals(jaxb.getInput()));
   
  }
View Full Code Here


    JAXBBlockFactory f = (JAXBBlockFactory)
      FactoryRegistry.getFactory(JAXBBlockFactory.class);
   
        // Create a jaxb object
        ObjectFactory factory = new ObjectFactory();
        EchoString jaxb = factory.createEchoString();
        jaxb.setInput("Hello World");
        JAXBBlockContext context = new JAXBBlockContext(EchoString.class.getPackage().getName());
       
        JAXBIntrospector jbi = JAXBUtils.getJAXBIntrospector(context.getJAXBContext());
        QName expectedQName = jbi.getElementName(jaxb);
   
    // On inbound, there will already be a XMLStreamReader (probably from OM)
    // which represents the message.  We will simulate this with inflow.
        StringWriter sw = new StringWriter();
        XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
        Marshaller marshaller = JAXBUtils.getJAXBMarshaller(context.getJAXBContext());
        marshaller.marshal(jaxb, writer);
        JAXBUtils.releaseJAXBMarshaller(context.getJAXBContext(), marshaller);
        writer.flush();
        sw.flush();
    StringReader sr = new StringReader(sw.toString());
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
   
    // Create a Block from the inflow. 
    Block block = f.createFrom(inflow, context, expectedQName);
   
    // We passed in a qname, so the following should return false
    assertTrue(block.isQNameAvailable());
   
    // Assume that we need to find the QName (perhaps to identify the operation and
    // determine if handlers are installed).   This is not very perfomant since
    // it causes an underlying parse of the String...but we need to support this.
    QName qName = block.getQName();
    assertTrue("Expected: " + expectedQName + " but found: " + qName, expectedQName.equals(qName));
   
    // Assuming no handlers are installed, the next thing that will happen
    // is the proxy code will ask for the business object.
    Object bo = block.getBusinessObject(true);
    assertTrue(bo instanceof EchoString);
   
    // The block should be consumed
    assertTrue(block.isConsumed());
   
    // Check for accuracy
    assertTrue("Unexpected:" + ((EchoString)bo).getInput(), ((EchoString)bo).getInput().equals(jaxb.getInput()));
   
  }
View Full Code Here

     */
  public void testJAXBSourceInFlow1()throws Exception{
    //  Create a jaxb object
    try{
          ObjectFactory factory = new ObjectFactory();
          EchoString jaxb = factory.createEchoString();
          jaxb.setInput("Hello World");
          JAXBContext context = JAXBContext.newInstance("test");
        
          JAXBSource src = new JAXBSource(context.createMarshaller(), jaxb);
          BlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);
View Full Code Here

       
        JAXBContext context = JAXBContext.newInstance("test");
       
        Unmarshaller u = context.createUnmarshaller();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(echoSample.getBytes());
        EchoString jaxb = (EchoString)u.unmarshal(inputStream);
        JAXBSource src = new JAXBSource(context.createMarshaller(), jaxb);
       
        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(src, null, null);
View Full Code Here

       
        Object obj = msg.getPayload(jbc);
        assertTrue("The returned payload (Object) was null", obj != null);
        assertTrue("The returned payload (Object) was of the wrong type: " + obj.getClass().getName(), obj.getClass().equals(EchoString.class));
       
        EchoString echo = (EchoString) obj;
        assertTrue("The EchoString object had null input", echo.getInput() != null);
        assertTrue("The EchoString object had bad input: " + echo.getInput(), echo.getInput().equals(INPUT));
    }
View Full Code Here

        MessageFactory factory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
        Message msg = factory.create(Protocol.soap11);
       
        // Create a jaxb object
        ObjectFactory objFactory = new ObjectFactory();
        EchoString echo = objFactory.createEchoString();
        echo.setInput(INPUT);
       
        // Create the necessary JAXBContext
        JAXBContext jbc = JAXBContext.newInstance("test");
        JAXBBlockContext blockCtx = new JAXBBlockContext(jbc);
       
View Full Code Here

TOP

Related Classes of test.EchoString

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.