Search in sources :

Example 1 with Notifier

use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.

the class AnyTest method returnAny1.

private Void returnAny1(Context context) {
    Notifier notifier = testUtilities.rhinoCallConvert("testAny1ToClientChalk", Notifier.class, testUtilities.javaToJS(getAddress()));
    boolean notified = notifier.waitForJavascript(1000 * 20);
    assertTrue(notified);
    Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
    assertNull(errorStatus);
    String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
    assertNull(errorText);
    // This method returns a String
    String chalk = (String) testUtilities.rhinoEvaluate("globalResponseObject._any.object._chalk");
    assertEquals("dover", chalk);
    return null;
}
Also used : Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)

Example 2 with Notifier

use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.

the class DocLitBareClientTest method portObjectCaller.

private Void portObjectCaller(Context context) {
    LOG.info("About to call portObjectTest " + getAddress());
    Notifier notifier = testUtilities.rhinoCallConvert("portObjectTest", Notifier.class);
    boolean notified = notifier.waitForJavascript(1000 * 10);
    assertTrue(notified);
    Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
    assertNull(errorStatus);
    String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
    assertNull(errorText);
    // This method returns a String
    Scriptable response = (Scriptable) testUtilities.rhinoEvaluate("globalResponseObject");
    String item = testUtilities.rhinoCallMethodConvert(String.class, response, "getStringItem");
    assertEquals("horsefeathers", item);
    return null;
}
Also used : Scriptable(org.mozilla.javascript.Scriptable) Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)

Example 3 with Notifier

use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.

the class DocLitBareClientTest method beanFunctionCaller.

private Void beanFunctionCaller(Context context) {
    TestBean1 b1 = new TestBean1();
    b1.stringItem = "strung";
    TestBean1[] beans = new TestBean1[3];
    beans[0] = new TestBean1();
    beans[0].stringItem = "zerobean";
    beans[0].beanTwoNotRequiredItem = new TestBean2("bean2");
    beans[1] = null;
    beans[2] = new TestBean1();
    beans[2].stringItem = "twobean";
    beans[2].optionalIntArrayItem = new int[2];
    beans[2].optionalIntArrayItem[0] = 4;
    beans[2].optionalIntArrayItem[1] = 6;
    Object[] jsBeans = new Object[3];
    jsBeans[0] = testBean1ToJS(testUtilities, context, beans[0]);
    jsBeans[1] = null;
    jsBeans[2] = testBean1ToJS(testUtilities, context, beans[2]);
    Scriptable jsBean1 = testBean1ToJS(testUtilities, context, b1);
    Scriptable jsBeanArray = context.newArray(testUtilities.getRhinoScope(), jsBeans);
    LOG.info("About to call beanFunctionTest " + getAddress());
    Notifier notifier = testUtilities.rhinoCallConvert("beanFunctionTest", Notifier.class, testUtilities.javaToJS(getAddress()), jsBean1, jsBeanArray);
    boolean notified = notifier.waitForJavascript(1000 * 10);
    assertTrue(notified);
    Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
    assertNull(errorStatus);
    String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
    assertNull(errorText);
    // this method returns void.
    Scriptable responseObject = (Scriptable) testUtilities.rhinoEvaluate("globalResponseObject");
    // there is no response, this thing returns 'void'
    assertNull(responseObject);
    SimpleDocLitBareImpl impl = (SimpleDocLitBareImpl) rawImplementor;
    TestBean1 b1returned = impl.getLastBean1();
    assertEquals(b1, b1returned);
    // assertArrayEquals(beans, beansReturned);
    return null;
}
Also used : TestBean1(org.apache.cxf.javascript.fortest.TestBean1) SimpleDocLitBareImpl(org.apache.cxf.javascript.fortest.SimpleDocLitBareImpl) TestBean2(org.apache.cxf.javascript.fortest.TestBean2) Scriptable(org.mozilla.javascript.Scriptable) Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)

Example 4 with Notifier

use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.

the class DocLitBareClientTest method actionMethodCaller.

private Void actionMethodCaller(Context context) {
    LOG.info("About to call actionMethod" + getAddress());
    Notifier notifier = testUtilities.rhinoCallConvert("actionMethodTest", Notifier.class, testUtilities.javaToJS(getAddress()), "wrong");
    boolean notified = notifier.waitForJavascript(1000 * 10);
    assertTrue(notified);
    Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
    assertNull(errorStatus);
    String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
    assertNull(errorText);
    // This method returns a String
    String response = (String) testUtilities.rhinoEvaluate("globalResponseObject");
    assertEquals("wrong", response);
    return null;
}
Also used : Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)

Example 5 with Notifier

use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.

the class DocLitWrappedClientTest method beanFunctionCaller.

private Void beanFunctionCaller(Context context, boolean useWrapper) {
    TestBean1 b1 = new TestBean1();
    b1.stringItem = "strung";
    TestBean1[] beans = new TestBean1[3];
    beans[0] = new TestBean1();
    beans[0].beanTwoNotRequiredItem = new TestBean2("bean2");
    if (useWrapper) {
        beans[1] = null;
    } else {
        // without a wrapper, it can't be null, so put something in there.
        beans[1] = new TestBean1();
    }
    beans[2] = new TestBean1();
    beans[2].optionalIntArrayItem = new int[2];
    beans[2].optionalIntArrayItem[0] = 4;
    beans[2].optionalIntArrayItem[1] = 6;
    Object[] jsBeans = new Object[3];
    jsBeans[0] = testBean1ToJS(testUtilities, context, beans[0]);
    jsBeans[1] = testBean1ToJS(testUtilities, context, beans[1]);
    jsBeans[2] = testBean1ToJS(testUtilities, context, beans[2]);
    Scriptable jsBean1 = testBean1ToJS(testUtilities, context, b1);
    Scriptable jsBeanArray = context.newArray(testUtilities.getRhinoScope(), jsBeans);
    LOG.info("About to call test4 " + getAddress());
    Notifier notifier = testUtilities.rhinoCallConvert("test4", Notifier.class, testUtilities.javaToJS(getAddress()), testUtilities.javaToJS(Boolean.valueOf(useWrapper)), jsBean1, jsBeanArray);
    boolean notified = notifier.waitForJavascript(1000 * 10);
    assertTrue(notified);
    Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
    assertNull(errorStatus);
    String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
    assertNull(errorText);
    // This method returns void, which translated into a Javascript object with no properties.
    // really. Void.
    Object responseObject = testUtilities.rhinoEvaluate("globalResponseObject");
    assertNotNull(responseObject);
    assertEquals(Context.getUndefinedValue(), responseObject);
    SimpleDocLitWrappedImpl impl = (SimpleDocLitWrappedImpl) rawImplementor;
    TestBean1 b1returned = impl.getLastBean1();
    assertEquals(b1, b1returned);
    TestBean1[] beansReturned = impl.getLastBean1Array();
    assertArrayEquals(beans, beansReturned);
    return null;
}
Also used : TestBean1(org.apache.cxf.javascript.fortest.TestBean1) SimpleDocLitWrappedImpl(org.apache.cxf.javascript.fortest.SimpleDocLitWrappedImpl) TestBean2(org.apache.cxf.javascript.fortest.TestBean2) Scriptable(org.mozilla.javascript.Scriptable) Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)

Aggregations

Notifier (org.apache.cxf.javascript.JavascriptTestUtilities.Notifier)13 Scriptable (org.mozilla.javascript.Scriptable)5 TestBean1 (org.apache.cxf.javascript.fortest.TestBean1)3 TestBean2 (org.apache.cxf.javascript.fortest.TestBean2)3 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 XPath (javax.xml.xpath.XPath)1 CountDownNotifier (org.apache.cxf.javascript.JavascriptTestUtilities.CountDownNotifier)1 SimpleDocLitBareImpl (org.apache.cxf.javascript.fortest.SimpleDocLitBareImpl)1 SimpleDocLitWrappedImpl (org.apache.cxf.javascript.fortest.SimpleDocLitWrappedImpl)1 SimpleRPCImpl (org.apache.cxf.javascript.fortest.SimpleRPCImpl)1 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)1 AbstractCXFSpringTest (org.apache.cxf.test.AbstractCXFSpringTest)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1