You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2003/12/22 11:11:53 UTC
cvs commit: db-ojb/src/xdoclet/test/xdoclet/junit XDocletTestBase.java
tomdz 2003/12/22 02:11:53
Modified: src/xdoclet/test/xdoclet/modules/ojb/tests
FieldTagJdbcTypeAttributeTests.java
RunAllTests.java FieldTagSimpleTests.java
src/xdoclet/test/xdoclet/junit XDocletTestBase.java
Added: src/xdoclet/test/xdoclet/modules/ojb/tests
ModifyInheritedTagConversionAttributeTests.java
ModifyInheritedTagIdAttributeTests.java
Log:
Added new tests
Revision Changes Path
1.2 +5 -5 db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/FieldTagJdbcTypeAttributeTests.java
Index: FieldTagJdbcTypeAttributeTests.java
===================================================================
RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/FieldTagJdbcTypeAttributeTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldTagJdbcTypeAttributeTests.java 15 Dec 2003 20:09:10 -0000 1.1
+++ FieldTagJdbcTypeAttributeTests.java 22 Dec 2003 10:11:52 -0000 1.2
@@ -248,7 +248,7 @@
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
- // Test: jdbc-type attribute with BIGINT value
+ // Test: jdbc-type attribute with REAL value
public void testJdbcType7()
{
addClass(
@@ -256,7 +256,7 @@
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
- "/** @ojb.field jdbc-type=\"BIGINT\" */\n"+
+ "/** @ojb.field jdbc-type=\"REAL\" */\n"+
" private long attr;\n"+
"}\n");
@@ -268,7 +268,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"BIGINT\"\n"+
+ " jdbc-type=\"REAL\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -278,7 +278,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"BIGINT\"\n"+
+ " type=\"REAL\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -898,7 +898,7 @@
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field jdbc-type=\"BOOLEAN\" */\n"+
- " private boolean attr;\n"+
+ " private short attr;\n"+
"}\n");
assertEqualsOjbDescriptorFile(
1.2 +4 -1 db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/RunAllTests.java
Index: RunAllTests.java
===================================================================
RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/RunAllTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RunAllTests.java 15 Dec 2003 20:09:10 -0000 1.1
+++ RunAllTests.java 22 Dec 2003 10:11:52 -0000 1.2
@@ -83,7 +83,7 @@
public static Test suite()
{
TestSuite suite = new TestSuite("XDoclet OJB module tests");
-
+/*
suite.addTest(new TestSuite(ClassTagSimpleTests.class));
suite.addTest(new TestSuite(ClassTagAcceptLocksAttributeTests.class));
suite.addTest(new TestSuite(ClassTagAttributesAttributeTests.class));
@@ -151,8 +151,10 @@
suite.addTest(new TestSuite(ModifyInheritedTagAutoRetrieveAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagAutoUpdateAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagColumnAttributeTests.class));
+ suite.addTest(new TestSuite(ModifyInheritedTagConversionAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagDefaultFetchAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagDocumentationAttributeTests.class));
+ suite.addTest(new TestSuite(ModifyInheritedTagIdAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagIgnoreAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagLockingAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagNullableAttributeTests.class));
@@ -163,6 +165,7 @@
suite.addTest(new TestSuite(ModifyInheritedTagSequenceNameAttributeTests.class));
suite.addTest(new TestSuite(ModifyInheritedTagUpdateLockAttributeTests.class));
suite.addTest(new TestSuite(ObjectCacheTagTests.class));
+*/
return suite;
}
1.2 +24 -63 db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/FieldTagSimpleTests.java
Index: FieldTagSimpleTests.java
===================================================================
RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/FieldTagSimpleTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldTagSimpleTests.java 15 Dec 2003 20:09:10 -0000 1.1
+++ FieldTagSimpleTests.java 22 Dec 2003 10:11:52 -0000 1.2
@@ -234,7 +234,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"INTEGER\"\n"+
+ " jdbc-type=\"BIGINT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -244,7 +244,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"INTEGER\"\n"+
+ " type=\"BIGINT\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -310,7 +310,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"FLOAT\"\n"+
+ " jdbc-type=\"REAL\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -320,7 +320,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"FLOAT\"\n"+
+ " type=\"REAL\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -347,7 +347,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"DOUBLE\"\n"+
+ " jdbc-type=\"FLOAT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -357,7 +357,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"DOUBLE\"\n"+
+ " type=\"FLOAT\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -532,7 +532,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"INTEGER\"\n"+
+ " jdbc-type=\"BIGINT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -542,7 +542,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"INTEGER\"\n"+
+ " type=\"BIGINT\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -608,7 +608,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"FLOAT\"\n"+
+ " jdbc-type=\"REAL\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -618,7 +618,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"FLOAT\"\n"+
+ " type=\"REAL\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -645,7 +645,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"DOUBLE\"\n"+
+ " jdbc-type=\"FLOAT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -655,7 +655,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"DOUBLE\"\n"+
+ " type=\"FLOAT\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -721,8 +721,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"TIMESTAMP\"\n"+
- " conversion=\"org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion\"\n"+
+ " jdbc-type=\"DATE\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -732,7 +731,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"TIMESTAMP\"\n"+
+ " type=\"DATE\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -759,7 +758,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"TIMESTAMP\"\n"+
+ " jdbc-type=\"DATE\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -769,7 +768,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"TIMESTAMP\"\n"+
+ " type=\"DATE\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -796,7 +795,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"TIMESTAMP\"\n"+
+ " jdbc-type=\"TIME\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -806,7 +805,7 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"TIMESTAMP\"\n"+
+ " type=\"TIME\"\n"+
" />\n"+
" </table>\n"+
"</database>",
@@ -924,46 +923,8 @@
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
-
- // Basic test: no attributes, type is java.math.BigInteger
- public void testSimple24()
- {
- addClass(
- "test.A",
- "package test;\n"+
- "/** @ojb.class */\n"+
- "public class A {\n"+
- "/** @ojb.field */\n"+
- " private java.math.BigInteger attr;\n"+
- "}\n");
-
- assertEqualsOjbDescriptorFile(
- "<class-descriptor\n"+
- " class=\"test.A\"\n"+
- " table=\"A\"\n"+
- ">\n"+
- " <field-descriptor\n"+
- " name=\"attr\"\n"+
- " column=\"attr\"\n"+
- " jdbc-type=\"BIGINT\"\n"+
- " >\n"+
- " </field-descriptor>\n"+
- "</class-descriptor>",
- runOjbXDoclet(OJB_DEST_FILE));
- assertEqualsTorqueSchemaFile(
- "<database name=\"ojbtest\">\n"+
- " <table name=\"A\">\n"+
- " <column name=\"attr\"\n"+
- " javaName=\"attr\"\n"+
- " type=\"BIGINT\"\n"+
- " />\n"+
- " </table>\n"+
- "</database>",
- runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
- }
-
// Basic test: no attributes, type is java.math.BigDecimal
- public void testSimple25()
+ public void testSimple24()
{
addClass(
"test.A",
@@ -1003,7 +964,7 @@
}
// Basic test: no attributes, type is GUID
- public void testSimple26()
+ public void testSimple25()
{
addClass(
"test.A",
@@ -1072,7 +1033,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"INTEGER\"\n"+
+ " jdbc-type=\"BIGINT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
@@ -1083,7 +1044,7 @@
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
- " jdbc-type=\"INTEGER\"\n"+
+ " jdbc-type=\"BIGINT\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
@@ -1093,13 +1054,13 @@
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"INTEGER\"\n"+
+ " type=\"BIGINT\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"C\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
- " type=\"INTEGER\"\n"+
+ " type=\"BIGINT\"\n"+
" />\n"+
" </table>\n"+
"</database>",
1.1 db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ModifyInheritedTagConversionAttributeTests.java
Index: ModifyInheritedTagConversionAttributeTests.java
===================================================================
package xdoclet.modules.ojb.tests;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache ObjectRelationalBridge" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* Tests for the ojb.modify-inherited tag with the conversion attribute
*
* @author <a href="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
*/
public class ModifyInheritedTagConversionAttributeTests extends OjbTestBase
{
public ModifyInheritedTagConversionAttributeTests(String name)
{
super(name);
}
// Test: conversion attribute for directly inherited field with no value
public void testConversion1()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field */\n"+
" private String attr;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.modify-inherited name=\"attr\"\n"+
" * conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: removing conversion attribute for indirectly inherited field
public void testConversion2()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\" */\n"+
" private String attr;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"public class B extends A {}\n");
addClass(
"test.C",
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.modify-inherited name=\"attr\"\n"+
" * conversion=\"\"\n"+
" */\n"+
"public class C extends B {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.C\"/>\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.C\"\n"+
" table=\"C\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"C\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: invalid conversion attribute
public void testConversion3()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field */\n"+
" private String attr;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.modify-inherited name=\"attr\"\n"+
" * conversion=\"SomeConversion\"\n"+
" */\n"+
"public class B extends A {}\n");
assertNull(runOjbXDoclet(OJB_DEST_FILE));
assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: overriding pre-defined conversion attribute for directly inherited field
public void testConversion4()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field */\n"+
" private org.apache.ojb.broker.util.GUID attr;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.modify-inherited name=\"attr\"\n"+
" * conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"org.apache.ojb.broker.accesslayer.conversions.GUID2StringFieldConversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: overriding conversion attribute for directly inherited field with user-defined conversion class
public void testConversion5()
{
addClass(
"test.Conversion",
"package test;\n"+
"public class Conversion implements org.apache.ojb.broker.accesslayer.conversions.FieldConversion {\n"+
" public Object javaToSql(Object source) throws ConversionException { return source; }\n"+
" public Object sqlToJava(Object source) throws ConversionException { return source; }\n"+
"}\n");
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field jdbc-type=\"VARCHAR\"\n"+
" * conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" */\n"+
" private Object attr;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.modify-inherited name=\"attr\"\n"+
" * conversion=\"test.Conversion\"\n"+
" */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"org.apache.ojb.broker.accesslayer.conversions.Object2Base64StringFieldConversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attr\"\n"+
" column=\"attr\"\n"+
" jdbc-type=\"VARCHAR\"\n"+
" conversion=\"test.Conversion\"\n"+
" length=\"24\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attr\"\n"+
" javaName=\"attr\"\n"+
" type=\"VARCHAR\"\n"+
" size=\"24\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
}
1.1 db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ModifyInheritedTagIdAttributeTests.java
Index: ModifyInheritedTagIdAttributeTests.java
===================================================================
package xdoclet.modules.ojb.tests;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache ObjectRelationalBridge" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* Tests for the ojb.modify-inherited tag with the id attribute
*
* @author <a href="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
*/
public class ModifyInheritedTagIdAttributeTests extends OjbTestBase
{
public ModifyInheritedTagIdAttributeTests(String name)
{
super(name);
}
// Test: removing id attribute of inherited field
public void testId1()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field id=\"3\" */\n"+
" private int attrA;\n"+
"/** @ojb.field id=\"1\" */\n"+
" private int attrB;\n"+
"/** @ojb.field id=\"2\" */\n"+
" private int attrC;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n"+
" * @ojb.modify-inherited name=\"attrC\"\n"+
" * id=\"\"\n"+
" */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: adding id attribute to remotely inherited field
public void testId2()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field id=\"3\" */\n"+
" private int attrA;\n"+
"/** @ojb.field id=\"1\" */\n"+
" private int attrB;\n"+
"/** @ojb.field */\n"+
" private int attrC;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class */\n"+
"public class B extends A {}\n");
addClass(
"test.C",
"package test;\n"+
"/** @ojb.class\n"+
" * @ojb.modify-inherited name=\"attrC\"\n"+
" * id=\"2\"\n"+
" */\n"+
"public class C extends B {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <extent-class class-ref=\"test.C\"/>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.C\"\n"+
" table=\"C\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"C\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: invalid value
public void testId3()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field id=\"3\" */\n"+
" private int attrA;\n"+
"/** @ojb.field id=\"1\" */\n"+
" private int attrB;\n"+
"/** @ojb.field id=\"2\" */\n"+
" private int attrC;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n"+
" * @ojb.modify-inherited name=\"attrB\"\n"+
" * id=\"a\"\n"+
" */\n"+
"public class B extends A {}\n");
assertNull(runOjbXDoclet(OJB_DEST_FILE));
assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
// Test: changing id attribute of inherited field
public void testId4()
{
addClass(
"test.A",
"package test;\n"+
"/** @ojb.class */\n"+
"public class A {\n"+
"/** @ojb.field id=\"3\" */\n"+
" private int attrA;\n"+
"/** @ojb.field id=\"1\" */\n"+
" private int attrB;\n"+
"/** @ojb.field id=\"2\" */\n"+
" private int attrC;\n"+
"}\n");
addClass(
"test.B",
"package test;\n"+
"/** @ojb.class\n"+
" * @ojb.modify-inherited name=\"attrB\"\n"+
" * id=\"4\"\n"+
" */\n"+
"public class B extends A {}\n");
addClass(
"test.C",
"package test;\n"+
"/** @ojb.class */\n"+
"public class C extends B {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
" class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
" <extent-class class-ref=\"test.B\"/>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
" <extent-class class-ref=\"test.C\"/>\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
" class=\"test.C\"\n"+
" table=\"C\"\n"+
">\n"+
" <field-descriptor\n"+
" name=\"attrC\"\n"+
" column=\"attrC\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrA\"\n"+
" column=\"attrA\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
" <field-descriptor\n"+
" name=\"attrB\"\n"+
" column=\"attrB\"\n"+
" jdbc-type=\"INTEGER\"\n"+
" >\n"+
" </field-descriptor>\n"+
"</class-descriptor>",
runOjbXDoclet(OJB_DEST_FILE));
assertEqualsTorqueSchemaFile(
"<database name=\"ojbtest\">\n"+
" <table name=\"A\">\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"B\">\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
" <table name=\"C\">\n"+
" <column name=\"attrC\"\n"+
" javaName=\"attrC\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrA\"\n"+
" javaName=\"attrA\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" <column name=\"attrB\"\n"+
" javaName=\"attrB\"\n"+
" type=\"INTEGER\"\n"+
" />\n"+
" </table>\n"+
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
}
1.2 +0 -1 db-ojb/src/xdoclet/test/xdoclet/junit/XDocletTestBase.java
Index: XDocletTestBase.java
===================================================================
RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/junit/XDocletTestBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XDocletTestBase.java 15 Dec 2003 20:09:10 -0000 1.1
+++ XDocletTestBase.java 22 Dec 2003 10:11:53 -0000 1.2
@@ -58,7 +58,6 @@
import java.util.Iterator;
import junit.framework.TestCase;
-import junit.runner.TestCaseClassLoader;
/**
* Base class for xdoclet test cases.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org