Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,136 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import java.math.BigDecimal; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBigDecimal; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type BigDecimal. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-19. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.math.BigDecimal</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfBigDecimal extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-19 (TestFieldsOfBigDecimal) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBigDecimal.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + BigDecimal firstValue = new BigDecimal("20079.0237"); + BigDecimal secondValue = new BigDecimal("8907489.658"); + int ret = 0; + tx.begin(); + FieldsOfBigDecimal pi = new FieldsOfBigDecimal(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, BigDecimal startValue){ + int ret = 0; + int i; + BigDecimal value; + FieldsOfBigDecimal pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i){ + if( !FieldsOfBigDecimal.isPersistent[i] ) continue; + BigDecimal val = pi.get(i); + if(!val.equals(value)){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBigDecimal.fieldSpecs[i] + + ", expected value " + value.toString() + + ", value is " + val.toString()); + } + } + } +}
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,136 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import java.math.BigInteger; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBigInteger; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type BigInteger. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-20. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.math.BigInteger</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfBigInteger extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-20 (TestFieldsOfBigInteger) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBigInteger.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + BigInteger firstValue = new BigInteger("2007908"); + BigInteger secondValue = new BigInteger("896738"); + tx.begin(); + FieldsOfBigInteger pi = new FieldsOfBigInteger(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, BigInteger startValue){ + int ret = 0; + int i; + BigInteger value = startValue; + FieldsOfBigInteger pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfBigInteger.isPersistent[i] ) + continue; + BigInteger val = pi.get(i); + if(!val.equals(value) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBigInteger.fieldSpecs[i] + + ", expected value " + value.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,132 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBoolean; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Boolean. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-9. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.lang.Boolean</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfBoolean extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-9 (TestFieldsOfBoolean) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBoolean.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Boolean firstValue = new Boolean(true); + Boolean secondValue = new Boolean(false); + tx.begin(); + FieldsOfBoolean pi = new FieldsOfBoolean(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfBoolean) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfBoolean) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Boolean startValue){ + int i; + FieldsOfBoolean pi = (FieldsOfBoolean) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfBoolean.isPersistent[i] ) + continue; + Boolean val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBoolean.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,133 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfByte; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Byte. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-11. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.lang.Byte</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + + +public class TestFieldsOfByte extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-11 (TestFieldsOfByte) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfByte.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Byte firstValue = new Byte((byte)Byte.MIN_VALUE); + Byte secondValue = new Byte((byte)Byte.MAX_VALUE); + tx.begin(); + FieldsOfByte pi = new FieldsOfByte(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfByte) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfByte) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Byte startValue){ + int i; + FieldsOfByte pi = (FieldsOfByte) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfByte.isPersistent[i] ) + continue; + Byte val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfByte.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,133 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfCharacter; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Character. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-10. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.lang.Character</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + + +public class TestFieldsOfCharacter extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-10 (TestFieldsOfCharacter) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfCharacter.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Character firstValue = new Character((char)Character.MIN_VALUE); + Character secondValue = new Character((char)Character.MAX_VALUE); + tx.begin(); + FieldsOfCharacter pi = new FieldsOfCharacter(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfCharacter) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfCharacter) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Character startValue){ + int i; + FieldsOfCharacter pi = (FieldsOfCharacter) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfCharacter.isPersistent[i] ) + continue; + Character val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfCharacter.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,133 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import java.util.Date; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfDate; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Date. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-21. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the mutable object class + <code>java.util.Date</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfDate extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-21 (TestFieldsOfDate) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfDate.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Date firstValue = new Date(2007908); + Date secondValue = new Date(890748967382l); + tx.begin(); + FieldsOfDate pi = new FieldsOfDate(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfDate) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfDate) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Date startValue){ + int i; + FieldsOfDate pi = (FieldsOfDate) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfDate.isPersistent[i] ) continue; + Date val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfDate.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,131 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfDouble; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Double. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-16. + *<BR> + *<B>Assertion Description: </B> + JDO implementations must support fields of the immutable object class + <code>java.lang.Double</code>, and may choose to support them as + Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfDouble extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-16 (TestFieldsOfDouble) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfDouble.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Double firstValue = new Double(Double.MIN_VALUE); + Double secondValue = new Double(Double.MAX_VALUE); + tx.begin(); + FieldsOfDouble pi = new FieldsOfDouble(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfDouble) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfDouble) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Double startValue){ + int i; + FieldsOfDouble pi = (FieldsOfDouble) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfDouble.isPersistent[i] ) continue; + Double val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfDouble.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,133 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfFloat; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Float. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-15. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the immutable object class +<code>java.lang.Float</code>, and may choose to support them as +Second Class Objects or First Class Objects. + */ + + +public class TestFieldsOfFloat extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-15 (TestFieldsOfFloat) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfFloat.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Float firstValue = new Float(Float.MIN_VALUE); + Float secondValue = new Float(Float.MAX_VALUE); + tx.begin(); + FieldsOfFloat pi = new FieldsOfFloat(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfFloat) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfFloat) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Float startValue){ + int i; + FieldsOfFloat pi = (FieldsOfFloat) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfFloat.isPersistent[i] ) continue; + Float val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfFloat.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,131 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfInteger; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Integer. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-13. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the immutable object class +<code>java.lang.Integer</code>, and may choose to support them as +Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfInteger extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-13 (TestFieldsOfInteger) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfInteger.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Integer firstValue = new Integer(Integer.MIN_VALUE); + Integer secondValue = new Integer(Integer.MAX_VALUE); + tx.begin(); + FieldsOfInteger pi = new FieldsOfInteger(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfInteger) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfInteger) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Integer startValue){ + int i; + FieldsOfInteger pi = (FieldsOfInteger) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfInteger.isPersistent[i] ) continue; + Integer val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfInteger.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,134 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import java.util.Locale; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfLocale; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Locale. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-18. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the immutable object class +<code>java.util.Locale</code>, and may choose to support them as +Second Class Objects or First Class Objects. + */ + +public class TestFieldsOfLocale extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-18 (TestFieldsOfLocale) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfLocale.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Locale firstValue = Locale.CHINA; + Locale secondValue = Locale.JAPANESE; + tx.begin(); + FieldsOfLocale pi = new FieldsOfLocale(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfLocale) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfLocale) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Locale startValue){ + int i; + Locale value; + FieldsOfLocale pi = (FieldsOfLocale) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfLocale.isPersistent[i] ) continue; + Locale val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfLocale.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,132 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfLong; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Long. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-14. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the immutable object class +<code>java.lang.Long</code>, and may choose to support them as +Second Class Objects or First Class Objects. + */ + + +public class TestFieldsOfLong extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-14 (TestFieldsOfLong) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfLong.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Long firstValue = new Long(Long.MIN_VALUE); + Long secondValue = new Long(Long.MAX_VALUE); + tx.begin(); + FieldsOfLong pi = new FieldsOfLong(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfLong) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfLong) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Long startValue){ + int i; + FieldsOfLong pi = (FieldsOfLong) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfLong.isPersistent[i] ) continue; + Long val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfLong.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,133 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfObject; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type Object. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-31. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of <code>Object</code> class type +as First Class Objects. The implementation is permitted, but is not required, +to allow any class to be assigned to the field. If an implementation restricts +instances to be assigned to the field, a <code>ClassCastException</code> +must be thrown at the time of any incorrect assignment. + */ + + +public class TestFieldsOfObject extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-31 (TestFieldsOfObject) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfObject.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + Object firstValue = new String("Hello"); + Object secondValue = new Integer("420"); + tx.begin(); + FieldsOfObject pi = new FieldsOfObject(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + pi = (FieldsOfObject) pm.getObjectById(oid, true); + checkValues(oid, firstValue); // check if persistent fields have values set + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + pi = (FieldsOfObject) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, Object startValue){ + int i; + FieldsOfObject pi = (FieldsOfObject) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfObject.isPersistent[i] ) continue; + Object val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfObject.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,128 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveboolean; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type boolean. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-1. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>boolean</code>. + */ + +public class TestFieldsOfPrimitiveboolean extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-1 (TestFieldsOfPrimitiveboolean) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitiveboolean.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + boolean value; + tx.begin(); + FieldsOfPrimitiveboolean pi = new FieldsOfPrimitiveboolean(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = true; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); + checkValues(oid, true); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = false; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, false); + pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, boolean startValue){ + int i; + FieldsOfPrimitiveboolean pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitiveboolean.isPersistent[i] ) continue; + boolean val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitiveboolean.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,129 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivebyte; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type byte. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-2. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>int</code>. + */ + + +public class TestFieldsOfPrimitivebyte extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-2 (TestFieldsOfPrimitivebyte) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivebyte.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + byte value; + tx.begin(); + FieldsOfPrimitivebyte pi = new FieldsOfPrimitivebyte(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 10; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); + checkValues(oid, (byte)10); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = 127; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, (byte)127); + pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, byte startValue){ + int i; + FieldsOfPrimitivebyte pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivebyte.isPersistent[i] ) continue; + byte val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitivebyte.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,129 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivechar; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type char. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-6. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>char</code>. + */ + + +public class TestFieldsOfPrimitivechar extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-6 (TestFieldsOfPrimitivechar) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivechar.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + char value; + tx.begin(); + FieldsOfPrimitivechar pi = new FieldsOfPrimitivechar(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 'a'; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); + checkValues(oid, 'a'); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = 'Z'; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, 'Z'); + pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, char startValue){ + int i; + FieldsOfPrimitivechar pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivechar.isPersistent[i] ) continue; + char val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitivechar.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,129 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivedouble; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type double. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-8. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>double</code>. + */ + + +public class TestFieldsOfPrimitivedouble extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-8 (TestFieldsOfPrimitivedouble) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivedouble.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + double value; + tx.begin(); + FieldsOfPrimitivedouble pi = new FieldsOfPrimitivedouble(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = (double)10.15; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); + checkValues(oid, (double)10.15); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = (double)68000.15; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, (double)68000.15); + pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, double startValue){ + int i; + FieldsOfPrimitivedouble pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivedouble.isPersistent[i] ) continue; + double val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitivedouble.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,129 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivefloat; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type float. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-7. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>float</code>. + */ + + +public class TestFieldsOfPrimitivefloat extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-7 (TestFieldsOfPrimitivefloat) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivefloat.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + float value; + tx.begin(); + FieldsOfPrimitivefloat pi = new FieldsOfPrimitivefloat(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = (float)10.15; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); + checkValues(oid, (float)10.15); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = (float)33000.15; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, (float)33000.15); + pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, float startValue){ + int i; + FieldsOfPrimitivefloat pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivefloat.isPersistent[i] ) continue; + float val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitivefloat.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,127 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type int. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-4. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>int</code>. + */ + + +public class TestFieldsOfPrimitiveint extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-4 (TestFieldsOfPrimitiveint) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitiveint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n, value; + tx.begin(); + FieldsOfPrimitiveint pi = new FieldsOfPrimitiveint(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 0; i < n; ++i, ++value ){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); + checkValues(oid, 0); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = 1000; i < n; ++i, ++value ){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, 1000); + pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, int startValue){ + int i, value; + FieldsOfPrimitiveint pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i, ++value){ + if( !FieldsOfPrimitiveint.isPersistent[i] ) continue; + int val = pi.get(i); + if( val != value ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitiveint.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,130 @@ +/* + * Copyright 2005 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.jdo.tck.models.fieldtypes; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivelong; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Support of field type long. + *<BR> + *<B>Keywords:</B> model + *<BR> + *<B>Assertion ID:</B> A6.4.3-5. + *<BR> + *<B>Assertion Description: </B> +JDO implementations must support fields of the primitive type <code>long</code>. + */ + + +public class TestFieldsOfPrimitivelong extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-5 (TestFieldsOfPrimitivelong) failed: "; + + /** + * The <code>main</code> is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivelong.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + try { + int i, n; + long value; + tx.begin(); + FieldsOfPrimitivelong pi = new FieldsOfPrimitivelong(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 10; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); + checkValues(oid, 10); // check if persistent fields have values set + + // Provide new set of values + for( i = 0, value = 67000; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, 67000); + pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); + pm.deletePersistent(pi); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void checkValues(Object oid, long startValue){ + int i; + long value; + FieldsOfPrimitivelong pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivelong.isPersistent[i] ) continue; + long val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfPrimitivelong.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } + } +}