You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/09/17 00:22:19 UTC
svn commit: rev 46216 - in incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181: model processor/apt processor/reflection
Author: mmerz
Date: Thu Sep 16 15:22:16 2004
New Revision: 46216
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
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:
Broke FooTestCase up into several tests, each of which can be customized (through overriding) if necessary.
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java Thu Sep 16 15:22:16 2004
@@ -21,100 +21,129 @@
import junit.framework.TestCase;
/**
- * Verifies an object model against expected values defined in Foo.java.
+ * This class serves as the base class for all TestCases based on Foo.java. It
+ * verifies the values of all parameters in the object model defined in Foo.java.
+ * Default values are expected to be filled in. If a subclass can't fully comply
+ * with JSR-181 (e.g. if it can't fill in all default values) it needs to
+ * override the respective tests.
*/
public class FooTestCase extends TestCase
{
+ protected static final String CLASSNAME = "Foo";
+ protected static final String SRCFILENAME = "Foo.java";
+
protected AnnotationModel objectModel;
- public void testMetaDataFromSourceFile() throws Exception
+ public void testObjectModel() throws Exception
{
- assertNotNull("Failed to retrieve object model", objectModel);
-
- WebServiceTYPEMetadata type = (WebServiceTYPEMetadata) objectModel;
+ assertNotNull("Failed to retrieve object model;", objectModel);
+ }
+
+ public void testWebServiceAbacus() throws Exception
+ {
+ assertEquals("Invalid wsName;", "Abacus",
+ ((WebServiceTYPEMetadata) objectModel).getWsName()
+ );
- // wsName
- assertEquals("Invalid wsName", type.getWsName(), "Abacus");
+ // todo test endpointInterface
- // todo: get the endpointInterface
+ assertEquals("Invalid wsTargetNamespace;",
+ "http://www.superflaco.com/AnnotationTest",
+ ((WebServiceTYPEMetadata) objectModel).getWsTargetNamespace()
+ );
+ }
+
+ public void testWebMethodGoLoco() throws Exception
+ {
+ WebServiceMETHODMetadata method = getMethod("GoLoco");
+ assertNotNull("Cannot find WebMethod GoLoco();", method);
+ assertEquals("Invalid wmAction;", "LocoAction", method.getWmAction());
+ assertFalse("Unexpected @Oneway;", method.isOneWay());
+ assertEquals("Invalid wrName;", "result", method.getWrName());
+ assertEquals("Invalid return type;",
+ boolean.class,
+ method.getJavaReturnType()
+ );
+ }
+
+ public void testWebMethodGoHome() throws Exception
+ {
+ WebServiceMETHODMetadata method = getMethod("goHome");
+ assertNotNull("Cannot find WebMethod goHome();", method);
+ assertEquals("Invalid wmAction;", "", method.getWmAction());
+ assertTrue("Cannot find @Oneway;", method.isOneWay());
+ assertNull("Unexpected @WebResult;", method.getWrName());
+ assertEquals("Unexpected return type;",
+ void.class,
+ method.getJavaReturnType()
+ );
+ }
+
+ public void testWebParamGoLocoFirst() throws Exception
+ {
+ final int paramNo = 0;
+ WebServicePARAMETERMetadata param = getParam("GoLoco", paramNo);
+ assertNotNull("Cannot find first param for WebMethod GoLoco();", param);
+ assertEquals("Invalid wpName;", "level", param.getWpName());
+ assertEquals("Invalid return type: " + param.getJavaType(),
+ int.class,
+ param.getJavaType()
+ );
+ }
- // wsTargetNamespace
- assertEquals("Invalid wsTargetNamespace",
- type.getWsTargetNamespace(),
- "http://www.superflaco.com/AnnotationTest"
+ public void testWebParamGoLocoSecond() throws Exception
+ {
+ final int paramNo = 1;
+ WebServicePARAMETERMetadata param = getParam("GoLoco", paramNo);
+ assertNotNull("Cannot find second param for WebMethod GoLoco();", param);
+ assertEquals("Invalid wpName;", "detail", param.getWpName());
+ assertEquals("Invalid return type: " + param.getJavaType(),
+ String.class,
+ param.getJavaType()
);
+ }
- for (WebServiceMETHODMetadata method : type.getMethods())
+ public void testWebParamGoHomeFirst() throws Exception
+ {
+ final int paramNo = 0;
+ WebServicePARAMETERMetadata param = getParam("goHome", paramNo);
+ assertNotNull("Cannot find first param for method goHome();", param);
+ assertEquals("Invalid wpName;", "when", param.getWpName());
+ assertEquals("Invalid return type: " + param.getJavaType(),
+ long.class,
+ param.getJavaType()
+ );
+ }
+
+ protected WebServiceMETHODMetadata getMethod(String methodName)
+ {
+ for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
{
- if (method.getWmOperationName().equals("GoLoco"))
+ if (method.getWmOperationName().equals(methodName))
{
- // 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
- );
- }
- }
+ return method;
}
- else if (method.getWmOperationName().equals("goHome"))
+ }
+ return null;
+ }
+
+ protected WebServicePARAMETERMetadata getParam(String methodName, int pos)
+ {
+ for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
+ {
+ if (method.getWmOperationName().equals(methodName))
{
- assertTrue(method.isOneWay());
-
- // test parameters
+ int i = 0;
for (WebServicePARAMETERMetadata param : method.getParams())
{
- if (param.getWpName().equals("when"))
+ if (i == pos)
{
- assertEquals("Invalid return type: " + param.getJavaType(),
- param.getJavaType(),
- long.class
- );
- }
- else
- {
- assertTrue("Found unexpected parameter of type: " +
- param.getJavaType(),
- false
- );
+ return param;
}
+ i++;
}
}
- else
- {
- assertTrue("Found unexpected method: " +
- method.getWmOperationName(),
- false
- );
- }
}
+ return null;
}
}
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 15:22:16 2004
@@ -30,9 +30,6 @@
*/
public class WsmAnnotationProcessorTest extends FooTestCase {
- private static final String CLASSNAME = "Foo";
- private static final String SRCFILENAME = "Foo.java";
-
@Override
public void setUp() throws Exception
{
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 15:22:16 2004
@@ -19,15 +19,15 @@
*/
import org.apache.beehive.wsm.jsr181.model.FooTestCase;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
/**
* Test case verifies that a class file can be read and its annotations can be
* interpreted by the annotation processor.
+ * Overrides some tests that are defined in the base class.
*/
public class WsmAnnotationProcessorTest extends FooTestCase {
- private static final String CLASSNAME = "Foo";
-
@Override
public void setUp() throws Exception
{
@@ -39,6 +39,23 @@
public void tearDown() throws Exception
{
// empty
+ }
+
+ /**
+ * We can't derive default values for WebParam from binaries. Thus, we use
+ * our own default name "in<number>".
+ */
+ @Override
+ public void testWebParamGoLocoFirst() throws Exception
+ {
+ final int paramNo = 0;
+ WebServicePARAMETERMetadata param = getParam("GoLoco", paramNo);
+ assertNotNull("Cannot find first param for WebMethod GoLoco()", param);
+ assertEquals("Invalid wpName", "in" + paramNo, param.getWpName());
+ assertEquals("Invalid return type: " + param.getJavaType(),
+ int.class,
+ param.getJavaType()
+ );
}
}