beehive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mm...@apache.org
Subject svn commit: rev 46189 - in incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor: apt reflection
Date Thu, 16 Sep 2004 17:03:27 GMT
Author: mmerz
Date: Thu Sep 16 10:03:27 2004
New Revision: 46189

Added:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
      - copied, changed from rev 46186, incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java
Removed:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java
Modified:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
Log:
Added tests for apt processing and aligned reflection and apt tests both based on Foo.java.



Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
(original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
Thu Sep 16 10:03:27 2004
@@ -23,6 +23,7 @@
 import junit.framework.TestCase;
 
 import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
+import org.apache.beehive.wsm.jsr181.model.*;
 
 import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
 
@@ -38,19 +39,10 @@
     private static final String CLASSNAME = "Foo";
     private static final String SRCFILENAME = "Foo.java";
     
-    private Main apt;
-
-    public void setUp()
-    {
-        apt = new Main();
-    }
+    private AnnotationModel objectModel;
     
-    public void tearDown()
-    {
-        // todo
-    }
-    
-    public void testAnnotationProcessor() throws Exception
+    @Override
+    public void setUp() throws Exception
     {
         // get project root from environment
         String BEEHIVE_HOME;
@@ -64,19 +56,115 @@
             "-factory", "org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessorFactory",
             new java.io.File(
                 new java.io.File(BEEHIVE_HOME, "/wsm/drt/tests/"),
-                SRCFILENAME).getCanonicalPath()
+                SRCFILENAME
+            ).getCanonicalPath()
         };
 
         // compile source file
-        int status = apt.compile(_args);
+        int status = new Main().compile(_args);
         if (0 != status)
         {
             throw new Exception("error compiling: " + SRCFILENAME);
         }
 
         // check if we have an object model
-        AnnotationModel objectModel =
-            WsmAnnotationProcessor.getObjectModel(CLASSNAME);
-        assertNotNull("object model could not be read", objectModel);
+        this.objectModel = WsmAnnotationProcessor.getObjectModel(CLASSNAME);
+    }
+    
+    @Override
+    public void tearDown()
+    {
+        // empty
+    }
+
+    public void testMetaDataFromSourceFile() throws Exception
+    {
+        assertNotNull("Failed to retrieve object model", objectModel);
+
+        WebServiceTYPEMetadata type = (WebServiceTYPEMetadata) objectModel;
+        
+        // wsName
+        assertEquals("Invalid wsName", type.getWsName(), "Abacus");
+
+        // todo: get the endpointInterface
+
+        // wsTargetNamespace
+        assertEquals("Invalid wsTargetNamespace",
+            type.getWsTargetNamespace(),
+            "http://www.superflaco.com/AnnotationTest"
+        );
+
+        for (WebServiceMETHODMetadata method : type.getMethods())
+        {
+            if (method.getWmOperationName().equals("GoLoco"))
+            {
+                // wmAction
+                assertEquals("Invalid wmAction",
+                    method.getWmAction(),
+                    "LocoAction"
+                );
+                
+                // wrName
+                assertEquals("Invalid wrName",
+                    method.getWrName(),
+                    "result"
+                );
+                
+                for (WebServicePARAMETERMetadata param : method.getParams())
+                {
+                    if (param.getWpName().equals("level"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            int.class
+                        );
+                    }
+                    else if (param.getWpName().equals("detail"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            String.class
+                        );
+                    }
+                    else
+                    {
+                        assertTrue("Found unexpected parameter of type: " +
+                            param.getJavaType(),
+                            false
+                        );
+                    }
+                }
+            }
+            else if (method.getWmOperationName().equals("goHome"))
+            {
+                assertTrue(method.isOneWay());
+                
+                // test parameters
+                for (WebServicePARAMETERMetadata param : method.getParams())
+                {
+                    if (param.getWpName().equals("when"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            long.class
+                        );
+                    }
+                    else
+                    {
+                        assertTrue("Found unexpected parameter of type: " +
+                            param.getJavaType(),
+                            false
+                        );
+                    }
+                }
+            }
+            else
+            {
+                assertTrue("Found unexpected method: " +
+                    method.getWmOperationName(),
+                    false
+                );
+            }
+        }
     }
-}
+}
\ No newline at end of file

Copied: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
(from rev 46186, incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java)
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java
(original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
Thu Sep 16 10:03:27 2004
@@ -1,84 +1,120 @@
 package org.apache.beehive.wsm.jsr181.processor.reflection;
 
-import java.util.Collection;
-import java.util.List;
-
 import junit.framework.TestCase;
 
+import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
 import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
 import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
 import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
 import org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
 
-public class ReflectionProcessingTest extends TestCase {
+public class WsmAnnotationProcessorTest extends TestCase {
 
-    public void setUp() {
+    private static final String CLASSNAME = "Foo";
+    
+    private AnnotationModel objectModel;
+    
+    @Override
+    public void setUp() throws Exception
+    {
+        Class clazz = Class.forName(CLASSNAME);
+        objectModel = WsmReflectionAnnotationProcessor.getObjectModel(clazz);
     }
 
-    public void tearDown() {
-
+    @Override
+    public void tearDown()
+    {
+        // empty
     }
 
-    public void testMetaDataFromCompiledClass() throws Exception {
-        WebServiceTYPEMetadata model = WsmReflectionAnnotationProcessor
-                .getObjectModel(Class.forName("Foo"));
-        assertTrue("Unexpected Webservice name", model.getWsName().compareTo(
-                "Abacus") == 0);
-
-        //TODO: get the endpointInterface
-
-        assertTrue(model.getWsTargetNamespace().compareTo(
-                "http://www.superflaco.com/AnnotationTest") == 0);
-        Collection<WebServiceMETHODMetadata> methods = model.getMethods();
-
-        for (WebServiceMETHODMetadata nxtMethod : methods) {
-            if (nxtMethod.getWmOperationName().compareTo("GoLoco") == 0) {
-                assertTrue(nxtMethod.getWmAction().compareTo("LocoAction") == 0);
-                assertTrue(nxtMethod.getWrName().compareTo("result") == 0);
-                // test parameters
-
-                List<WebServicePARAMETERMetadata> params = nxtMethod
-                        .getParams();
-                for (WebServicePARAMETERMetadata nxtParam : params) {
-
-                    if (nxtParam.getWpName().compareTo("in0") == 0) {
-                        assertTrue("Invalid return type: "
-                                + nxtParam.getJavaType(), nxtParam
-                                .getJavaType() == int.class);
-                    } else if (nxtParam.getWpName().compareTo("detail") == 0) {
-                        assertTrue("Invalid return type: "
-                                + nxtParam.getJavaType(), nxtParam
-                                .getJavaType() == String.class);
-
-                    } else {
-                        assertTrue("Found an unexpected parameter: "
-                                + nxtParam.getJavaType(), false);
-
+    public void testMetaDataFromCompiledClass() throws Exception
+    {
+        assertNotNull("Failed to retrieve object model", objectModel);
+
+        WebServiceTYPEMetadata type = (WebServiceTYPEMetadata) objectModel;
+        
+        // wsName
+        assertEquals("Invalid wsName", type.getWsName(), "Abacus");
+
+        // todo: get the endpointInterface
+
+        // wsTargetNamespace
+        assertEquals("Invalid wsTargetNamespace",
+            type.getWsTargetNamespace(),
+            "http://www.superflaco.com/AnnotationTest"
+        );
+
+        for (WebServiceMETHODMetadata method : type.getMethods())
+        {
+            if (method.getWmOperationName().equals("GoLoco"))
+            {
+                // wmAction
+                assertEquals("Invalid wmAction",
+                    method.getWmAction(),
+                    "LocoAction"
+                );
+                
+                // wrName
+                assertEquals("Invalid wrName",
+                    method.getWrName(),
+                    "result"
+                );
+                
+                for (WebServicePARAMETERMetadata param : method.getParams())
+                {
+                    if (param.getWpName().equals("in0"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            int.class
+                        );
+                    }
+                    else if (param.getWpName().equals("detail"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            String.class
+                        );
+                    }
+                    else
+                    {
+                        assertTrue("Found unexpected parameter of type: " +
+                            param.getJavaType(),
+                            false
+                        );
                     }
                 }
-            } else if (nxtMethod.getWmOperationName().compareTo("goHome") == 0) {
-                assertTrue(nxtMethod.isOneWay());
-                List<WebServicePARAMETERMetadata> params = nxtMethod
-                        .getParams();
+            }
+            else if (method.getWmOperationName().equals("goHome"))
+            {
+                assertTrue(method.isOneWay());
+                
                 // test parameters
-                for (WebServicePARAMETERMetadata nxtParam : params) {
-
-                    if (nxtParam.getWpName().compareTo("when") == 0) {
-                        assertTrue("Invalid return type: "
-                                + nxtParam.getJavaType(), nxtParam
-                                .getJavaType() == long.class);
-                    } else {
-                        assertTrue("Found an unexpected parameter: "
-                                + nxtParam.getJavaType(), false);
-
+                for (WebServicePARAMETERMetadata param : method.getParams())
+                {
+                    if (param.getWpName().equals("when"))
+                    {
+                        assertEquals("Invalid return type: " + param.getJavaType(),
+                            param.getJavaType(),
+                            long.class
+                        );
+                    }
+                    else
+                    {
+                        assertTrue("Found unexpected parameter of type: " +
+                            param.getJavaType(),
+                            false
+                        );
                     }
                 }
-
-            } else {
-                assertTrue("Found an unexpected method: "
-                        + nxtMethod.getWmOperationName(), false);
             }
-
+            else
+            {
+                assertTrue("Found unexpected method: " +
+                    method.getWmOperationName(),
+                    false
+                );
+            }
         }
     }
 }

Mime
View raw message