You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ad...@apache.org on 2003/09/27 22:18:37 UTC
cvs commit: incubator-geronimo/modules/common/src/test/org/apache/geronimo/common ClassesTest.java
adc 2003/09/27 13:18:37
Modified: modules/common/src/java/org/apache/geronimo/common
Classes.java
modules/common/src/test/org/apache/geronimo/common
ClassesTest.java
Log:
Applied patch GERONIMO-88
Revision Changes Path
1.7 +2 -2 incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/Classes.java
Index: Classes.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/Classes.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Classes.java 5 Sep 2003 05:49:26 -0000 1.6
+++ Classes.java 27 Sep 2003 20:18:37 -0000 1.7
@@ -374,7 +374,7 @@
int arrayDimension = 0;
String componentClassName = className;
while (componentClassName.endsWith("[]")) {
- componentClassName = componentClassName.substring(0, className.length() - 2);
+ componentClassName = componentClassName.substring(0, componentClassName.length() - 2);
arrayDimension++;
}
1.3 +85 -12 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/ClassesTest.java
Index: ClassesTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/ClassesTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClassesTest.java 29 Aug 2003 19:33:43 -0000 1.2
+++ ClassesTest.java 27 Sep 2003 20:18:37 -0000 1.3
@@ -69,26 +69,49 @@
protected Class loadClass(final String name)
{
Class type = null;
-
+
try {
type = Classes.loadClass(name);
}
catch (ClassNotFoundException e) {
fail("Class should have been found: " + e);
}
-
+
assertNotNull(type);
-
+
return type;
}
-
+
+ public void testLoadClass_Null()
+ {
+ try {
+ Classes.loadClass(null);
+ fail("Expected NullArgumentException");
+ }
+ catch(NullArgumentException ignore) {
+ }
+ catch (ClassNotFoundException e) {
+ fail("Class should have been found: " + e);
+ }
+
+ try {
+ Classes.loadClass("org.apache.geronimo.common.Classes",null);
+ fail("Expected NullArgumentException");
+ }
+ catch(NullArgumentException ignore) {
+ }
+ catch (ClassNotFoundException e) {
+ fail("Class should have been found: " + e);
+ }
+ }
+
public void testLoadClass_Simple()
{
String className = "org.apache.geronimo.common.Classes";
Class type = loadClass(className);
assertEquals(className, type.getName());
}
-
+
public void testLoadClass_Missing()
{
String className = "some.class.that.does.not.Exist";
@@ -98,33 +121,48 @@
}
catch (ClassNotFoundException ignore) {}
}
-
+
public void testLoadClass_Primitives()
{
String className = "boolean";
Class type = loadClass(className);
assertEquals(className, type.getName());
}
-
+
public void testLoadClass_VMPrimitives()
{
String className = "B";
Class type = loadClass(className);
assertEquals(byte.class, type);
}
-
+
public void testLoadClass_VMClassSyntax()
{
String className = "org.apache.geronimo.common.Classes";
Class type = loadClass("L" + className + ";");
assertEquals(className, type.getName());
}
-
+
public void testLoadClass_VMArraySyntax()
{
String className = "[B";
Class type = loadClass(className);
assertEquals(byte[].class, type);
+
+ className = "[java.lang.String";
+ type = loadClass(className);
+ assertEquals(String[].class, type);
+ }
+
+ public void testLoadClass_UserFriendlySyntax()
+ {
+ String className = "I[]";
+ Class type = loadClass(className);
+ assertEquals(int[].class, type);
+
+ className = "I[][][]";
+ type = loadClass(className);
+ assertEquals(int[][][].class, type);
}
public void testgetClassName() throws ClassNotFoundException {
@@ -136,7 +174,7 @@
x = Classes.getClassName(t);
y = loadClass(x);
assertEquals(t,y);
-
+
t= int.class;
x = Classes.getClassName(t);
y = loadClass(x);
@@ -163,5 +201,40 @@
assertEquals(t,y);
}
-
+
+ public void testGetPrimitiveWrapper() {
+ try {
+ Classes.getPrimitiveWrapper(null);
+ fail("Expected NullArgumentException");
+ } catch (NullArgumentException ignore) {
+ }
+
+ try {
+ Classes.getPrimitiveWrapper(String.class);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException ignore) {
+ }
+
+ assertEquals(Boolean.class,Classes.getPrimitiveWrapper(Boolean.TYPE));
+ }
+
+ public void testIsPrimitiveWrapper() {
+ try {
+ Classes.isPrimitiveWrapper(null);
+ fail("Expected NullArgumentException");
+ } catch (NullArgumentException ignore) {
+ }
+ assertTrue(Classes.isPrimitiveWrapper(Boolean.TYPE));
+ assertFalse(Classes.isPrimitiveWrapper(String.class));
+ }
+
+ public void testIsPrimitive() {
+ try {
+ Classes.isPrimitive(null);
+ fail("Expected NullArgumentException");
+ } catch (NullArgumentException ignore) {
+ }
+ assertTrue(Classes.isPrimitive(Boolean.TYPE));
+ assertFalse(Classes.isPrimitive(String.class));
+ }
}