User: mulder
Date: 00/10/19 12:56:32
Modified: src/main/org/jboss/test/dbtest/test Main.java
Log:
- Add a variable of type Time
- Add checks for min/max values for numeric types. Many DBs cannot
accurately represent floats, doubles, or longs. This is not
considered to be a failure, since it's a limitation of the DB not
the jBoss configuration or JAWS mapping.
- Change "Oracle" mapping to "Oracle 7". There's an "Oracle 8" mapping
forthcoming. In 7, you can only have one serialized Java object
per table, since they map to DB type long. In 8, we may be able to
get around that.
Revision Changes Path
1.2 +153 -38 jbosstest/src/main/org/jboss/test/dbtest/test/Main.java
Index: Main.java
===================================================================
RCS file:
/products/cvs/ejboss/jbosstest/src/main/org/jboss/test/dbtest/test/Main.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Main.java 2000/10/09 18:07:18 1.1
+++ Main.java 2000/10/19 19:56:31 1.2
@@ -24,20 +24,20 @@
public class Main {
-
+
static boolean deployed = false;
-
+
public static void main(String arg[]) {
Main main = new Main();
-
+
try {
main.setUp();
-
+
} catch (Exception e) {
System.out.println("Setup failed:");
e.printStackTrace();
}
-
+
try {
main.testAllTypesBean();
System.out.println();
@@ -61,66 +61,67 @@
System.out.println();
System.out.println("Thanks very much!");
System.out.println();
-
+
} catch (Exception e) {
+e.printStackTrace();
System.out.println();
System.out.println("_____________________________________________");
System.out.println("Sorry, test failed. Try again with
different settings!");
System.out.println("Thanks for your time...");
System.out.println();
-
+
}
}
-
-
+
+
public void testAllTypesBean() throws Exception {
int test = 0;
-
+
Context ctx = new InitialContext();
-
+
System.out.println();
System.out.print(++test+"- "+"Looking up the home AllTypes...");
-
+
AllTypesHome allTypesHome;
-
+
try {
allTypesHome = (AllTypesHome) ctx.lookup("AllTypes");
-
+
if (allTypesHome == null) throw new Exception("abort");
System.out.println("OK");
-
+
} catch (Exception e) {
System.out.println();
System.out.println("Could not lookup the context: the beans
are probably not deployed");
System.out.println("Check the server trace for details");
-
+
throw new Exception();
}
-
+
System.out.print(++test+"- "+"Calling findByPrimaryKey on AllTypesHome
with name seb...");
-
+
AllTypes allTypes = null;
-
+
try {
allTypes = allTypesHome.findByPrimaryKey("seb");
} catch (Exception e) {System.out.println(e.getMessage());}
-
+
if (allTypes == null) {
-
+
System.out.println("not found OK");
System.out.print(++test+"- "+"Calling create on AllTypesHome
with name seb...");
allTypes = allTypesHome.create("seb");
}
-
+
if (allTypes != null) System.out.println("OK"); else {
System.out.println();
System.out.println("Could not find or create the alltypes
bean");
System.out.println("Check the server trace for details");
-
+
throw new Exception();
}
-
-
+
+
System.out.println("Getting all the fields");
System.out.println(++test+"- "+"boolean " + allTypes.getBoolean() + "
OK");
System.out.println(++test+"- "+"byte " + allTypes.getByte() + " OK");
@@ -132,47 +133,161 @@
System.out.println("No char test yet, bug in jdk");
System.out.println(++test+"- "+"String " + allTypes.getString() + "
OK");
System.out.println(++test+"- "+"Date " + allTypes.getDate() + " OK");
+ System.out.println(++test+"- "+"Time " + allTypes.getTime() + " OK");
System.out.println(++test+"- "+"Timestamp " + allTypes.getTimestamp()
+ " OK");
-
+
System.out.print(++test+"- "+"MyObject ");
MyObject obj = allTypes.getObject();
System.out.println("OK");
-
+
System.out.print(++test+"- "+"Creating Record beans and adding them to
the Collection in Alltypes..");
RecordHome recordHome = (RecordHome) ctx.lookup("Record");
-
+
Record[] record = new Record[3];
int i;
for (i=0; i<3; i++) {
- try {
+ try {
record[i] = recordHome.findByPrimaryKey("bill " + i);
} catch (FinderException e) {
record[i] = recordHome.create("bill " + i);
}
-
+
record[i].setAddress("SanFrancisco, CA 9411"+i);
allTypes.addObjectToList(record[i]);
}
System.out.println("OK");
-
+
System.out.print(++test+"- "+"Getting them back..");
-
+
Collection collection = allTypes.getObjectList();
boolean ok = true;
-
+
for (i=0; i<3; i++) ok = ok && collection.contains(record[i]);
-
+
if (ok) System.out.println("OK"); else {
System.out.println("failed");
throw new Exception("abort");
}
+
+ System.out.println("All basic tests passed.");
+ System.out.println("Now testing min/max values...");
+
+ try {
+ allTypes.setFloat(Float.MIN_VALUE);
+ float f;
+ if((f = allTypes.getFloat()) == Float.MIN_VALUE)
+ System.out.println(++test+"- Float Min Value OK");
+ else
+ System.out.println(++test+"- Float Min Value Different ("+f+" <>
"+Float.MIN_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Float Min Value Failed");
+ }
+ try {
+ allTypes.setFloat(Float.MAX_VALUE);
+ float f;
+ if((f = allTypes.getFloat()) == Float.MAX_VALUE)
+ System.out.println(++test+"- Float Max Value OK");
+ else
+ System.out.println(++test+"- Float Max Value Different ("+f+" <>
"+Float.MAX_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Float Max Value Failed");
+ }
+
+ try {
+ allTypes.setDouble(Double.MIN_VALUE);
+ double d;
+ if((d = allTypes.getDouble()) == Double.MIN_VALUE)
+ System.out.println(++test+"- Double Min Value OK");
+ else
+ System.out.println(++test+"- Double Min Value Different ("+d+" <>
"+Double.MIN_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Double Min Value Failed");
+ }
+ try {
+ allTypes.setDouble(Double.MAX_VALUE);
+ double d;
+ if((d = allTypes.getDouble()) == Double.MAX_VALUE)
+ System.out.println(++test+"- Double Max Value OK");
+ else
+ System.out.println(++test+"- Double Max Value Different ("+d+" <>
"+Double.MAX_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Double Max Value Failed");
+ }
+
+ try {
+ allTypes.setByte(Byte.MIN_VALUE);
+ byte b;
+ if((b = allTypes.getByte()) == Byte.MIN_VALUE)
+ System.out.println(++test+"- Byte Min Value OK");
+ else
+ System.out.println(++test+"- Byte Min Value Different ("+b+" <>
"+Byte.MIN_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Byte Min Value Failed");
+ }
+ try {
+ allTypes.setByte(Byte.MAX_VALUE);
+ byte b;
+ if((b = allTypes.getByte()) == Byte.MAX_VALUE)
+ System.out.println(++test+"- Byte Max Value OK");
+ else
+ System.out.println(++test+"- Byte Max Value Different ("+b+" <>
"+Byte.MAX_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Byte Max Value Failed");
+ }
+
+ try {
+ allTypes.setShort(Short.MIN_VALUE);
+ short s;
+ if((s = allTypes.getShort()) == Short.MIN_VALUE)
+ System.out.println(++test+"- Short Min Value OK");
+ else
+ System.out.println(++test+"- Short Min Value Different ("+s+" <>
"+Short.MIN_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Short Min Value Failed");
+ }
+ try {
+ allTypes.setShort(Short.MAX_VALUE);
+ short s;
+ if((s = allTypes.getShort()) == Short.MAX_VALUE)
+ System.out.println(++test+"- Short Max Value OK");
+ else
+ System.out.println(++test+"- Short Max Value Different ("+s+" <>
"+Short.MAX_VALUE+")");
+ } catch(Exception e) {
+ System.out.println(++test+"- Short Max Value Failed");
+ }
+
+ try {
+ allTypes.setInt(Integer.MIN_VALUE);
+ System.out.println(++test+"- Int Min Value OK");
+ } catch(Exception e) {
+ System.out.println(++test+"- Int Min Value Failed");
+ }
+ try {
+ allTypes.setInt(Integer.MAX_VALUE);
+ System.out.println(++test+"- Int Max Value OK");
+ } catch(Exception e) {
+ System.out.println(++test+"- Int Max Value Failed");
+ }
+
+ try {
+ allTypes.setLong(Long.MIN_VALUE);
+ System.out.println(++test+"- Long Min Value OK");
+ } catch(Exception e) {
+ System.out.println(++test+"- Long Min Value Failed");
+ }
+ try {
+ allTypes.setLong(Long.MAX_VALUE);
+ System.out.println(++test+"- Long Max Value OK");
+ } catch(Exception e) {
+ System.out.println(++test+"- Long Max Value Failed");
+ }
}
-
-
- protected void setUp() throws Exception
+
+
+ protected void setUp() throws Exception
{
if (deployed) return;
-
+
System.out.println("_____________________________________________");
System.out.println();
System.out.println("jBoss, the EJB Open Source Server");