You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by pc...@apache.org on 2004/03/02 21:21:53 UTC
cvs commit: xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam GoldenMethod.java JamTestBase.java
pcal 2004/03/02 12:21:53
Modified: v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl
EInvokableImpl.java
v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses
Base.java FooImpl.java
v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
GoldenMethod.java JamTestBase.java
Added: v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses
MyException.java
v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ejb
MyEjbException.java
Log:
jam: fix classcastexception and add a test case
Revision Changes Path
1.3 +2 -1 xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java
Index: EInvokableImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EInvokableImpl.java 1 Mar 2004 00:10:18 -0000 1.2
+++ EInvokableImpl.java 2 Mar 2004 20:21:53 -0000 1.3
@@ -20,6 +20,7 @@
import org.apache.xmlbeans.impl.jam.editable.impl.ref.DirectJClassRef;
import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
import org.apache.xmlbeans.impl.jam.editable.impl.ref.UnqualifiedJClassRef;
+import org.apache.xmlbeans.impl.jam.editable.impl.ref.JClassRef;
import org.apache.xmlbeans.impl.jam.JClass;
import org.apache.xmlbeans.impl.jam.JParameter;
@@ -123,7 +124,7 @@
}
JClass[] out = new JClass[mExceptionClassRefs.size()];
for(int i=0; i<out.length; i++) {
- out[i] = getClassLoader().loadClass((String)mExceptionClassRefs.get(i));
+ out[i] = ((JClassRef)mExceptionClassRefs.get(i)).getRefClass();
}
return out;
}
1.4 +10 -4 xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/Base.java
Index: Base.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/Base.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Base.java 26 Feb 2004 23:22:50 -0000 1.3
+++ Base.java 2 Mar 2004 20:21:53 -0000 1.4
@@ -1,7 +1,11 @@
package org.apache.xmlbeans.test.jam.dummyclasses;
- /**
- * NOT doonkie javadoc!
+import org.apache.xmlbeans.test.jam.dummyclasses.ejb.MyEjbException;
+
+import java.net.MalformedURLException;
+
+/**
+ * NOT doonkie javadoc!
*/
/**
@@ -12,10 +16,10 @@
public abstract class Base implements Foo {
/**
- * NOT doonkie javadoc!
+ * NOT doonkie javadoc!
*/
/**
- * doonkie javadoc!
+ * doonkie javadoc!
*/
private double doonkie = 2312;
private long doonkietoo;
@@ -26,6 +30,8 @@
public String getFoo() { return "foo"; } // {{}}{{
public void setId(int id) {}
+
+
}
1.4 +15 -0 xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/FooImpl.java
Index: FooImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/FooImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FooImpl.java 2 Mar 2004 04:26:19 -0000 1.3
+++ FooImpl.java 2 Mar 2004 20:21:53 -0000 1.4
@@ -1,5 +1,9 @@
package org.apache.xmlbeans.test.jam.dummyclasses;
+import org.apache.xmlbeans.test.jam.dummyclasses.ejb.MyEjbException;
+
+import java.net.MalformedURLException;
+
/**
* Dummy class for JAM tests.
*
@@ -20,5 +24,16 @@
String[][] methodDealingWithArrays(int[] foo, Object[] bar) {
return null;
}
+
+ protected abstract void iThrowExceptions(int p1, String p2) throws
+ IllegalArgumentException,
+ NoSuchMethodError,
+ MyException,
+ MyEjbException,
+ MalformedURLException,
+ OutOfMemoryError,
+ NullPointerException;
+
+
}
1.1 xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MyException.java
Index: MyException.java
===================================================================
/* 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.
*/
package org.apache.xmlbeans.test.jam.dummyclasses;
/**
*
* @author Patrick Calahan <pc...@bea.com>
*/
public class MyException extends Exception {
}
1.1 xml-xmlbeans/v2/test/src/jamtest/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ejb/MyEjbException.java
Index: MyEjbException.java
===================================================================
/* 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.
*/
package org.apache.xmlbeans.test.jam.dummyclasses.ejb;
/**
*
* @author Patrick Calahan <pc...@bea.com>
*/
public class MyEjbException extends Exception {
}
1.3 +38 -12 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/GoldenMethod.java
Index: GoldenMethod.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/GoldenMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GoldenMethod.java 2 Mar 2004 04:26:19 -0000 1.2
+++ GoldenMethod.java 2 Mar 2004 20:21:53 -0000 1.3
@@ -16,6 +16,7 @@
import org.apache.xmlbeans.impl.jam.JMethod;
import org.apache.xmlbeans.impl.jam.JParameter;
+import org.apache.xmlbeans.impl.jam.JClass;
import java.util.StringTokenizer;
@@ -60,6 +61,7 @@
private String mName;
private String[] mParamTypes;
private String[] mParamNames;
+ private String[] mExceptions;
// ========================================================================
@@ -69,7 +71,8 @@
this(modsTypeNameParams[0],
modsTypeNameParams[1],
modsTypeNameParams[2],
- modsTypeNameParams[3]);
+ modsTypeNameParams[3],
+ modsTypeNameParams[4]);
}
/**
@@ -81,7 +84,8 @@
public GoldenMethod(String modiferString,
String type,
String name,
- String paramString) {
+ String paramString,
+ String exceptionList) {
mModifers = ModifierHelper.parseModifiers(modiferString);
mReturnType = type;
mName = name;
@@ -102,6 +106,18 @@
i++;
}
}
+ // parse the exception list
+ if (exceptionList == null) {
+ mExceptions = new String[0];
+ } else {
+ StringTokenizer st = new StringTokenizer(exceptionList,",");
+ mExceptions = new String[st.countTokens()];
+ int i = 0;
+ while(st.hasMoreTokens()) {
+ mExceptions[i] = st.nextToken().trim();
+ i++;
+ }
+ }
}
public void compare(JMethod method, boolean compareParamNames, Assert a) {
@@ -114,16 +130,26 @@
a.assertTrue("modifiers are different on "+method.getSimpleName()+
"["+method.getModifiers()+","+mModifers+"]",
method.getModifiers() == mModifers);
- JParameter[] params = method.getParameters();
- a.assertTrue("parameter lists are of different lengths",
- params.length == mParamTypes.length);
- for(int i=0; i<params.length; i++) {
- a.assertTrue("parameter type is different on "+method.getSimpleName()+
- "["+params[i].getType().getQualifiedName()+","+mParamTypes[i]+"]",
- params[i].getType().getQualifiedName().equals(mParamTypes[i]));
- if (compareParamNames) {
- a.assertTrue("parameter names are different on "+method.getSimpleName(),
- params[i].getSimpleName().equals(mParamNames[i]));
+ {
+ JParameter[] params = method.getParameters();
+ a.assertTrue("parameter lists are of different lengths",
+ params.length == mParamTypes.length);
+ for(int i=0; i<params.length; i++) {
+ a.assertTrue("parameter type is different on "+method.getSimpleName()+
+ "["+params[i].getType().getQualifiedName()+","+mParamTypes[i]+"]",
+ params[i].getType().getQualifiedName().equals(mParamTypes[i]));
+ if (compareParamNames) {
+ a.assertTrue("parameter names are different on "+method.getSimpleName(),
+ params[i].getSimpleName().equals(mParamNames[i]));
+ }
+ }
+ }
+ {
+ JClass[] exceptions = method.getExceptionTypes();
+ for(int i=0; i<exceptions.length; i++) {
+ a.assertTrue("exceptions type is different on "+method.getSimpleName()+
+ "["+exceptions[i].getQualifiedName()+","+mExceptions[i]+"]",
+ exceptions[i].getQualifiedName().equals(mExceptions[i]));
}
}
}
1.6 +40 -19 xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
Index: JamTestBase.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JamTestBase.java 2 Mar 2004 06:32:13 -0000 1.5
+++ JamTestBase.java 2 Mar 2004 20:21:53 -0000 1.6
@@ -59,7 +59,6 @@
import org.apache.xmlbeans.impl.jam.*;
import java.io.File;
-import java.io.IOException;
import java.util.*;
/**
@@ -76,31 +75,50 @@
// ========================================================================
// Constants
+
+ protected static final String
+ DUMMY = "org.apache.xmlbeans.test.jam.dummyclasses";
+
//this array must contain the names of all of the test classes under
//dummyclasses
private static final String[] ALL_CLASSES = {
- "org.apache.xmlbeans.test.jam.dummyclasses.ejb.IEnv",
- "org.apache.xmlbeans.test.jam.dummyclasses.ejb.TraderEJB",
- "org.apache.xmlbeans.test.jam.dummyclasses.ejb.TradeResult",
- "org.apache.xmlbeans.test.jam.dummyclasses.Base",
- "org.apache.xmlbeans.test.jam.dummyclasses.Baz",
- "org.apache.xmlbeans.test.jam.dummyclasses.Foo",
- "org.apache.xmlbeans.test.jam.dummyclasses.FooImpl"
+ DUMMY+".ejb.IEnv",
+ DUMMY+".ejb.MyEjbException",
+ DUMMY+".ejb.TraderEJB",
+ DUMMY+".ejb.TradeResult",
+ DUMMY+".Base",
+ DUMMY+".Baz",
+ DUMMY+".Foo",
+ DUMMY+".FooImpl",
+ DUMMY+".MyException"
};
// this needs to correspond to the methods on the FooImpl dummyclass
private static final String[][] FOOIMPL_METHODS = {
- {"public", "int", "getId", null},
- {"public", "void", "setId", "int id"},
- {"private final static", "void", "setId2", "double id"},
- {"protected synchronized ", "void", "setId3", "double id, double id2"},
- {"protected abstract", "void", "setId4", "double id, double id2, double id3"},
- {"", "java.lang.String[][]", "methodDealingWithArrays", "int[] foo, java.lang.Object[] bar"}
+ {"public", "int", "getId", null, null},
+
+ {"public", "void", "setId", "int id",null},
+
+ {"private final static", "void", "setId2", "double id",null},
+
+ {"protected synchronized ", "void", "setId3", "double id, double id2",null},
+
+ {"protected abstract", "void", "setId4", "double id, double id2, double id3",null},
+
+ {"", "java.lang.String[][]", "methodDealingWithArrays", "int[] foo, java.lang.Object[] bar",null},
+
+ {"protected abstract", "void", "iThrowExceptions", "int p1, java.lang.String p2",
+ "java.lang.IllegalArgumentException," +
+ "java.lang.NoSuchMethodError," +
+ DUMMY+".MyException,"+
+ DUMMY+".ejb.MyEjbException,"+
+ "java.net.MalformedURLException,"+
+ "java.lang.OutOfMemoryError,"+
+ "java.lang.NullPointerException"
+ }
};
- protected static final String
- DUMMY = "org.apache.xmlbeans.test.jam.dummyclasses";
private static final boolean VERBOSE = false;
@@ -113,7 +131,7 @@
// ========================================================================
// Constructors
-
+
public JamTestBase() {
super("JamTestBase");
}
@@ -186,6 +204,8 @@
resolveCheckRecursively(mResult.getAllClasses(),new HashSet());
}
+
+
/**
* Verify that FooImpl has the correct methods with the correct
* number of parameters and correct return types.
@@ -197,6 +217,7 @@
methods,isParameterNamesKnown(),this);
}
+
public void testInterfaceIsAssignableFrom()
{
JClass fooImpl = resolved(mLoader.loadClass(DUMMY+".FooImpl"));
@@ -207,7 +228,7 @@
!fooImpl.isAssignableFrom(foo));
}
- public void testClassIsAssignableFrom()
+ public void testClassIsAssignableFrom()
{
JClass fooImpl = resolved(mLoader.loadClass(DUMMY+".FooImpl"));
JClass base = resolved(mLoader.loadClass(DUMMY+".Base"));
@@ -217,7 +238,7 @@
!fooImpl.isAssignableFrom(base));
}
- public void testClassIsAssignableFromDifferentClassLoaders()
+ public void testClassIsAssignableFromDifferentClassLoaders()
{
JClass baz = resolved(mLoader.loadClass(DUMMY+".Baz"));
JClass runnable = resolved(mLoader.loadClass("java.lang.Runnable"));
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org