tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlmonte...@apache.org
Subject svn commit: r920267 - in /openejb/trunk/openejb3/examples/simple-webservice/src: main/java/org/superbiz/calculator/CalculatorImpl.java main/java/org/superbiz/calculator/CalculatorWs.java test/java/org/superbiz/calculator/CalculatorTest.java
Date Mon, 08 Mar 2010 11:03:56 GMT
Author: jlmonteiro
Date: Mon Mar  8 11:03:56 2010
New Revision: 920267

URL: http://svn.apache.org/viewvc?rev=920267&view=rev
Log:
Add @WebServiceRef injection to the test case.

Modified:
    openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorImpl.java
    openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorWs.java
    openejb/trunk/openejb3/examples/simple-webservice/src/test/java/org/superbiz/calculator/CalculatorTest.java

Modified: openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorImpl.java?rev=920267&r1=920266&r2=920267&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorImpl.java
(original)
+++ openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorImpl.java
Mon Mar  8 11:03:56 2010
@@ -27,7 +27,11 @@
  * This is an EJB 3 style pojo stateless session bean
  * Every stateless session bean implementation must be annotated
  * using the annotation @Stateless
- * This EJB has a single interface: CalculatorWs a webservice interface.
+ * This EJB has a 2 interfaces: 
+ * <ul>
+ *   <li>CalculatorWs a webservice interface</li>
+ *   <li>CalculatorLocal a local interface</li>
+ * </ul>
  */
 //START SNIPPET: code
 @Stateless

Modified: openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorWs.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorWs.java?rev=920267&r1=920266&r2=920267&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorWs.java
(original)
+++ openejb/trunk/openejb3/examples/simple-webservice/src/main/java/org/superbiz/calculator/CalculatorWs.java
Mon Mar  8 11:03:56 2010
@@ -30,11 +30,13 @@
 
 /**
  * This is an EJB 3 webservice interface
- * A webservice interface must be annotated with the @Local
+ * A webservice interface must be annotated with the @WebService
  * annotation.
  */
 //START SNIPPET: code
-@WebService(targetNamespace = "http://superbiz.org/wsdl")
+@WebService(
+        name="CalculatorWs",
+        targetNamespace = "http://superbiz.org/wsdl")
 public interface CalculatorWs {
 
     public int sum(int add1, int add2);

Modified: openejb/trunk/openejb3/examples/simple-webservice/src/test/java/org/superbiz/calculator/CalculatorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-webservice/src/test/java/org/superbiz/calculator/CalculatorTest.java?rev=920267&r1=920266&r2=920267&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/simple-webservice/src/test/java/org/superbiz/calculator/CalculatorTest.java
(original)
+++ openejb/trunk/openejb3/examples/simple-webservice/src/test/java/org/superbiz/calculator/CalculatorTest.java
Mon Mar  8 11:03:56 2010
@@ -20,16 +20,26 @@
 import java.util.Date;
 import java.util.Properties;
 
+import javax.ejb.EJB;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceRef;
+
+import org.apache.openejb.api.LocalClient;
 
 import junit.framework.TestCase;
 
+@LocalClient
 public class CalculatorTest extends TestCase {
 
+    @WebServiceRef(
+            wsdlLocation="http://127.0.0.1:4204/CalculatorImpl?wsdl"
+    )
+    private CalculatorWs calculatorWs;
+    
     //START SNIPPET: setup	
     private InitialContext initialContext;
     
@@ -42,6 +52,8 @@
         properties.setProperty("openejb.embedded.remotable", "true");
         
         initialContext = new InitialContext(properties);
+        initialContext.bind("inject", this);
+
     }
     //END SNIPPET: setup    
 
@@ -68,6 +80,18 @@
 	assertEquals(userIdHolder.value, returnCodeHolder.value);
 	assertTrue(date.before(datetimeHolder.value));
     }
+    
+    public void testWebServiceRefInjection() throws Exception {
+        assertEquals(10, calculatorWs.sum(4,6));
+        assertEquals(12, calculatorWs.multiply(3,4));
+        
+        Holder<String> userIdHolder = new Holder<String>("jane");
+        Holder<String> returnCodeHolder = new Holder<String>();
+        Holder<Date> datetimeHolder = new Holder<Date>(date);
+        assertEquals(6, calculatorWs.factorial(3, userIdHolder, returnCodeHolder, datetimeHolder));
+        assertEquals(userIdHolder.value, returnCodeHolder.value);
+        assertTrue(date.before(datetimeHolder.value));
+    }
 
     public void testCalculatorViaRemoteInterface() throws Exception {
         CalculatorLocal calc = (CalculatorLocal) initialContext.lookup("CalculatorImplLocal");



Mime
View raw message