beehive-commits mailing list archives

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

Added:
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.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/reflection/WsmAnnotationProcessorTest.java
Log:
Added new file "FooTestCase" that implements common functionality and provides a base class
for annotation processing junit tests.



Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
Thu Sep 16 10:27:49 2004
@@ -0,0 +1,120 @@
+package org.apache.beehive.wsm.jsr181.model;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * Verifies an object model against expected values defined in Foo.java.
+ */
+public class FooTestCase extends TestCase
+{
+    protected AnnotationModel objectModel;
+    
+    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("detail")) || (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

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:27:49 2004
@@ -20,27 +20,19 @@
 
 import com.sun.tools.apt.Main;
 
-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.model.FooTestCase;
 import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
 
 
 /**
- * Test case verifies that a source file can be read and interpreted by the
- * annotation processor.
- * Data validation is not implemented here, but will be part of other test
- * cases.
+ * Test case verifies that a source file can be read and its annotations can be
+ * interpreted by the annotation processor.
  */
-public class WsmAnnotationProcessorTest extends TestCase {
+public class WsmAnnotationProcessorTest extends FooTestCase {
 
     private static final String CLASSNAME = "Foo";
     private static final String SRCFILENAME = "Foo.java";
     
-    private AnnotationModel objectModel;
-    
     @Override
     public void setUp() throws Exception
     {
@@ -53,7 +45,8 @@
 
         // initialize "command line args"
         String[] _args = {
-            "-factory", "org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessorFactory",
+            "-factory",
+            "org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessorFactory",
             new java.io.File(
                 new java.io.File(BEEHIVE_HOME, "/wsm/drt/tests/"),
                 SRCFILENAME
@@ -72,99 +65,8 @@
     }
     
     @Override
-    public void tearDown()
+    public void tearDown() throws Exception
     {
         // 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
-                );
-            }
-        }
     }
 }

Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
(original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
Thu Sep 16 10:27:49 2004
@@ -1,19 +1,33 @@
 package org.apache.beehive.wsm.jsr181.processor.reflection;
 
-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 WsmAnnotationProcessorTest extends TestCase {
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+
+import org.apache.beehive.wsm.jsr181.model.FooTestCase;
+
+/**
+ * Test case verifies that a class file can be read and its annotations can be
+ * interpreted by the annotation processor.
+ */
+public class WsmAnnotationProcessorTest extends FooTestCase {
 
     private static final String CLASSNAME = "Foo";
     
-    private AnnotationModel objectModel;
-    
     @Override
     public void setUp() throws Exception
     {
@@ -22,100 +36,9 @@
     }
 
     @Override
-    public void tearDown()
+    public void tearDown() throws Exception
     {
         // empty
-    }
-
-    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 (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
-                );
-            }
-        }
     }
 }
 

Mime
View raw message