You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2007/11/23 00:23:10 UTC
svn commit: r597511 [1/2] - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/service/model/
api/src/test/java/org/apache/cxf/service/model/
rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/
rt/bindings/soap/src/main/java/org/apache...
Author: bimargulies
Date: Thu Nov 22 15:23:08 2007
New Revision: 597511
URL: http://svn.apache.org/viewvc?rev=597511&view=rev
Log:
Further work on Javascript. To support same, make MessageInfo store the message type (input or output).
Added:
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
incubator/cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml
incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/MessageInfo.java
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingMessageInfoTest.java
incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessageInfoTest.java
incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessagePartInfoTest.java
incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/OperationInfoTest.java
incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java
incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties
incubator/cxf/trunk/rt/javascript/src/test/resources/serializationTestBeans.xml
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/MethodMapperTest.java
Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/MessageInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/MessageInfo.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/MessageInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/MessageInfo.java Thu Nov 22 15:23:08 2007
@@ -30,8 +30,18 @@
import org.apache.cxf.common.util.StringUtils;
public class MessageInfo extends AbstractMessageContainer {
- public MessageInfo(OperationInfo op, QName nm) {
+
+ public static enum Type {
+ INPUT,
+ OUTPUT,
+ FAULT;
+ }
+
+ private Type type;
+
+ public MessageInfo(OperationInfo op, Type type, QName nm) {
super(op, nm);
+ this.type = type;
}
public void setName(QName qn) {
@@ -59,4 +69,19 @@
}
return orderedParts;
}
+
+ @Override
+ public String toString() {
+ return "[MessageInfo " + type + mName.toString() + "]";
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+
}
Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java Thu Nov 22 15:23:08 2007
@@ -77,8 +77,8 @@
}
- public MessageInfo createMessage(QName nm) {
- return new MessageInfo(this, nm);
+ public MessageInfo createMessage(QName nm, MessageInfo.Type type) {
+ return new MessageInfo(this, type, nm);
}
public MessageInfo getOutput() {
Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingMessageInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingMessageInfoTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingMessageInfoTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingMessageInfoTest.java Thu Nov 22 15:23:08 2007
@@ -28,20 +28,21 @@
public class BindingMessageInfoTest extends Assert {
private BindingMessageInfo bindingMessageInfo;
-
+
@Before
public void setUp() throws Exception {
- MessageInfo messageInfo = new MessageInfo(null, new QName(
- "http://apache.org/hello_world_soap_http", "testMessage"));
+ MessageInfo messageInfo = new MessageInfo(null, MessageInfo.Type.INPUT,
+ new QName("http://apache.org/hello_world_soap_http",
+ "testMessage"));
bindingMessageInfo = new BindingMessageInfo(messageInfo, null);
}
-
+
@Test
public void testMessage() {
assertNotNull(bindingMessageInfo.getMessageInfo());
assertEquals(bindingMessageInfo.getMessageInfo().getName().getLocalPart(), "testMessage");
assertEquals(bindingMessageInfo.getMessageInfo().getName().getNamespaceURI(),
- "http://apache.org/hello_world_soap_http");
+ "http://apache.org/hello_world_soap_http");
assertNull(bindingMessageInfo.getBindingOperation());
}
}
Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/BindingOperationInfoTest.java Thu Nov 22 15:23:08 2007
@@ -33,11 +33,13 @@
public void setUp() throws Exception {
OperationInfo operationInfo = new OperationInfo(null, new QName(TEST_NS, "operationTest"));
MessageInfo inputMessage = operationInfo.createMessage(new QName(
- "http://apache.org/hello_world_soap_http", "testInputMessage"));
+ "http://apache.org/hello_world_soap_http", "testInputMessage"),
+ MessageInfo.Type.INPUT);
operationInfo.setInput("input", inputMessage);
MessageInfo outputMessage = operationInfo.createMessage(new QName(
- "http://apache.org/hello_world_soap_http", "testOutputMessage"));
+ "http://apache.org/hello_world_soap_http", "testOutputMessage"),
+ MessageInfo.Type.OUTPUT);
operationInfo.setOutput("output", outputMessage);
operationInfo.addFault(new QName(TEST_NS, "fault"), new QName(
"http://apache.org/hello_world_soap_http", "faultMessage"));
Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessageInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessageInfoTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessageInfoTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessageInfoTest.java Thu Nov 22 15:23:08 2007
@@ -31,8 +31,8 @@
@Before
public void setUp() throws Exception {
- messageInfo = new MessageInfo(null, new QName(
- "http://apache.org/hello_world_soap_http", "testMessage"));
+ messageInfo = new MessageInfo(null, MessageInfo.Type.INPUT,
+ new QName("http://apache.org/hello_world_soap_http", "testMessage"));
}
@Test
Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessagePartInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessagePartInfoTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessagePartInfoTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/MessagePartInfoTest.java Thu Nov 22 15:23:08 2007
@@ -34,7 +34,8 @@
@Before
public void setUp() throws Exception {
- MessageInfo msg = new MessageInfo(null,
+ MessageInfo msg = new MessageInfo(null,
+ MessageInfo.Type.INPUT,
new QName("http://apache.org/hello_world_soap_http/types",
"testMessage"));
messagePartInfo = new MessagePartInfo(new QName(
Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/OperationInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/OperationInfoTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/OperationInfoTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/service/model/OperationInfoTest.java Thu Nov 22 15:23:08 2007
@@ -52,7 +52,8 @@
public void testInput() throws Exception {
assertFalse(operationInfo.hasInput());
MessageInfo inputMessage = operationInfo.createMessage(new QName(
- "http://apache.org/hello_world_soap_http", "testInputMessage"));
+ "http://apache.org/hello_world_soap_http", "testInputMessage"),
+ MessageInfo.Type.INPUT);
operationInfo.setInput("input", inputMessage);
assertTrue(operationInfo.hasInput());
inputMessage = operationInfo.getInput();
@@ -66,7 +67,8 @@
public void testOutput() throws Exception {
assertFalse(operationInfo.hasOutput());
MessageInfo outputMessage = operationInfo.createMessage(new QName(
- "http://apache.org/hello_world_soap_http", "testOutputMessage"));
+ "http://apache.org/hello_world_soap_http", "testOutputMessage"),
+ MessageInfo.Type.OUTPUT);
operationInfo.setOutput("output", outputMessage);
assertTrue(operationInfo.hasOutput());
outputMessage = operationInfo.getOutput();
@@ -80,7 +82,8 @@
public void testOneWay() throws Exception {
assertFalse(operationInfo.isOneWay());
MessageInfo inputMessage = operationInfo.createMessage(new QName(
- "http://apache.org/hello_world_soap_http", "testInputMessage"));
+ "http://apache.org/hello_world_soap_http", "testInputMessage"),
+ MessageInfo.Type.INPUT);
operationInfo.setInput("input", inputMessage);
assertTrue(operationInfo.isOneWay());
}
Modified: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java Thu Nov 22 15:23:08 2007
@@ -205,8 +205,8 @@
QName mn1 = new QName("A", "B");
QName mn2 = new QName("C", "D");
- MessageInfo mi1 = new MessageInfo(oi, mn1);
- MessageInfo mi2 = new MessageInfo(oi, mn2);
+ MessageInfo mi1 = new MessageInfo(oi, MessageInfo.Type.INPUT, mn1);
+ MessageInfo mi2 = new MessageInfo(oi, MessageInfo.Type.INPUT, mn2);
match = ColocUtil.isSameMessageInfo(mi1, null);
assertEquals("Should not find a match", false, match);
match = ColocUtil.isSameMessageInfo(null, mi2);
Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Thu Nov 22 15:23:08 2007
@@ -406,14 +406,18 @@
private void addOutOfBandParts(final BindingOperationInfo bop, final javax.wsdl.Message msg,
final SchemaCollection schemas, boolean isInput) {
MessageInfo minfo = null;
+ MessageInfo.Type type;
+
if (isInput) {
+ type = MessageInfo.Type.INPUT;
minfo = bop.getOperationInfo().getInput();
} else {
+ type = MessageInfo.Type.OUTPUT;
minfo = bop.getOperationInfo().getOutput();
}
if (minfo == null) {
- minfo = new MessageInfo(null, msg.getQName());
+ minfo = new MessageInfo(null, type, msg.getQName());
}
buildMessage(minfo, msg, schemas);
@@ -422,14 +426,17 @@
if (unwrapped == null) {
return;
}
+
if (isInput) {
minfo = unwrapped.getInput();
+ type = MessageInfo.Type.INPUT;
} else {
minfo = unwrapped.getOutput();
+ type = MessageInfo.Type.OUTPUT;
}
if (minfo == null) {
- minfo = new MessageInfo(unwrapped, msg.getQName());
+ minfo = new MessageInfo(unwrapped, type, msg.getQName());
}
buildMessage(minfo, msg, schemas);
}
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Thu Nov 22 15:23:08 2007
@@ -458,7 +458,7 @@
this.copyExtensionAttributes(opInfo, op);
Input input = op.getInput();
if (input != null) {
- MessageInfo minfo = opInfo.createMessage(input.getMessage().getQName());
+ MessageInfo minfo = opInfo.createMessage(input.getMessage().getQName(), MessageInfo.Type.INPUT);
opInfo.setInput(input.getName(), minfo);
buildMessage(minfo, input.getMessage());
copyExtensors(minfo, input.getExtensibilityElements());
@@ -466,7 +466,7 @@
}
Output output = op.getOutput();
if (output != null) {
- MessageInfo minfo = opInfo.createMessage(output.getMessage().getQName());
+ MessageInfo minfo = opInfo.createMessage(output.getMessage().getQName(), MessageInfo.Type.OUTPUT);
opInfo.setOutput(output.getName(), minfo);
buildMessage(minfo, output.getMessage());
copyExtensors(minfo, output.getExtensibilityElements());
@@ -548,7 +548,8 @@
// Now lets see if we have any attributes...
// This should probably look at the restricted and substitute types too.
OperationInfo unwrapped = new UnwrappedOperationInfo(opInfo);
- MessageInfo unwrappedInput = new MessageInfo(unwrapped, inputMessage.getName());
+ MessageInfo unwrappedInput = new MessageInfo(unwrapped, MessageInfo.Type.INPUT,
+ inputMessage.getName());
MessageInfo unwrappedOutput = null;
XmlSchemaComplexType xsct = null;
@@ -568,7 +569,7 @@
}
if (outputMessage != null) {
- unwrappedOutput = new MessageInfo(unwrapped, outputMessage.getName());
+ unwrappedOutput = new MessageInfo(unwrapped, MessageInfo.Type.OUTPUT, outputMessage.getName());
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java Thu Nov 22 15:23:08 2007
@@ -65,8 +65,10 @@
jwsc.setServiceFactory(bean);
OperationInfo op = si.getInterface().getOperation(opName);
- op.setInput("input", new MessageInfo(op, new QName("http://cxf.com/", "input")));
- op.setOutput("output", new MessageInfo(op, new QName("http://cxf.com/", "output")));
+ op.setInput("input", new MessageInfo(op, MessageInfo.Type.INPUT,
+ new QName("http://cxf.com/", "input")));
+ op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT,
+ new QName("http://cxf.com/", "output")));
QName partName = jwsc.getInPartName(op, sayHelloMethod, 0);
assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg0"), partName);
@@ -133,7 +135,9 @@
// clear the output
OperationInfo op = si.getInterface().getOperation(opName);
- op.setOutput("output", new MessageInfo(op, new QName("http://cxf.com/", "output")));
+ op.setOutput("output", new MessageInfo(op,
+ MessageInfo.Type.OUTPUT,
+ new QName("http://cxf.com/", "output")));
QName partName = jwsc.getOutPartName(op, sayHiMethod, -1);
assertEquals("get wrong return partName", new QName("http://cxf.com/", "return"), partName);
Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Thu Nov 22 15:23:08 2007
@@ -542,7 +542,7 @@
createMessageParts(intf, uOp, m);
if (uOp.hasInput()) {
- MessageInfo msg = new MessageInfo(op, uOp.getInput().getName());
+ MessageInfo msg = new MessageInfo(op, MessageInfo.Type.INPUT, uOp.getInput().getName());
op.setInput(uOp.getInputName(), msg);
createInputWrappedMessageParts(uOp, m, msg);
@@ -555,7 +555,7 @@
if (uOp.hasOutput()) {
QName name = uOp.getOutput().getName();
- MessageInfo msg = new MessageInfo(op, name);
+ MessageInfo msg = new MessageInfo(op, MessageInfo.Type.OUTPUT, name);
op.setOutput(uOp.getOutputName(), msg);
createOutputWrappedMessageParts(uOp, m, msg);
@@ -1024,7 +1024,7 @@
final Class[] paramClasses = method.getParameterTypes();
// Setup the input message
op.setProperty(METHOD, method);
- MessageInfo inMsg = op.createMessage(this.getInputMessageName(op, method));
+ MessageInfo inMsg = op.createMessage(this.getInputMessageName(op, method), MessageInfo.Type.INPUT);
op.setInput(inMsg.getName().getLocalPart(), inMsg);
for (int j = 0; j < paramClasses.length; j++) {
if (isInParam(method, j)) {
@@ -1051,7 +1051,8 @@
if (hasOutMessage(method)) {
// Setup the output message
- MessageInfo outMsg = op.createMessage(createOutputMessageName(op, method));
+ MessageInfo outMsg = op.createMessage(createOutputMessageName(op, method),
+ MessageInfo.Type.OUTPUT);
op.setOutput(outMsg.getName().getLocalPart(), outMsg);
final Class<?> returnType = method.getReturnType();
if (!returnType.isAssignableFrom(void.class)) {
@@ -1078,7 +1079,8 @@
for (int j = 0; j < paramClasses.length; j++) {
if (isOutParam(method, j)) {
if (outMsg == null) {
- outMsg = op.createMessage(createOutputMessageName(op, method));
+ outMsg = op.createMessage(createOutputMessageName(op, method),
+ MessageInfo.Type.OUTPUT);
}
QName q = getOutPartName(op, method, j);
QName q2 = getOutParameterName(op, method, j);
Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties Thu Nov 22 15:23:08 2007
@@ -18,6 +18,7 @@
# under the License.
#
#
-NO_SOAP_BINDING=Service {1} has no SOAP binding.
-MULTIPLE_OUTPUTS=Operation {1} has more than one output part.
-RPC= Service {1} calls for unsupported RPC binding style.
\ No newline at end of file
+NO_USABLE_BINDING=Service {0} has no SOAP or XML binding.
+MULTIPLE_OUTPUTS=Operation {0} has more than one output part.
+RPC= Service {0} calls for unsupported RPC binding style.
+XML_BINDING= Service {0} calls for unsupported XML binding.
\ No newline at end of file
Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java Thu Nov 22 15:23:08 2007
@@ -27,6 +27,8 @@
import java.util.Set;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+
import org.apache.cxf.binding.soap.SoapBindingConstants;
import org.apache.cxf.binding.soap.SoapVersion;
import org.apache.cxf.binding.soap.model.SoapBindingInfo;
@@ -55,7 +57,7 @@
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaSequence;
-class ServiceJavascriptBuilder extends ServiceModelVisitor {
+public class ServiceJavascriptBuilder extends ServiceModelVisitor {
private static final Logger LOG = LogUtils.getL7dLogger(ServiceJavascriptBuilder.class);
private boolean isRPC;
@@ -64,15 +66,23 @@
private NameManager nameManager;
private StringBuilder code;
private String currentInterfaceClassName;
+ private OperationInfo currentOperation;
private Set<OperationInfo> operationsWithNameConflicts;
+ private Set<MessageInfo> inputMessagesWithNameConflicts;
+ private Set<MessageInfo> outputMessagesWithNameConflicts;
private SchemaCollection xmlSchemaCollection;
private SchemaInfo serviceSchemaInfo;
private XmlSchemaElement wrapperElement;
private NamespacePrefixAccumulator prefixAccumulator;
+ private BindingInfo xmlBindingInfo;
+ private Map<String, OperationInfo> localOperationsNameMap;
+ private Map<String, MessageInfo> localInputMessagesNameMap;
+ private Map<String, MessageInfo> localOutputMessagesNameMap;
+ private String opFunctionPropertyName;
+ private String opFunctionGlobalName;
- public ServiceJavascriptBuilder(ServiceInfo serviceInfo,
- NamespacePrefixAccumulator prefixAccumulator,
+ public ServiceJavascriptBuilder(ServiceInfo serviceInfo, NamespacePrefixAccumulator prefixAccumulator,
NameManager nameManager) {
super(serviceInfo);
code = new StringBuilder();
@@ -93,25 +103,28 @@
@Override
public void begin(InterfaceInfo intf) {
code.append("\n// Javascript for " + intf.getName() + "\n\n");
-
+
currentInterfaceClassName = nameManager.getJavascriptName(intf.getName());
operationsWithNameConflicts = new HashSet<OperationInfo>();
+ inputMessagesWithNameConflicts = new HashSet<MessageInfo>();
+ outputMessagesWithNameConflicts = new HashSet<MessageInfo>();
+ localOperationsNameMap = new HashMap<String, OperationInfo>();
+ localInputMessagesNameMap = new HashMap<String, MessageInfo>();
+ localOutputMessagesNameMap = new HashMap<String, MessageInfo>();
+
code.append("function " + currentInterfaceClassName + " () {\n");
+ utils.appendLine("this.jsutils = new CxfApacheOrgUtil();");
+ utils.appendLine("this.synchronous = false;");
+ utils.appendLine("this.url = null;");
+ utils.appendLine("this.client = null;");
+ utils.appendLine("this.response = null;");
+ // the callback functions for a pending operation are stored in these.
+ // thus, only one pending operation at a time.
+ utils.appendLine("this._onsuccess = null;");
+ utils.appendLine("this._onerror = null;");
code.append("}\n\n");
- Map<String, OperationInfo> localNameMap = new HashMap<String, OperationInfo>();
- for (OperationInfo operation : intf.getOperations()) {
- OperationInfo conflict = localNameMap.get(operation.getName().getLocalPart());
- if (conflict != null) {
- operationsWithNameConflicts.add(conflict);
- operationsWithNameConflicts.add(operation);
- }
- localNameMap.put(operation.getName().getLocalPart(), operation);
- }
- serviceSchemaInfo = serviceInfo.getSchema(serviceInfo.getTargetNamespace());
- }
- @Override
- public void begin(MessageInfo msg) {
+ serviceSchemaInfo = serviceInfo.getSchema(serviceInfo.getTargetNamespace());
}
@Override
@@ -141,26 +154,36 @@
return javascriptName;
}
}
+
+ private String getFunctionGlobalName(QName itemName, String itemType) {
+ return nameManager.getJavascriptName(itemName) + "_" + itemType;
+ }
+
+
+ private<T> String getFunctionPropertyName(Set<T> conflictMap, T object, QName fullName) {
+ boolean needsLongName = conflictMap.contains(object);
+ String functionName;
+ if (needsLongName) {
+ functionName = nameManager.getJavascriptName(fullName);
+ } else {
+ functionName = JavascriptUtils.javaScriptNameToken(fullName.getLocalPart());
+ }
+ return functionName;
+
+ }
+ // we do this at the end so we can inventory name conflicts sooner.
@Override
- public void begin(OperationInfo op) {
- if (isRPC) {
- unsupportedConstruct("RPC", op.getInterface().getName().toString());
- }
- boolean isWrapped = op.isUnwrappedCapable();
+ public void end(OperationInfo op) {
// we only process the wrapped operation, not the unwrapped alternative.
if (op.isUnwrapped()) {
return;
}
- boolean needsLongName = operationsWithNameConflicts.contains(op);
- String opFunctionName;
- String opGlobalFunctionName = nameManager.getJavascriptName(op.getName()) + "_op";
- if (needsLongName) {
- opFunctionName = opGlobalFunctionName;
- } else {
- opFunctionName = JavascriptUtils.javaScriptNameToken(op.getName().getLocalPart());
+ if (isRPC) {
+ unsupportedConstruct("RPC", op.getInterface().getName().toString());
}
+ boolean isWrapped = op.isUnwrappedCapable();
List<String> inputParameterNames = new ArrayList<String>();
MessageInfo inputMessage = op.getInput();
String wrapperClassName = null;
@@ -174,14 +197,31 @@
wrapperClassName = setupWrapperElement(op, inputParameterNames, parts);
}
- for (String param : inputParameterNames) {
- parameterList.append(param);
- parameterList.append(", ");
- }
+ buildParameterList(inputParameterNames, parameterList);
+ }
+
+ MessageInfo outputMessage = op.getOutput();
+ buildSuccessFunction(outputMessage);
+
+ buildErrorFunction(); // fault part some day.
+
+ buildOperationFunction(inputParameterNames, inputMessage, parameterList);
+
+ createInputSerializer(inputMessage, isWrapped, inputParameterNames, wrapperClassName, parts);
+
+ if (outputMessage != null) {
+ createResponseDeserializer(outputMessage);
}
+ }
- code.append("function " + opGlobalFunctionName + "(" + parameterList
- + "responseCallback, errorCallback) {\n");
+ private void buildOperationFunction(List<String> inputParameterNames,
+ MessageInfo inputMessage,
+ StringBuilder parameterList) {
+ code.append("function "
+ + opFunctionGlobalName
+ + "(successCallback, errorCallback"
+ + ((parameterList.length() > 0) ? ", " + parameterList : "") + ") {\n");
+ utils.appendLine("var xml = null;");
if (inputMessage != null) {
utils.appendLine("var args = new Array(" + inputParameterNames.size() + ");");
int px = 0;
@@ -189,49 +229,144 @@
utils.appendLine("args[" + px + "] = " + param + ";");
px++;
}
- utils.appendLine("var xml = this.serializeInputMessage(args);");
- // more to come ...
- }
+ utils.appendLine("xml = this."
+ + getFunctionPropertyName(inputMessagesWithNameConflicts,
+ inputMessage,
+ inputMessage.getName())
+ + "_serializeInput"
+ + "(args);");
+ }
+ utils.appendLine("this.client = new CxfApacheOrgClient(jsutils);");
+ // we need to pass the caller's callback functions to our callback
+ // functions.
+ utils.appendLine("this._onsuccess = successCallback;");
+ utils.appendLine("this._onerror = errorCallback;");
+ utils.appendLine("this.client.onsuccess = this."
+ + opFunctionPropertyName
+ + "_onsuccess");
+ utils.appendLine("this.client.onerror = this."
+ + opFunctionPropertyName
+ + "_error");
+
+ utils.appendLine("var requestHeaders = [];");
+
+ if (soapBindingInfo != null) {
+ String action = soapBindingInfo.getSoapAction(currentOperation);
+ utils.appendLine("requestHeaders['SOAPAction'] = '" + action + "';");
+ }
+
+ // default method by passing null. Is there some place this lives in the
+ // service model?
+ utils.appendLine("this.client.request(this.url, xml, null, this.synchronous, requestHeaders);");
+
code.append("}\n\n");
- code.append(currentInterfaceClassName + ".prototype." + opFunctionName + " = " + opGlobalFunctionName
+ code.append(currentInterfaceClassName + ".prototype."
+ + opFunctionPropertyName
+ + " = "
+ + opFunctionGlobalName
+ ";\n\n");
+ }
- createInputSerializer(op, isWrapped, inputParameterNames, wrapperClassName, parts);
+ private void buildErrorFunction() {
+ String errorFunctionPropertyName = opFunctionPropertyName + "_onerror";
+ String errorFunctionGlobalName = opFunctionGlobalName + "_onerror";
- MessageInfo outputMessage = op.getOutput();
+ code.append("function " + errorFunctionGlobalName + "() {\n");
+ utils.startIf("this._onerror");
+ // Is this a good set of parameters for the error function?
+ // Not if we want to process faults, it isn't. To be revisited.
+ utils.appendLine("this._onerror(this.client.req.status, this.client.req.statusText);");
+ utils.endBlock();
+ code.append("}\n\n");
+ code.append(currentInterfaceClassName + ".prototype."
+ + errorFunctionPropertyName
+ + " = "
+ + errorFunctionGlobalName
+ + ";\n\n");
+ }
+
+ private void buildSuccessFunction(MessageInfo outputMessage) {
+ // Here are the success and error callbacks. They have the job of
+ // calling
+ // the callbacks provided to the operation function with appropriate
+ // parameters.
+ String successFunctionGlobalName = opFunctionGlobalName + "_onsuccess";
+ String successFunctionPropertyName = opFunctionPropertyName + "_onsuccess";
+ code.append("function " + successFunctionGlobalName + "(responseXml) {\n");
+ utils.startIf("_onsuccess");
+ utils.appendLine("var responseObject = null;");
if (outputMessage != null) {
- createResponseDeserializer(op, outputMessage.getMessageParts());
+ if (soapBindingInfo != null) { // soap
+ // The following code is probably only right for basic
+ // Doc/Literal/Wrapped services.
+ // the top element should be the Envelope, then the Body, then
+ // the actual response item.
+ utils.appendLine("var element = this.jsutils.getFirstElementChild(responseXml);");
+ // Go down one more from the body to the response item.
+ utils.appendLine("element = this.jsutils.getFirstElementChild(responseXml);");
+ } else if (xmlBindingInfo != null) {
+ utils.appendLine("var element = responseXml;");
+ }
+
+ String deserializerFunctionName = outputDeserializerFunctionName(outputMessage);
+ utils.appendLine("responseObject = " + deserializerFunctionName + "(this.jsutils, element);");
}
+ utils.appendLine("this._onsuccess(responseObject);");
+ utils.endBlock();
+ code.append("}\n\n");
+ code.append(currentInterfaceClassName + ".prototype."
+ + successFunctionPropertyName
+ + " = "
+ + successFunctionGlobalName + ";\n\n");
}
-
- private void createResponseDeserializer(OperationInfo op, List<MessagePartInfo> parts) {
+
+ private void buildParameterList(List<String> inputParameterNames, StringBuilder parameterList) {
+ for (String param : inputParameterNames) {
+ parameterList.append(param);
+ parameterList.append(", ");
+ }
+ // trim last comma.
+ if (parameterList.length() > 2) {
+ parameterList.setLength(parameterList.length() - 2);
+ }
+ }
+
+ private String outputDeserializerFunctionName(MessageInfo message) {
+ return getFunctionGlobalName(message.getName(), "deserializeResponse");
+ }
+
+ private void createResponseDeserializer(MessageInfo outputMessage) {
+ List<MessagePartInfo> parts = outputMessage.getMessageParts();
if (parts.size() != 1) {
- unsupportedConstruct("MULTIPLE_OUTPUTS", op.getName().toString());
+ unsupportedConstruct("MULTIPLE_OUTPUTS", outputMessage.getName().toString());
}
List<ElementAndNames> elements = new ArrayList<ElementAndNames>();
- String functionName = nameManager.getJavascriptName(op.getName()) + "_deserializeResponse";
+ String functionName = outputDeserializerFunctionName(outputMessage);
code.append("function " + functionName + "(cxfjsutils, partElement) {\n");
getElementsForParts(elements, parts);
ElementAndNames element = elements.get(0);
XmlSchemaComplexType type = (XmlSchemaComplexType)element.getElement().getSchemaType();
assert type != null;
String typeObjectName = nameManager.getJavascriptName(type);
- utils.appendLine("var returnObject = "
- + typeObjectName + "_deserialize (cxfjsutils, partElement);\n");
+ utils
+ .appendLine("var returnObject = " + typeObjectName + "_deserialize (cxfjsutils, partElement);\n");
utils.appendLine("return returnObject;");
code.append("}\n");
}
- private void createInputSerializer(OperationInfo op, boolean isWrapped,
- List<String> inputParameterNames, String wrapperClassName,
- List<MessagePartInfo> parts) {
+ private void createInputSerializer(MessageInfo msg, boolean isWrapped, List<String> inputParameterNames,
+ String wrapperClassName, List<MessagePartInfo> parts) {
List<ElementAndNames> elements = new ArrayList<ElementAndNames>();
- String serializerFunctionName = nameManager.getJavascriptName(op.getName()) + "_serializeInput";
- code.append("function " + serializerFunctionName + "(args) {\n");
+ String serializerFunctionGlobalName = getFunctionGlobalName(msg.getName(), "serializeInput");
+ String serializerFunctionPropertyName =
+ getFunctionPropertyName(inputMessagesWithNameConflicts, msg, msg.getName());
+
+ code.append("function " + serializerFunctionGlobalName + "(args) {\n");
getElementsForParts(elements, parts);
- // if not wrapped, the param array matches up with the parts. If wrapped, the members
+ // if not wrapped, the param array matches up with the parts. If
+ // wrapped, the members
// of it have to be packed into an object.
if (isWrapped) {
@@ -249,17 +384,22 @@
utils.appendLine("var cxfutils = new CxfApacheOrgUtil();");
- SoapVersion soapVersion = soapBindingInfo.getSoapVersion();
- assert soapVersion.getVersion() == 1.1;
- utils.appendLine("var xml;");
- utils.appendLine("xml = cxfutils.beginSoap11Message(\"" + prefixAccumulator.getAttributes() + "\");");
+ if (soapBindingInfo != null) {
+ SoapVersion soapVersion = soapBindingInfo.getSoapVersion();
+ assert soapVersion.getVersion() == 1.1;
+ utils.appendLine("var xml;");
+ utils.appendLine("xml = cxfutils.beginSoap11Message(\"" + prefixAccumulator.getAttributes()
+ + "\");");
+ } else {
+ // other alternative is XML, which isn't really all here yet.
+ unsupportedConstruct("XML_BINDING", currentInterfaceClassName, xmlBindingInfo.getName());
+ }
utils.setXmlStringAccumulator("xml");
int px = 0;
for (ElementAndNames partElement : elements) {
- utils.generateCodeToSerializeElement("cxfutils",
- partElement.getElement(), "args[" + px + "]",
+ utils.generateCodeToSerializeElement("cxfutils", partElement.getElement(), "args[" + px + "]",
partElement.getXmlName(), xmlSchemaCollection,
serviceSchemaInfo.getNamespaceURI(), null);
px++;
@@ -268,9 +408,10 @@
utils.appendLine("xml = xml + cxfutils.endSoap11Message();");
utils.appendLine("return xml;");
code.append("}\n\n");
- code.append(currentInterfaceClassName + ".prototype.serializeInputMessage = "
- + serializerFunctionName
- + ";\n\n");
+ code.append(currentInterfaceClassName + ".prototype."
+ + serializerFunctionPropertyName
+ + " = "
+ + serializerFunctionGlobalName + ";\n\n");
}
private void getElementsForParts(List<ElementAndNames> elements, List<MessagePartInfo> parts) {
@@ -283,11 +424,12 @@
serviceInfo.getTargetNamespace());
}
} else {
- // dkulp may have fixed the problem that caused me to write this code.
- // aside from the fact that in the !isElement case (rpc) we have other work to do.
- LOG.severe("Missing element "
- + mpi.getElementQName().toString()
- + " in " + mpi.getName().toString());
+ // dkulp may have fixed the problem that caused me to write this
+ // code.
+ // aside from the fact that in the !isElement case (rpc) we have
+ // other work to do.
+ LOG.severe("Missing element " + mpi.getElementQName().toString() + " in "
+ + mpi.getName().toString());
// there is still an element in there, but it's not a very
// interesting element
element = new XmlSchemaElement();
@@ -334,11 +476,9 @@
}
@Override
- public void end(OperationInfo op) {
- }
-
- @Override
public void begin(ServiceInfo service) {
+
+ BindingInfo xml = null;
// assume only one soap binding.
// until further consideration.
// hypothetically, we could generate two different JavaScript classes,
@@ -354,13 +494,21 @@
soapBindingInfo = sbi;
break;
}
+ } else if (WSDLConstants.NS_BINDING_XML.equals(bindingInfo.getBindingId())) {
+ xml = bindingInfo;
}
}
- if (soapBindingInfo == null) {
- unsupportedConstruct("NO_SOAP_BINDING", service.getName());
+
+ // For now, we use soap if its available, and XML if it isn't.\
+ if (soapBindingInfo == null && xml == null) {
+ unsupportedConstruct("NO_USABLE_BINDING", service.getName());
}
- isRPC = soapBindingInfo.getStyle().equals(WSDLConstants.RPC);
+ if (soapBindingInfo != null) {
+ isRPC = soapBindingInfo.getStyle().equals(WSDLConstants.RPC);
+ } else if (xml != null) {
+ xmlBindingInfo = xml;
+ }
}
@Override
@@ -381,10 +529,49 @@
@Override
public void end(ServiceInfo service) {
+ LOG.fine(getCode());
}
private void unsupportedConstruct(String messageKey, Object... args) {
Message message = new Message(messageKey, LOG, args);
throw new UnsupportedConstruct(message);
}
+
+ @Override
+ public void begin(OperationInfo op) {
+ if (op.isUnwrapped()) {
+ return;
+ }
+ currentOperation = op;
+ OperationInfo conflict = localOperationsNameMap.get(op.getName().getLocalPart());
+ if (conflict != null) {
+ operationsWithNameConflicts.add(conflict);
+ operationsWithNameConflicts.add(op);
+ }
+ localOperationsNameMap.put(op.getName().getLocalPart(), op);
+ opFunctionPropertyName = getFunctionPropertyName(operationsWithNameConflicts, op, op.getName());
+ opFunctionGlobalName = getFunctionGlobalName(op.getName(), "op");
+ }
+
+ @Override
+ public void begin(MessageInfo msg) {
+ Map<String, MessageInfo> nameMap;
+ Set<MessageInfo> conflicts;
+ if (msg.getType() == MessageInfo.Type.INPUT) {
+ nameMap = localInputMessagesNameMap;
+ conflicts = inputMessagesWithNameConflicts;
+ } else {
+ nameMap = localOutputMessagesNameMap;
+ conflicts = outputMessagesWithNameConflicts;
+
+ }
+ MessageInfo conflict = nameMap.get(msg.getName().getLocalPart());
+ if (conflict != null) {
+ conflicts.add(conflict);
+ conflicts.add(msg);
+ }
+ nameMap.put(msg.getName().getLocalPart(), msg);
+ }
+
+
}
Modified: incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js Thu Nov 22 15:23:08 2007
@@ -168,4 +168,112 @@
}
CxfApacheOrgUtil.prototype.endSoap11Message = org_apache_cxf_end_soap11_message;
+
+/*
+ * Client object sends requests and calls back with responses.
+ */
+function CxfApacheOrgClient(utils) {
+ this.utils = utils;
+ this.soapAction = "";
+ this.messageType = "CALL";
+ // handler functions
+ this.onsuccess = null;
+ this.onerror = null;
+}
+
+// Caller must avoid stupid mistakes like 'GET' with a request body.
+// This does not support attempts to cross-script.
+// This imposes a relatively straightforward set of HTTP options.
+function org_apache_cxf_client_request(url, requestXML, method, sync, headers)
+{
+ this.url = url;
+ this.onSuccess = onSuccess;
+ this.onError = onError;
+ this.sync = sync;
+
+ this.req = null;
+
+ if (method) {
+ this.method = method;
+ } else {
+ if(!requestXML)
+ this.method = "POST";
+ else
+ this.method="GET";
+ }
+
+ try {
+ this.req = new XMLHttpRequest();
+ } catch(err) {
+ this.utils.trace("Error creating XMLHttpRequest " + err);
+ this.req = null;
+ }
+
+ if(this.req == null) {
+ if(window.ActiveXObject) {
+ this.req = new ActiveXObject("MSXML2.XMLHTTP.6.0"); // Microsoft's recommended version
+ }
+ }
+
+ if(this.req == null) {
+ this.utils.trace("Unable to create request object.");
+ throw "ORG_APACHE_CXF_NO_REQUEST_OBJECT";
+ }
+
+ this.req.open(this.method, this.url, !this.sync);
+
+ this.req.setRequestHeader("Content-Type", "application/xml");
+
+ if (headers) { // must be array indexed by header field.
+ for (var h in headers) {
+ this.req.setRequestHeader(h,headers[h]);
+ }
+ }
+
+ this.req.setRequestHeader("SOAPAction", this.soapAction);
+ this.req.setRequestHeader("MessageType", this.messageType);
+
+ var requester = this; /* setup a closure */
+
+ this.req.onreadystatechange = function() {
+ requester.onReadyState();
+ }
+
+ // NOTE: we do not call the onerror callback for a synchronous error
+ // at request time. We let the request object throw as it will.
+ // onError will only be called for asynchronous errors.
+ this.req.send(requestXML);
+}
+
+CxfApacheOrgClient.prototype.request = org_apache_cxf_client_request;
+
+function org_apache_cxf_client_onReadyState() {
+ var req = this.req;
+ var ready = req.readyState;
+
+ this.utils.trace("onreadystatechange " + ready);
+
+ if (ready == req.DONE) {
+ var httpStatus=req.status;
+ this.utils.trace("onreadystatechange DONE " + httpStatus);
+
+ if (httpStatus==200 || httpStatus==0) {
+ if(this.onSuccess != null) {
+ // the onSuccess function is generated, and picks apart the response.
+ this.onSuccess(req.responseXML);
+ }
+ } else {
+ this.utils.trace("onreadystatechange DONE ERROR " +
+ req.getAllResponseHeaders()
+ + " "
+ + req.statusText
+ + " "
+ + req.responseText);
+ if(this.onError != null)
+ this.onError(this);
+ }
+ }
+}
+
+CxfApacheOrgClient.prototype.onReadyState = org_apache_cxf_client_onReadyState;
Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java?rev=597511&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java Thu Nov 22 15:23:08 2007
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
+import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.test.AbstractCXFSpringTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.mozilla.javascript.Context;
+import org.springframework.context.support.GenericApplicationContext;
+
+@org.junit.Ignore
+public class DocLitWrappedClientTest extends AbstractCXFSpringTest {
+
+ // shadow declaration from base class.
+ private JavascriptTestUtilities testUtilities;
+ private JaxWsProxyFactoryBean clientProxyFactory;
+
+ public DocLitWrappedClientTest() throws Exception {
+ testUtilities = new JavascriptTestUtilities(getClass());
+ testUtilities.addDefaultNamespaces();
+ }
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[] {"classpath:DocLitWrappedClientTestBeans.xml"};
+ }
+
+ @Before
+ public void setupRhino() throws Exception {
+ testUtilities.setBus(getBean(Bus.class, "cxf"));
+ testUtilities.initializeRhino();
+ testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js");
+ clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, "dlw-proxy-factory");
+ Client client = clientProxyFactory.getClientFactoryBean().create();
+ List<ServiceInfo> serviceInfos = client.getEndpoint().getService().getServiceInfos();
+ // there can only be one.
+ assertEquals(1, serviceInfos.size());
+ ServiceInfo serviceInfo = serviceInfos.get(0);
+ testUtilities.loadJavascriptForService(serviceInfo);
+ testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/DocLitWrappedTests.js");
+ }
+
+ // just one test function to avoid muddles with engine startup/shutdown
+ @Test
+ public void runTests() throws Exception {
+ testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+ public Void run(Context context) {
+ EndpointImpl endpoint = getBean(EndpointImpl.class, "dlw-service-endpoint");
+ Notifier notifier =
+ testUtilities.rhinoCallConvert("test1", Notifier.class,
+ testUtilities.javaToJS(endpoint.getAddress()),
+ testUtilities.javaToJS(Double.valueOf(7.0)),
+ testUtilities.javaToJS(Float.valueOf((float)11.0)),
+ testUtilities.javaToJS(Integer.valueOf(42)),
+ testUtilities.javaToJS(Long.valueOf(240000)),
+ "This is the cereal shot from guns");
+ boolean notified = notifier.waitForJavascript(10);
+ assertTrue(notified);
+ Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
+ assertNull(errorStatus);
+ String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
+ assertNull(errorText);
+
+ Object responseObject = testUtilities.rhinoEvaluate("globalResponseObject");
+ assertNotNull(responseObject);
+ return null; // well, null AND void.
+ }
+ });
+ }
+
+ public String getStaticResourceURL() throws Exception {
+ File staticFile = new File(this.getClass().getResource("test.html").toURI());
+ staticFile = staticFile.getParentFile();
+ staticFile = staticFile.getAbsoluteFile();
+ URL furl = staticFile.toURL();
+ return furl.toString();
+ }
+
+ @Override
+ protected void additionalSpringConfiguration(GenericApplicationContext context) throws Exception {
+ }
+}
Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java?rev=597511&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java Thu Nov 22 15:23:08 2007
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.test.AbstractCXFSpringTest;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ * This will eventually be a test of XML binding.
+ */
+@Ignore
+public class GreeterClientTest extends AbstractCXFSpringTest {
+
+ // shadow declaration from base class.
+ private JavascriptTestUtilities testUtilities;
+ private JaxWsProxyFactoryBean clientProxyFactory;
+
+ public GreeterClientTest() throws Exception {
+ testUtilities = new JavascriptTestUtilities(getClass());
+ testUtilities.addDefaultNamespaces();
+ }
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[] {"classpath:GreeterClientTestBeans.xml"};
+ }
+
+
+ @Before
+ public
+ void setupRhino() throws Exception {
+ testUtilities.setBus(getBean(Bus.class, "cxf"));
+ testUtilities.initializeRhino();
+ // move the following into the utility class?
+ JsXMLHttpRequest.register(testUtilities.getRhinoScope());
+ testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js");
+ clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, "greeter-proxy-factory");
+ Client client = clientProxyFactory.getClientFactoryBean().create();
+ List<ServiceInfo> serviceInfos = client.getEndpoint().getService().getServiceInfos();
+ // there can only be one.
+ assertEquals(1, serviceInfos.size());
+ ServiceInfo serviceInfo = serviceInfos.get(0);
+ testUtilities.loadJavascriptForService(serviceInfo);
+ //well, we should be able to load Javascript that talks to the service.
+
+ }
+
+
+ // just one test function to avoid muddles with engine startup/shutdown
+ @Test
+ public void runTests() throws Exception {
+
+ }
+
+ public String getStaticResourceURL() throws Exception {
+ File staticFile = new File(this.getClass().getResource("test.html").toURI());
+ staticFile = staticFile.getParentFile();
+ staticFile = staticFile.getAbsoluteFile();
+ URL furl = staticFile.toURL();
+ return furl.toString();
+ }
+
+ @Override
+ protected void additionalSpringConfiguration(GenericApplicationContext context) throws Exception {
+ }
+}
Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java Thu Nov 22 15:23:08 2007
@@ -22,12 +22,18 @@
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
import java.util.logging.Logger;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.javascript.service.ServiceJavascriptBuilder;
+import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.test.TestUtilities;
import org.junit.Assert;
import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.RhinoException;
@@ -35,35 +41,39 @@
import org.mozilla.javascript.tools.debugger.Main;
/**
- * Test utilities class with some Javascript capability included.
+ * Test utilities class with some Javascript capability included.
*/
public class JavascriptTestUtilities extends TestUtilities {
-
+
private static final Logger LOG = LogUtils.getL7dLogger(JavascriptTestUtilities.class);
+ private ContextFactory rhinoContextFactory;
private ScriptableObject rhinoScope;
private Context rhinoContext;
-
+
public static class JavaScriptAssertionFailed extends RuntimeException {
public JavaScriptAssertionFailed(String what) {
super(what);
}
}
-
+
public static class JsAssert extends ScriptableObject {
- public JsAssert() { }
+ public JsAssert() {
+ }
+
public void jsConstructor(String exp) {
LOG.severe("Assertion failed: " + exp);
throw new JavaScriptAssertionFailed(exp);
}
+
@Override
public String getClassName() {
return "Assert";
}
}
-
+
public static class Trace extends ScriptableObject {
public Trace() {
@@ -73,18 +83,18 @@
public String getClassName() {
return "org_apache_cxf_trace";
}
-
- //CHECKSTYLE:OFF
+
+ // CHECKSTYLE:OFF
public static void jsStaticFunction_trace(String message) {
LOG.fine(message);
}
- //CHECKSTYLE:ON
+ // CHECKSTYLE:ON
}
-
+
public static class Notifier extends ScriptableObject {
-
+
private boolean notified;
-
+
public Notifier() {
}
@@ -92,39 +102,41 @@
public String getClassName() {
return "org_apache_cxf_notifier";
}
-
+
public synchronized boolean waitForJavascript(long timeout) {
while (!notified) {
try {
wait(timeout);
- return notified;
+ return notified;
} catch (InterruptedException e) {
// do nothing.
}
}
return true; // only here if true on entry.
}
-
- //CHECKSTYLE:OFF
+
+ // CHECKSTYLE:OFF
public synchronized void jsFunction_notify() {
notified = true;
notifyAll();
}
- //CHECKSTYLE:ON
+ // CHECKSTYLE:ON
}
public JavascriptTestUtilities(Class<?> classpathReference) {
super(classpathReference);
}
-
+
public void initializeRhino() {
-
+
+ rhinoContextFactory = new ContextFactory();
if (System.getProperty("cxf.jsdebug") != null) {
- Main.mainEmbedded("Debug embedded JavaScript.");
+ Main.mainEmbedded(rhinoContextFactory, rhinoScope, "Debug embedded JavaScript.");
}
- rhinoContext = Context.enter();
+ rhinoContext = rhinoContextFactory.enter();
rhinoScope = rhinoContext.initStandardObjects();
+
try {
ScriptableObject.defineClass(rhinoScope, JsAssert.class);
ScriptableObject.defineClass(rhinoScope, Trace.class);
@@ -135,48 +147,85 @@
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
+ } finally {
+ rhinoContextFactory.exit();
}
JsSimpleDomNode.register(rhinoScope);
JsSimpleDomParser.register(rhinoScope);
+ JsXMLHttpRequest.register(rhinoScope);
}
-
+
public void readResourceIntoRhino(String resourceClasspath) throws IOException {
Reader js = getResourceAsReader(resourceClasspath);
- rhinoContext.evaluateReader(rhinoScope, js, resourceClasspath, 1, null);
+ rhinoContextFactory.enter(rhinoContext);
+ try {
+ rhinoContext.evaluateReader(rhinoScope, js, resourceClasspath, 1, null);
+ } finally {
+ rhinoContextFactory.exit();
+ }
}
-
+
public void readStringIntoRhino(String js, String sourceName) {
LOG.fine(sourceName + ":\n" + js);
- rhinoContext.evaluateString(rhinoScope, js, sourceName, 1, null);
+ rhinoContextFactory.enter(rhinoContext);
+ try {
+ rhinoContext.evaluateString(rhinoScope, js, sourceName, 1, null);
+ } finally {
+ rhinoContextFactory.exit();
+ }
}
-
+
public ScriptableObject getRhinoScope() {
return rhinoScope;
}
- public Context getRhinoContext() {
- return rhinoContext;
+ public ContextFactory getRhinoContextFactory() {
+ return rhinoContextFactory;
}
-
+
+ public static interface JSRunnable<T> {
+ T run(Context context);
+ }
+
+ public <T> T runInsideContext(Class<T> clazz, JSRunnable<?> runnable) {
+ rhinoContextFactory.enter(rhinoContext);
+ try {
+ return clazz.cast(runnable.run(rhinoContext));
+ } finally {
+ rhinoContextFactory.exit();
+ }
+ }
+
public Object javaToJS(Object value) {
return Context.javaToJS(value, rhinoScope);
}
-
- public Object rhinoNewObject(String constructorName) {
- return rhinoContext.newObject(rhinoScope, constructorName);
+
+ public Object rhinoNewObject(final String constructorName) {
+ return runInsideContext(Object.class, new JSRunnable<Object>() {
+ public Object run(Context context) {
+ return context.newObject(rhinoScope, constructorName);
+ }
+ });
}
-
+
/**
* Evaluate a javascript expression, returning the raw Rhino object.
+ *
* @param jsExpression the javascript expression.
* @return return value.
*/
- public Object rhinoEvaluate(String jsExpression) {
- return rhinoContext.evaluateString(rhinoScope, jsExpression, "<testcase>", 1, null);
+ public Object rhinoEvaluate(final String jsExpression) {
+ return runInsideContext(Object.class, new JSRunnable<Object>() {
+ public Object run(Context context) {
+ return rhinoContext.evaluateString(rhinoScope, jsExpression, "<testcase>", 1, null);
+ }
+ });
}
-
+
/**
- * Evaluate a Javascript expression, converting the return value to a convenient Java type.
+ * Evaluate a Javascript expression, converting the return value to a
+ * convenient Java type.
+ *
* @param <T> The desired type
* @param jsExpression the javascript expression.
* @param clazz the Class object for the desired type.
@@ -185,45 +234,69 @@
public <T> T rhinoEvaluateConvert(String jsExpression, Class<T> clazz) {
return clazz.cast(Context.jsToJava(rhinoEvaluate(jsExpression), clazz));
}
-
+
/**
- * Call a JavaScript function. Optionally, require it to throw an exception equal to
- * a supplied object. If the exception is called for, this function will either return null
- * or Assert.
+ * Call a JavaScript function. Optionally, require it to throw an exception
+ * equal to a supplied object. If the exception is called for, this function
+ * will either return null or Assert.
+ *
* @param expectingException Exception desired, or null.
* @param functionName Function to call.
- * @param args args for the function. Be sure to Javascript-ify them as appropriate.
+ * @param args args for the function. Be sure to Javascript-ify them as
+ * appropriate.
* @return
*/
- public Object rhinoCallExpectingException(Object expectingException,
- String functionName,
- Object ... args) {
- Object fObj = rhinoScope.get(functionName, rhinoScope);
- if (!(fObj instanceof Function)) {
- throw new RuntimeException("Missing test function " + functionName);
- }
- Function function = (Function)fObj;
- try {
- return function.call(rhinoContext, rhinoScope, rhinoScope, args);
- } catch (RhinoException angryRhino) {
- if (expectingException != null && angryRhino instanceof JavaScriptException) {
- JavaScriptException jse = (JavaScriptException)angryRhino;
- Assert.assertEquals(jse.getValue(), expectingException);
+ public Object rhinoCallExpectingException(final Object expectingException, final String functionName,
+ final Object... args) {
+ return runInsideContext(Object.class, new JSRunnable<Object>() {
+ public Object run(Context context) {
+ Object fObj = rhinoScope.get(functionName, rhinoScope);
+ if (!(fObj instanceof Function)) {
+ throw new RuntimeException("Missing test function " + functionName);
+ }
+ Function function = (Function)fObj;
+ try {
+ return function.call(rhinoContext, rhinoScope, rhinoScope, args);
+ } catch (RhinoException angryRhino) {
+ if (expectingException != null && angryRhino instanceof JavaScriptException) {
+ JavaScriptException jse = (JavaScriptException)angryRhino;
+ Assert.assertEquals(jse.getValue(), expectingException);
+ return null;
+ }
+ String trace = angryRhino.getScriptStackTrace();
+ Assert.fail("JavaScript error: " + angryRhino.toString() + " " + trace);
+ } catch (JavaScriptAssertionFailed assertion) {
+ Assert.fail(assertion.getMessage());
+ }
return null;
}
- String trace = angryRhino.getScriptStackTrace();
- Assert.fail("JavaScript error: " + angryRhino.toString() + " " + trace);
- } catch (JavaScriptAssertionFailed assertion) {
- Assert.fail(assertion.getMessage());
- }
- return null;
+ });
}
-
- public Object rhinoCall(String functionName, Object ... args) {
+
+ public Object rhinoCall(String functionName, Object... args) {
return rhinoCallExpectingException(null, functionName, args);
}
-
- public <T> T rhinoCallConvert(String functionName, Class<T> clazz, Object ... args) {
+
+ public <T> T rhinoCallConvert(String functionName, Class<T> clazz, Object... args) {
return clazz.cast(Context.jsToJava(rhinoCall(functionName, args), clazz));
+ }
+
+ public void loadJavascriptForService(ServiceInfo serviceInfo) {
+ Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
+ BasicNameManager nameManager = new BasicNameManager(serviceInfo);
+ NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
+ .getXmlSchemaCollection());
+ for (SchemaInfo schema : schemata) {
+ SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo
+ .getXmlSchemaCollection(), prefixManager, nameManager, schema);
+ String allThatJavascript = builder.generateCodeForSchema(schema);
+ readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
+ }
+
+ ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, prefixManager,
+ nameManager);
+ serviceBuilder.walk();
+ String serviceJavascript = serviceBuilder.getCode();
+ readStringIntoRhino(serviceJavascript, serviceInfo.getName() + ".js");
}
}
Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java Thu Nov 22 15:23:08 2007
@@ -72,10 +72,8 @@
void setupRhino() throws Exception {
testUtilities.setBus(getBean(Bus.class, "cxf"));
testUtilities.initializeRhino();
- JsXMLHttpRequest.register(testUtilities.getRhinoScope());
testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/XMLHttpRequestTests.js");
}
-
// just one test function to avoid muddles with engine startup/shutdown
@Test
Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java Thu Nov 22 15:23:08 2007
@@ -267,7 +267,7 @@
// 4 preprocess data. Handled on the way in here, we're called with
// UTF-8 bytes.
if (xml && !requestHeaders.containsKey("Content-Type")) {
- requestHeaders.put("ContentType", "application/xml");
+ requestHeaders.put("Content-Type", "application/xml;charset=utf-8");
}
// 5 talk to the server.
@@ -645,36 +645,4 @@
return doGetStatusText();
}
}
-
-// fodder for local transport.
-// return invoke("local://" + service, LocalTransportFactory.TRANSPORT_ID, message);
-//EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-//ei.setAddress(address);
-//
-//ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
-//ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport);
-//Conduit conduit = conduitInit.getConduit(ei);
-//
-//TestMessageObserver obs = new TestMessageObserver();
-//conduit.setMessageObserver(obs);
-//
-//Message m = new MessageImpl();
-//conduit.prepare(m);
-//
-//OutputStream os = m.getContent(OutputStream.class);
-//InputStream is = getResourceAsStream(message);
-//if (is == null) {
-// throw new RuntimeException("Could not find resource " + message);
-//}
-//
-//IOUtils.copy(is, os);
-//
-//// TODO: shouldn't have to do this. IO caching needs cleaning
-//// up or possibly removal...
-//os.flush();
-//is.close();
-//os.close();
-//
-//byte[] bs = obs.getResponseStream().toByteArray();
-//
-//return bs;
\ No newline at end of file
+
\ No newline at end of file
Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java?rev=597511&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java Thu Nov 22 15:23:08 2007
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript.fortest;
+
+import javax.jws.WebService;
+
+/**
+ *
+ */
+@WebService(endpointInterface = "org.apache.cxf.javascript.fortest.SimpleDocLitWrapped")
+public class SimpleDocLitWrappedImpl implements SimpleDocLitWrapped {
+
+ private String lastString;
+ private int lastInt;
+ private long lastLong;
+ private float lastFloat;
+ private double lastDouble;
+ private TestBean1 lastBean1;
+ private TestBean1[] lastBean1Array;
+
+ /** {@inheritDoc}*/
+ public int basicTypeFunctionReturnInt(String s, int i, long l, float f, double d) {
+ lastString = s;
+ lastInt = i;
+ lastLong = l;
+ lastFloat = f;
+ lastDouble = d;
+ return 42;
+ }
+
+ /** {@inheritDoc}*/
+ public String basicTypeFunctionReturnString(String s, int i, long l, float f, double d) {
+ lastString = s;
+ lastInt = i;
+ lastLong = l;
+ lastFloat = f;
+ lastDouble = d;
+ return "eels";
+ }
+
+ /** {@inheritDoc}*/
+ public void beanFunction(TestBean1 bean, TestBean1[] beans) {
+ lastBean1 = bean;
+ lastBean1Array = beans;
+ }
+
+ /** {@inheritDoc}*/
+ public TestBean1 functionReturnTestBean1() {
+ TestBean1 bean1 = new TestBean1();
+ bean1.intItem = 42;
+ return bean1;
+ }
+
+ public String getLastString() {
+ return lastString;
+ }
+
+ public int getLastInt() {
+ return lastInt;
+ }
+
+ public long getLastLong() {
+ return lastLong;
+ }
+
+ public float getLastFloat() {
+ return lastFloat;
+ }
+
+ public double getLastDouble() {
+ return lastDouble;
+ }
+
+ public TestBean1 getLastBean1() {
+ return lastBean1;
+ }
+
+ public TestBean1[] getLastBean1Array() {
+ return lastBean1Array;
+ }
+}
Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java?rev=597511&r1=597510&r2=597511&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java Thu Nov 22 15:23:08 2007
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.StringReader;
-import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
@@ -42,27 +41,25 @@
import org.apache.cxf.databinding.DataReader;
import org.apache.cxf.databinding.DataWriter;
import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.javascript.BasicNameManager;
import org.apache.cxf.javascript.JavascriptTestUtilities;
+import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
import org.apache.cxf.javascript.JsSimpleDomNode;
-import org.apache.cxf.javascript.NameManager;
-import org.apache.cxf.javascript.NamespacePrefixAccumulator;
import org.apache.cxf.javascript.fortest.BasicTypeFunctionReturnStringWrapper;
import org.apache.cxf.javascript.fortest.StringWrapper;
-import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.service.model.MessageInfo;
import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.test.AbstractCXFSpringTest;
import org.junit.Test;
+import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.springframework.context.support.GenericApplicationContext;
-//@org.junit.Ignore
public class DocLitWrappedTest extends AbstractCXFSpringTest {
+ private static final String BASIC_TYPE_FUNCTION_RETURN_STRING_RESPONSE_DESERIALIZE_RESPONSE =
+ "org_apache_cxf_javascript_fortest_basicTypeFunctionReturnStringResponse_deserializeResponse";
private static final String WHAT_ROUGH_BEAST_ITS_HOUR_COME_AT_LAST =
"What rough beast, its hour come at last, ...";
private static final Logger LOG = LogUtils.getL7dLogger(DocLitWrappedTest.class);
@@ -72,11 +69,8 @@
private JavascriptTestUtilities testUtilities;
private Client client;
private List<ServiceInfo> serviceInfos;
- private Collection<SchemaInfo> schemata;
- private NameManager nameManager;
private JaxWsProxyFactoryBean clientProxyFactory;
private XMLInputFactory xmlInputFactory;
- private NamespacePrefixAccumulator prefixManager;
private DocumentBuilder documentBuilder;
public DocLitWrappedTest() throws Exception {
@@ -101,14 +95,18 @@
DataBinding dataBinding = clientProxyFactory.getServiceFactory().getDataBinding();
assertNotNull(dataBinding);
// the serialize function takes an array of the five parameters.
- Object[] params = new Object[5];
+ final Object[] params = new Object[5];
params[0] = testUtilities.javaToJS(new Float("3.14159"));
params[1] = testUtilities.javaToJS(new Double("7.90834"));
params[2] = testUtilities.javaToJS(new Integer(42));
params[3] = testUtilities.javaToJS(new Long(420000));
params[4] = testUtilities.javaToJS(new String("Hello<Dolly&sheep"));
- Scriptable jsParamArray =
- testUtilities.getRhinoContext().newArray(testUtilities.getRhinoScope(), params);
+ Scriptable jsParamArray =
+ testUtilities.runInsideContext(Scriptable.class, new JSRunnable<Scriptable>() {
+ public Scriptable run(Context context) {
+ return context.newArray(testUtilities.getRhinoScope(), params);
+ }
+ });
Object xmlString = null;
xmlString = testUtilities.rhinoCall(BASIC_TYPE_FUNCTION_RETURN_STRING_SERIALIZER_NAME,
jsParamArray);
@@ -159,11 +157,11 @@
writer.write(responseObject, part, document);
Element messageElement = document.getDocumentElement();
Object jsUtils = testUtilities.rhinoNewObject("CxfApacheOrgUtil");
- Object jsResult = testUtilities.rhinoCall("org_apache_cxf_javascript_fortest_"
- + "basicTypeFunctionReturnString_deserializeResponse",
- jsUtils,
- JsSimpleDomNode.wrapNode(testUtilities.getRhinoScope(),
- messageElement));
+ Object jsResult =
+ testUtilities.rhinoCall(BASIC_TYPE_FUNCTION_RETURN_STRING_RESPONSE_DESERIALIZE_RESPONSE,
+ jsUtils,
+ JsSimpleDomNode.wrapNode(testUtilities.getRhinoScope(),
+ messageElement));
assertNotNull(jsResult);
ScriptableObject jsResultObject = (ScriptableObject)jsResult;
Object returnValue = ScriptableObject.callMethod(jsResultObject,
@@ -184,27 +182,7 @@
// there can only be one.
assertEquals(1, serviceInfos.size());
ServiceInfo serviceInfo = serviceInfos.get(0);
- schemata = serviceInfo.getSchemas();
- nameManager = new BasicNameManager(serviceInfo);
- prefixManager = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
- for (SchemaInfo schema : schemata) {
- SchemaJavascriptBuilder builder =
- new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(),
- prefixManager, nameManager, schema);
- String allThatJavascript = builder.generateCodeForSchema(schema);
- assertNotNull(allThatJavascript);
- LOG.fine(schema.toString());
- LOG.fine(allThatJavascript);
- testUtilities.readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
- }
-
- ServiceJavascriptBuilder serviceBuilder =
- new ServiceJavascriptBuilder(serviceInfo, prefixManager, nameManager);
- serviceBuilder.walk();
- String serviceJavascript = serviceBuilder.getCode();
- LOG.fine(serviceInfo.toString());
- LOG.fine(serviceJavascript);
- testUtilities.readStringIntoRhino(serviceJavascript, serviceInfo.getName() + ".js");
+ testUtilities.loadJavascriptForService(serviceInfo);
}
@Override