Examples of MockExtensionContext


Examples of org.apache.ode.test.MockExtensionContext

    StringBuffer s = new StringBuffer();
    s.append("var request = dom2js(_context.readVariable('request'));\n");
    s.append("request.TestPart += ' World';\n");
    s.append("_context.writeVariable('request', js2dom(request));\n");

    MockExtensionContext c = new MockExtensionContext();
    c.getVariables().put("request", DOMUtils.stringToDOM("<message><TestPart>Hello</TestPart></message>"));
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    String res = DOMUtils.domToString(c.getVariables().get("request"));
    Assert.assertTrue(c.completed);
    Assert.assertFalse(c.faulted);
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart>Hello World</TestPart></message>", res);
  }
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

 
  @Test public void testHelloWorldDirect() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("request.TestPart += ' World';\n");

    MockExtensionContext c = new MockExtensionContext();
    c.getVariables().put("request", DOMUtils.stringToDOM("<message><TestPart>Hello</TestPart></message>"));
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    String res = DOMUtils.domToString(c.getVariables().get("request"));
    Assert.assertTrue(c.completed);
    Assert.assertFalse(c.faulted);
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart>Hello World</TestPart></message>", res);
  }
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

    s.append("var items = dom2js(_context.readVariable('items'));\n");
    s.append("items.TestPart.items.item += item.TestPart.item;\n");
    s.append("items.TestPart.items.item.(@hyped=='true').price *= 2;");
    s.append("_context.writeVariable('items', js2dom(items));\n");

    MockExtensionContext c = new MockExtensionContext();
    c.getVariables().put("item", DOMUtils.stringToDOM("<message><TestPart><item hyped=\"true\"><name>BPEL consulting</name><price>3000</price></item></TestPart></message>"));
    c.getVariables().put("items", DOMUtils.stringToDOM("<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item></items></TestPart></message>"));
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    String res = DOMUtils.domToString(c.getVariables().get("items"));
    Assert.assertTrue(c.completed);
    Assert.assertFalse(c.faulted);
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item><item hyped=\"true\"><name>BPEL consulting</name><price>6000</price></item></items></TestPart></message>", res);
  }
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testArrayCopyDirect() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("items.TestPart.items.item += item.TestPart.item;\n");
    s.append("items.TestPart.items.item.(@hyped=='true').price *= 2;");

    MockExtensionContext c = new MockExtensionContext();
    c.getVariables().put("item", DOMUtils.stringToDOM("<message><TestPart><item hyped=\"true\"><name>BPEL consulting</name><price>3000</price></item></TestPart></message>"));
    c.getVariables().put("items", DOMUtils.stringToDOM("<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item></items></TestPart></message>"));
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    String res = DOMUtils.domToString(c.getVariables().get("items"));
    Assert.assertTrue(c.completed);
    Assert.assertFalse(c.faulted);
    Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item><item hyped=\"true\"><name>BPEL consulting</name><price>6000</price></item></items></TestPart></message>", res);
  }
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testVariableNotFoundDirect() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("items1 = item;\n");

    MockExtensionContext c = new MockExtensionContext();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
    Assert.assertTrue(c.faulted);
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

 
  @Test public void testPrint() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("print('Hello World!');\n");

    MockExtensionContext c = new MockExtensionContext();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
    Assert.assertFalse(c.faulted);
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testLoad() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("load('../resources/test.js');\n");
    s.append("print(myvar);\n");

    MockExtensionContext c = new MockExtensionContext();
    c.duDir = this.getClass().getResource("/").toURI();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testPid() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("myvar = pid();\n");
    s.append("print(myvar);\n");

    MockExtensionContext c = new MockExtensionContext();
    c.duDir = this.getClass().getResource("/").toURI();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testActivityName() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("myvar = activityName();\n");
    s.append("print(myvar);\n");

    MockExtensionContext c = new MockExtensionContext();
    c.duDir = this.getClass().getResource("/").toURI();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
View Full Code Here

Examples of org.apache.ode.test.MockExtensionContext

  @Test public void testThrowFault() throws Exception {
    StringBuffer s = new StringBuffer();
    s.append("throwFault('urn:test', 'myfault', 'Ohje');\n");
    s.append("print('unreachable');\n");

    MockExtensionContext c = new MockExtensionContext();
    c.duDir = this.getClass().getResource("/").toURI();
    JSExtensionOperation jso = new JSExtensionOperation();
    Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
    jso.run(c, null, e);
    Assert.assertTrue(c.completed);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.