Package org.milyn.payload

Examples of org.milyn.payload.StringResult


        test_SetNamespace(FilterSettings.DEFAULT_DOM);
    }

    private void test_SetNamespace(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks();
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setElementName("c"), "b");
        smooks.addVisitor(new SetElementData().setElementName("xxx:z").
                               setAttribute(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xxx", "xmlns"), "http://xxx"), "e");

        smooks.filterSource(new StringSource("<a><b><d><e>some text</e></d></b></a>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a><c><d><xxx:z xmlns:xxx=\"http://xxx\">some text</xxx:z></d></c></a>"), new StringReader(result.getResult()));
    }
View Full Code Here


        test_ChangeNamespace_1(FilterSettings.DEFAULT_DOM);
    }

    public void test_ChangeNamespace_1(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks();
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setElementName("c"), "b");
        smooks.addVisitor(new RemoveAttribute().setName("xmlns:xxx").setNamespace(XMLConstants.XMLNS_ATTRIBUTE_NS_URI), "z");
        smooks.addVisitor(new SetElementData().setElementNamespace("http://yyy").setElementName("yyy:z").
                               setAttribute(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "yyy", "xmlns"), "http://yyy"), "z");

        smooks.filterSource(new StringSource("<a><c><d><xxx:z xmlns:xxx=\"http://xxx\">some text</xxx:z></d></c></a>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a><c><d><yyy:z xmlns:yyy=\"http://yyy\">some text</yyy:z></d></c></a>"), new StringReader(result.getResult()));
    }
View Full Code Here

        test_ChangeNamespace_2(FilterSettings.DEFAULT_DOM);
    }

    public void test_ChangeNamespace_2(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks();
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setElementName("c"), "b");
        smooks.addVisitor(new SetElementData().setAttribute(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xxx", "xmlns"), "http://yyy"), "z");

        smooks.filterSource(new StringSource("<a><c><d><xxx:z xmlns:xxx=\"http://xxx\">some text</xxx:z></d></c></a>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a><c><d><xxx:z xmlns:xxx=\"http://yyy\">some text</xxx:z></d></c></a>"), new StringReader(result.getResult()));
    }
View Full Code Here

        test_SetAttribute_1(FilterSettings.DEFAULT_DOM);
    }

    public void test_SetAttribute_1(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks();
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setAttribute(new QName("xxx"), "${injectedVal}"), "a");

        ExecutionContext execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("injectedVal", "something");

        smooks.filterSource(execContext, new StringSource("<a/>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a xxx=\"something\" />"), new StringReader(result.getResult()));
    }
View Full Code Here

        test_SetAttribute_2(FilterSettings.DEFAULT_DOM);
    }

    public void test_SetAttribute_2(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks();
        StringResult result = new StringResult();

        smooks.setFilterSettings(filterSettings);
        smooks.addVisitor(new SetElementData().setAttribute(new QName("http://www.w3.org/2000/xmlns/", "ns1", "xmlns"), "http://ns1").
                                               setAttribute(new QName("http://ns1", "xxx", "ns1"), "${injectedVal}"), "a");

        ExecutionContext execContext = smooks.createExecutionContext();
        execContext.getBeanContext().addBean("injectedVal", "something");

        smooks.filterSource(execContext, new StringSource("<a/>"), result);

        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new StringReader("<a xmlns:ns1=\"http://ns1\" ns1:xxx=\"something\" />"), new StringReader(result.getResult()));
    }
View Full Code Here

*/
public class MILYN_367_Test extends TestCase {

  public void test_SAX_01() throws SAXException, IOException {
    Smooks smooks = new Smooks();
    StringResult result = new StringResult();
   
    smooks.addVisitor(new DefaultSAXElementSerializer(), "#document");
    smooks.addVisitor(new DefaultSAXElementSerializer(), "#document/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.SAX));
   
View Full Code Here

    assertOK("expected_01.xml", result);       
  }

  public void test_SAX_02() throws SAXException, IOException {
    Smooks smooks = new Smooks();
    StringResult result = new StringResult();
   
    smooks.addVisitor(new DefaultSAXElementSerializer(), "customer");
    smooks.addVisitor(new DefaultSAXElementSerializer(), "customer/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.SAX));
   
View Full Code Here

    assertOK("expected_02.xml", result);       
  }

  public void test_SAX_03() throws SAXException, IOException {
    Smooks smooks = new Smooks();
    StringResult result = new StringResult();
   
    smooks.addVisitor(new DefaultSAXElementSerializer(), "items");
    smooks.addVisitor(new DefaultSAXElementSerializer(), "items/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.SAX));
   
View Full Code Here

    assertOK("expected_03.xml", result);       
  }

  public void test_DOM_01() throws SAXException, IOException {
    Smooks smooks = new Smooks();
    StringResult result = new StringResult();
   
    smooks.addVisitor(new DefaultSerializationUnit(), "#document");
    smooks.addVisitor(new DefaultSerializationUnit(), "#document/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.DOM));
   
View Full Code Here

    assertOK("expected_01.xml", result);       
  }

  public void test_DOM_02() throws SAXException, IOException {
    Smooks smooks = new Smooks();
    StringResult result = new StringResult();
   
    smooks.addVisitor(new DefaultSerializationUnit(), "customer");
    smooks.addVisitor(new DefaultSerializationUnit(), "customer/**");
    smooks.setFilterSettings(new FilterSettings().setDefaultSerializationOn(false).setFilterType(StreamFilterType.DOM));
   
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringResult

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.