use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.
the class GreeterClientTest method sayHiCaller.
private Void sayHiCaller(Context context) {
Notifier notifier = testUtilities.rhinoCallConvert("sayHiTest", Notifier.class, testUtilities.javaToJS(getAddress()));
boolean notified = notifier.waitForJavascript(1000 * 15);
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 inside of an object, since there's an @WebResponse
String responseObject = testUtilities.rhinoEvaluateConvert("globalResponseObject.getResponseType()", String.class);
assertEquals("Bonjour", responseObject);
return null;
}
use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.
the class JsHttpRequestTest method runTests.
// just one test function to avoid muddles with engine startup/shutdown
@Test
public void runTests() throws Exception {
testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testOpaqueURI");
testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testNonAbsolute");
testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testNonHttp");
testUtilities.rhinoCallExpectingExceptionInContext("INVALID_STATE_ERR", "testSendNotOpenError");
testUtilities.rhinoCallInContext("testStateNotificationSync");
Notifier notifier = testUtilities.rhinoCallConvert("testAsyncHttpFetch1", Notifier.class);
testUtilities.rhinoCallInContext("testAsyncHttpFetch2");
boolean notified = notifier.waitForJavascript(2 * 10000);
assertTrue(notified);
assertEquals("HEADERS_RECEIVED", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotHeadersReceived", Boolean.class));
assertEquals("LOADING", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotLoading", Boolean.class));
assertEquals("DONE", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotDone", Boolean.class));
String outOfOrder = testUtilities.rhinoEvaluateConvert("outOfOrderError", String.class);
assertEquals("OutOfOrder", null, outOfOrder);
assertEquals("status 200", Integer.valueOf(200), testUtilities.rhinoEvaluateConvert("asyncStatus", Integer.class));
assertEquals("status text", "OK", testUtilities.rhinoEvaluateConvert("asyncStatusText", String.class));
assertTrue("headers", testUtilities.rhinoEvaluateConvert("asyncResponseHeaders", String.class).contains("Content-Type: text/html"));
Object httpObj = testUtilities.rhinoCallInContext("testSyncHttpFetch");
assertNotNull(httpObj);
assertTrue(httpObj instanceof String);
String httpResponse = (String) httpObj;
assertTrue(httpResponse.contains("Test"));
Reader r = getResourceAsReader("/org/apache/cxf/javascript/XML_GreetMeDocLiteralReq.xml");
String xml = IOUtils.toString(r);
EndpointImpl endpoint = this.getBean(EndpointImpl.class, "greeter-service-endpoint");
JsSimpleDomNode xmlResponse = testUtilities.rhinoCallConvert("testSyncXml", JsSimpleDomNode.class, testUtilities.javaToJS(endpoint.getAddress()), testUtilities.javaToJS(xml));
assertNotNull(xmlResponse);
Document doc = (Document) xmlResponse.getWrappedNode();
testUtilities.addNamespace("t", "http://apache.org/hello_world_xml_http/wrapped/types");
XPath textPath = XPathAssert.createXPath(testUtilities.getNamespaces());
String nodeText = (String) textPath.evaluate("//t:responseType/text()", doc, XPathConstants.STRING);
assertEquals("Hello \u05e9\u05dc\u05d5\u05dd", nodeText);
}
use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.
the class MtoMTest method sendMtoMString.
private Void sendMtoMString(Context context) throws IOException {
Notifier notifier = testUtilities.rhinoCallConvert("testMtoMReply", Notifier.class, testUtilities.javaToJS(getAddress()));
boolean notified = notifier.waitForJavascript(1000 * 30);
assertTrue(notified);
Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
assertNull(errorStatus);
assertNull(errorText);
String unpacked = testUtilities.rhinoEvaluateConvert("globalResponseObject._notXml10", String.class);
assertNotNull(unpacked);
return null;
}
use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.
the class MtoMTest method acceptMtoMString.
private Void acceptMtoMString(Context context) throws IOException {
Notifier notifier = testUtilities.rhinoCallConvert("testMtoMString", Notifier.class, testUtilities.javaToJS(getAddress()));
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);
assertEquals("disorganized<organized", implementor.getLastDHBean().getOrdinary());
InputStream dis = implementor.getLastDHBean().getNotXml10().getInputStream();
byte[] bytes = new byte[2048];
int byteCount = dis.read(bytes, 0, 2048);
String stuff = IOUtils.newStringFromBytes(bytes, 0, byteCount);
assertEquals("<html>\u0027</html>", stuff);
return null;
}
use of org.apache.cxf.javascript.JavascriptTestUtilities.Notifier in project cxf by apache.
the class AegisTest method returnBeanWithAnyTypeArray.
private Void returnBeanWithAnyTypeArray(Context context) {
Notifier notifier = testUtilities.rhinoCallConvert("testReturningBeanWithAnyTypeArray", Notifier.class, testUtilities.javaToJS(getAddress()));
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 'BeanWithAnyTypeArray'.
// start by looking at the string.
String beanString = (String) testUtilities.rhinoEvaluate("globalResponseObject._return._string");
assertEquals("lima", beanString);
Object o1 = testUtilities.rhinoEvaluate("globalResponseObject._return._objects._anyType[0]");
assertNotNull(o1);
String marker = testUtilities.rhinoEvaluateConvert("globalResponseObject._return._objects._anyType[0].typeMarker", String.class);
assertEquals("aegis_fortest_javascript_cxf_apache_org_Mammal", marker);
Object intValue = testUtilities.rhinoEvaluate("globalResponseObject._return._objects._anyType[1]");
assertEquals(new Float(42), new Float(intValue.toString()));
return null;
}
Aggregations