cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r603801 - in /incubator/cxf/trunk/rt/javascript/src/test: java/org/apache/cxf/javascript/ resources/
Date Thu, 13 Dec 2007 02:12:03 GMT
Author: bimargulies
Date: Wed Dec 12 18:11:59 2007
New Revision: 603801

URL: http://svn.apache.org/viewvc?rev=603801&view=rev
Log:
Improve modularity of tests, begin to create test for funny case
of zero-argument wrapped method.

Added:
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DemoServerTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
    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/RPCClientTest.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DemoServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DemoServerTest.java?rev=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DemoServerTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DemoServerTest.java
Wed Dec 12 18:11:59 2007
@@ -62,7 +62,12 @@
     
     @AfterClass
     public static void afterClass() {
-        System.setProperty("cxf.config.file", oldConfigProperty);
+        if (oldConfigProperty == null) {
+            System.setProperty("cxf.config.file", "");
+            
+        } else {
+            System.setProperty("cxf.config.file", oldConfigProperty);
+        }
     }
 
     @Before
@@ -106,6 +111,6 @@
         URL endpointURL = new URL("http://localhost:9000/SoapContext/SoapPort?js");
         String js = getStringFromURL(endpointURL);
         // faultDetail will only be here if we got a nontrivial schema.
-        assertTrue(js.contains("faultDetail"));
+        assertTrue(js.contains("function apache_org_hello_world_soap_http_in"));
     }
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
Wed Dec 12 18:11:59 2007
@@ -19,22 +19,14 @@
 
 package org.apache.cxf.javascript;
 
-import java.util.List;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.SimpleDocLitBareImpl;
 import org.apache.cxf.javascript.fortest.TestBean1;
 import org.apache.cxf.javascript.fortest.TestBean2;
-import org.apache.cxf.jaxws.EndpointImpl;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.message.Message;
-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;
@@ -46,43 +38,16 @@
  * but a complex type for an array of the element.
  */
 
-public class DocLitBareClientTest extends AbstractCXFSpringTest {
+public class DocLitBareClientTest extends JavascriptRhinoTest {
 
     private static final Logger LOG = LogUtils.getL7dLogger(DocLitBareClientTest.class);
 
-    // shadow declaration from base class.
-    private JavascriptTestUtilities testUtilities;
-    private JaxWsProxyFactoryBean clientProxyFactory;
-    private EndpointImpl endpoint;
-    private SimpleDocLitBareImpl implementor;
-
-    private Client client;
-    private ServiceInfo serviceInfo;
+    SimpleDocLitBareImpl implementor;
 
     public DocLitBareClientTest() throws Exception {
-        testUtilities = new JavascriptTestUtilities(getClass());
-        testUtilities.addDefaultNamespaces();
+        super();
     }
 
-    @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, "dlb-proxy-factory");
-        client = clientProxyFactory.getClientFactoryBean().create();
-        List<ServiceInfo> serviceInfos = client.getEndpoint().getService().getServiceInfos();
-        // there can only be one.
-        assertEquals(1, serviceInfos.size());
-        serviceInfo = serviceInfos.get(0);
-        testUtilities.loadJavascriptForService(serviceInfo);
-        testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/DocLitBareTests.js");
-        endpoint = getBean(EndpointImpl.class, "dlb-service-endpoint");
-        endpoint.getService().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
-        implementor = (SimpleDocLitBareImpl)endpoint.getImplementor();
-        implementor.resetLastValues();
-    }
-    
     @Override
     protected void additionalSpringConfiguration(GenericApplicationContext context) throws
Exception {
     }
@@ -90,6 +55,16 @@
     @Override
     protected String[] getConfigLocations() {
         return new String[] {"classpath:DocLitBareClientTestBeans.xml"};
+    }
+    
+    @Before
+    public void before() throws Exception {
+        setupRhino("dlb-proxy-factory", 
+                   "dlb-service-endpoint", 
+                   "/org/apache/cxf/javascript/DocLitBareTests.js",
+                   true);
+        implementor = (SimpleDocLitBareImpl)endpoint.getImplementor();
+        implementor.resetLastValues();
     }
 
     private Void beanFunctionCaller(Context context) {

Modified: 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=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
Wed Dec 12 18:11:59 2007
@@ -21,39 +21,26 @@
 
 import java.io.File;
 import java.net.URL;
-import java.util.List;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.SimpleDocLitWrappedImpl;
 import org.apache.cxf.javascript.fortest.TestBean1;
 import org.apache.cxf.javascript.fortest.TestBean2;
-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.mozilla.javascript.Scriptable;
 import org.springframework.context.support.GenericApplicationContext;
 
-public class DocLitWrappedClientTest extends AbstractCXFSpringTest {
+public class DocLitWrappedClientTest extends JavascriptRhinoTest {
 
     private static final Logger LOG = LogUtils.getL7dLogger(DocLitWrappedClientTest.class);
 
-    // shadow declaration from base class.
-    private JavascriptTestUtilities testUtilities;
-    private JaxWsProxyFactoryBean clientProxyFactory;
-    private EndpointImpl endpoint;
-
     public DocLitWrappedClientTest() throws Exception {
-        testUtilities = new JavascriptTestUtilities(getClass());
-        testUtilities.addDefaultNamespaces();
+        super();
     }
 
     public String getStaticResourceURL() throws Exception {
@@ -65,19 +52,11 @@
     }
 
     @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");
-        endpoint = getBean(EndpointImpl.class, "dlw-service-endpoint");
+    public void before() throws Exception {
+        setupRhino("dlw-proxy-factory", 
+                   "dlw-service-endpoint", 
+                   "/org/apache/cxf/javascript/DocLitWrappedTests.js", 
+                   false);
     }
     
     @Override

Modified: 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=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
Wed Dec 12 18:11:59 2007
@@ -21,31 +21,17 @@
 
 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.
+ *  Test the same schema used in the samples.
  */
-@Ignore
-public class GreeterClientTest extends AbstractCXFSpringTest {
+public class GreeterClientTest extends JavascriptRhinoTest {
 
-    // shadow declaration from base class.
-    private JavascriptTestUtilities testUtilities;
-    private JaxWsProxyFactoryBean clientProxyFactory;
-    
     public GreeterClientTest() throws Exception {
-        testUtilities = new JavascriptTestUtilities(getClass());
-        testUtilities.addDefaultNamespaces();
+        super();
     }
     
     @Override
@@ -56,29 +42,17 @@
     
     @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.
-
+    void before() throws Exception {
+        setupRhino("greeter-proxy-factory", "greeter-service-endpoint",  
+                   "/org/apache/cxf/javascript/GreeterTests.js",
+                   true);
     }
     
-    
-    // just one test function to avoid muddles with engine startup/shutdown
     @Test
-    public void runTests() throws Exception {
+    public void testCallSayHi() throws Exception {
         
     }
+    
     
     public String getStaticResourceURL() throws Exception {
         File staticFile = new File(this.getClass().getResource("test.html").toURI());

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java?rev=603801&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
(added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
Wed Dec 12 18:11:59 2007
@@ -0,0 +1,68 @@
+/**
+ * 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.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.test.AbstractCXFSpringTest;
+
+public abstract class JavascriptRhinoTest extends AbstractCXFSpringTest {
+    
+    protected JavascriptTestUtilities testUtilities;
+    protected JaxWsProxyFactoryBean clientProxyFactory;
+    protected EndpointImpl endpoint;
+    protected Client client;
+    protected ServiceInfo serviceInfo;
+
+    
+    public JavascriptRhinoTest() throws Exception {
+        super();
+        testUtilities = new JavascriptTestUtilities(getClass());
+        testUtilities.addDefaultNamespaces();
+    }
+
+    public void setupRhino(String proxyFactoryBean, 
+                           String serviceEndpointBean, 
+                           String testsJavascript,
+                           boolean validation) throws Exception {
+        testUtilities.setBus(getBean(Bus.class, "cxf"));
+        testUtilities.initializeRhino();
+        testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js");
+        clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, proxyFactoryBean);
+        client = clientProxyFactory.getClientFactoryBean().create();
+        List<ServiceInfo> serviceInfos = client.getEndpoint().getService().getServiceInfos();
+        // there can only be one.
+        assertEquals(1, serviceInfos.size());
+        serviceInfo = serviceInfos.get(0);
+        testUtilities.loadJavascriptForService(serviceInfo);
+        testUtilities.readResourceIntoRhino(testsJavascript);
+        endpoint = getBean(EndpointImpl.class, serviceEndpointBean);
+        if (validation) {
+            endpoint.getService().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
+        }
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java?rev=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
Wed Dec 12 18:11:59 2007
@@ -19,21 +19,14 @@
 
 package org.apache.cxf.javascript;
 
-import java.util.List;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.SimpleRPCImpl;
 import org.apache.cxf.javascript.fortest.TestBean1;
 import org.apache.cxf.javascript.fortest.TestBean2;
-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;
@@ -45,41 +38,20 @@
  * but a complex type for an array of the element.
  */
 
-public class RPCClientTest extends AbstractCXFSpringTest {
+public class RPCClientTest extends JavascriptRhinoTest {
 
     private static final Logger LOG = LogUtils.getL7dLogger(RPCClientTest.class);
 
-    // shadow declaration from base class.
-    private JavascriptTestUtilities testUtilities;
-    private JaxWsProxyFactoryBean clientProxyFactory;
-    private EndpointImpl endpoint;
     private SimpleRPCImpl implementor;
 
-    private Client client;
-    private ServiceInfo serviceInfo;
-
     public RPCClientTest() throws Exception {
-        testUtilities = new JavascriptTestUtilities(getClass());
-        testUtilities.addDefaultNamespaces();
+        super();
     }
 
     @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, "rpc-proxy-factory");
-        client = clientProxyFactory.getClientFactoryBean().create();
-        List<ServiceInfo> serviceInfos = client.getEndpoint().getService().getServiceInfos();
-        // there can only be one.
-        assertEquals(1, serviceInfos.size());
-        serviceInfo = serviceInfos.get(0);
-        testUtilities.loadJavascriptForService(serviceInfo);
-        testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/RPCTests.js");
-        endpoint = getBean(EndpointImpl.class, "rpc-service-endpoint");
-        // schema validation doesn't work in RPC. CXF-1277.
-        //endpoint.getService().put(org.apache.cxf.message.Message.Message.SCHEMA_VALIDATION_ENABLED,
-        //                          Boolean.TRUE);
+    public void before() throws Exception {
+        setupRhino("rpc-proxy-factory", "rpc-service-endpoint", 
+                   "/org/apache/cxf/javascript/RPCTests.js", false); 
         implementor = (SimpleRPCImpl)endpoint.getImplementor();
         implementor.resetLastValues();
     }

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml?rev=603801&r1=603800&r2=603801&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/GreeterClientTestBeans.xml Wed Dec
12 18:11:59 2007
@@ -33,12 +33,12 @@
   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
               
  <jaxws:endpoint id="greeter-service-endpoint" 
-    implementor="org.apache.hello_world_xml_http.wrapped.GreeterImpl" 
+    implementor="org.apache.cxf.javascript.hwdemo.GreeterImpl" 
     address="http://localhost:8808/Greeter" >
  </jaxws:endpoint>
  
  <bean id="greeter-proxy-factory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean" >
-    <property name="serviceClass" value="org.apache.hello_world_xml_http.wrapped.GreeterImpl"/>
+    <property name="serviceClass" value="org.apache.cxf.javascript.hwdemo.GreeterImpl"/>
     <property name="address" value="http://localhost:8808/Greeter"/>
  </bean>
  



Mime
View raw message