Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCArrays.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCArrays.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCArrays.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCArrays.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,642 @@ +/* + * 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.pc; + +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Vector; + +import org.apache.jdo.test.util.Util; + +/** +* Contains 3 arrays of each supported type: one with elements, one without, +* and one whose reference is null +* +* @author Dave Bristor +*/ +public class PCArrays { + // boolean + public boolean _booleanArray[]; + public boolean _emptyBooleanArray[]; + public boolean _nullBooleanArray[]; + + public Boolean _lang_BooleanArray[]; + public Boolean _empty_lang_BooleanArray[]; + public Boolean _null_lang_BooleanArray[]; + + // char + public char _charArray[]; + public char _emptyCharArray[]; + public char _nullCharArray[]; + + public Character _lang_CharacterArray[]; + public Character _empty_lang_CharacterArray[]; + public Character _null_lang_CharacterArray[]; + + // byte + public byte _byteArray[]; + public byte _emptyByteArray[]; + public byte _nullByteArray[]; + + public Byte _lang_ByteArray[]; + public Byte _empty_lang_ByteArray[]; + public Byte _null_lang_ByteArray[]; + + // short + public short _shortArray[]; + public short _emptyShortArray[]; + public short _nullShortArray[]; + + public Short _lang_ShortArray[]; + public Short _empty_lang_ShortArray[]; + public Short _null_lang_ShortArray[]; + + // int + public int _intArray[]; + public int _emptyIntArray[]; + public int _nullIntArray[]; + + public Integer _lang_IntegerArray[]; + public Integer _empty_lang_IntegerArray[]; + public Integer _null_lang_IntegerArray[]; + + // long + public long _longArray[]; + public long _emptyLongArray[]; + public long _nullLongArray[]; + + public Long _lang_LongArray[]; + public Long _empty_lang_LongArray[]; + public Long _null_lang_LongArray[]; + + // float + public float _floatArray[]; + public float _emptyFloatArray[]; + public float _nullFloatArray[]; + + public Float _lang_FloatArray[]; + public Float _empty_lang_FloatArray[]; + public Float _null_lang_FloatArray[]; + + // double + public double _doubleArray[]; + public double _emptyDoubleArray[]; + public double _nullDoubleArray[]; + + public Double _lang_DoubleArray[]; + public Double _empty_lang_DoubleArray[]; + public Double _null_lang_DoubleArray[]; + + // String + public String _stringArray[]; + public String _emptyStringArray[]; + public String _nullStringArray[]; + + private final Date date; + + private static final BigDecimal bigDecimal = new BigDecimal(3.14159); + private static final BigInteger bigInteger = new + BigInteger("12345678998765432112345"); + private static final Locale locale = new Locale("fr", "CA", "MAC"); + + // Date + public Date _dateArray[]; + public Date _emptyDateArray[]; + public Date _nullDateArray[]; + + // BigDecimal + public BigDecimal _bigDecimalArray[]; + public BigDecimal _emptyBigDecimalArray[]; + public BigDecimal _nullBigDecimalArray[]; + + // BigInteger + public BigInteger _bigIntegerArray[]; + public BigInteger _emptyBigIntegerArray[]; + public BigInteger _nullBigIntegerArray[]; + + // Locale + public Locale _localeArray[]; + public Locale _emptyLocaleArray[]; + public Locale _nullLocaleArray[]; + + // ArrayList + public ArrayList _arrayListArray[]; + public ArrayList _emptyArrayListArray[]; + public ArrayList _nullArrayListArray[]; + + // HashMap + public HashMap _hashMapArray[]; + public HashMap _emptyHashMapArray[]; + public HashMap _nullHashMapArray[]; + + // HashSet + public HashSet _hashSetArray[]; + public HashSet _emptyHashSetArray[]; + public HashSet _nullHashSetArray[]; + + // Hashtable + public Hashtable _hashtableArray[]; + public Hashtable _emptyHashtableArray[]; + public Hashtable _nullHashtableArray[]; + + // LinkedList + public LinkedList _linkedListArray[]; + public LinkedList _emptyLinkedListArray[]; + public LinkedList _nullLinkedListArray[]; + + // TreeMap + public TreeMap _treeMapArray[]; + public TreeMap _emptyTreeMapArray[]; + public TreeMap _nullTreeMapArray[]; + + // TreeSet + public TreeSet _treeSetArray[]; + public TreeSet _emptyTreeSetArray[]; + public TreeSet _nullTreeSetArray[]; + + // Vector + public Vector _vectorArray[]; + public Vector _emptyVectorArray[]; + public Vector _nullVectorArray[]; + + public PCArrays() { + date = Util.moonWalkDate.getTime(); + } + + // Create some arrays with "interesting" values. + // + public void init() { + // boolean + _booleanArray = new boolean[] { true, false, true, false}; + _emptyBooleanArray = new boolean[0]; + _nullBooleanArray = null; + + _lang_BooleanArray = new Boolean[] { + new Boolean(true), new Boolean(true), new Boolean(false), new Boolean(false)}; + _empty_lang_BooleanArray = new Boolean[0]; + _null_lang_BooleanArray = null; + + // char + _charArray = new char[] { 'h', 'e', 'l', 'l', 'o' }; + _emptyCharArray = new char[0]; + _nullCharArray = null; + + _lang_CharacterArray = new Character[] { + new Character('w'), new Character('o'), new Character('r'), + new Character('l'), new Character('d') }; + _empty_lang_CharacterArray = new Character[0]; + _null_lang_CharacterArray = null; + + // byte + _byteArray = new byte[] { 0xf, 0xe, 0xd, 0xc, 0xb, 0xa }; + _emptyByteArray = new byte[0]; + _nullByteArray = null; + + _lang_ByteArray = new Byte[] { + new Byte((byte)0xa), new Byte((byte)0xb), new Byte((byte)0xc), new + Byte((byte)0xd), new Byte((byte)0xe), new Byte((byte)0xf) }; + _empty_lang_ByteArray = new Byte[0]; + _null_lang_ByteArray = null; + + // short + _shortArray = new short[] { 10, 20, 30, 40 }; + _emptyShortArray = new short[0]; + _nullShortArray = null; + + _lang_ShortArray = new Short[] { + new Short((short)10), new Short((short)9), new Short((short)8), + new Short((short)7), new Short((short)6) }; + _empty_lang_ShortArray = new Short[0]; + _null_lang_ShortArray = null; + + // int + _intArray = new int[] { 1, 3, 5 }; + _emptyIntArray = new int[0]; + _nullIntArray = null; + + _lang_IntegerArray = new Integer[] { + new Integer(2), new Integer(4), new Integer(6) }; + _empty_lang_IntegerArray = new Integer[0]; + _null_lang_IntegerArray = null; + + // long + _longArray = new long[] { Long.MIN_VALUE, 0L, Long.MAX_VALUE }; + _emptyLongArray = new long[0]; + _nullLongArray = null; + + _lang_LongArray = new Long[] { + new Long(-2), new Long(-1), new Long(0), new Long(1), new Long(2) }; + _empty_lang_LongArray = new Long[0]; + _null_lang_LongArray = null; + + // float + _floatArray = new float[] { 6.02e+23f, 3.14159f, 186000.0f }; + _emptyFloatArray = new float[0]; + _nullFloatArray = null; + + _lang_FloatArray = new Float[] { + new Float(3.14159f), new Float(6.02e+23f), new Float(186000.0f) }; + _empty_lang_FloatArray = new Float[0]; + _null_lang_FloatArray = null; + + // double + _doubleArray = new double[] { 0.0, 1.0, 2.0 }; + _emptyDoubleArray = new double[0]; + _nullDoubleArray = null; + + _lang_DoubleArray = new Double[] { + new Double(3.333), new Double(5.55555), new Double(7.7777777) }; + _empty_lang_DoubleArray = new Double[0]; + _null_lang_DoubleArray = null; + + // String + _stringArray = new String[] { "hello", "world", "hi", "mom" }; + _emptyStringArray = new String[0]; + _nullStringArray = null; + + // Date + _dateArray = new Date[] { date, date }; + _emptyDateArray = new Date[0]; + _nullDateArray = null; + + // BigDecimal + _bigDecimalArray = new BigDecimal[] { + new BigDecimal(3.1415), new BigDecimal(6.02e+23) }; + _emptyBigDecimalArray = new BigDecimal[0]; + _nullBigDecimalArray = null; + + // BigInteger + _bigIntegerArray = new BigInteger[] { + new BigInteger("123456789"), new BigInteger("987654321") }; + _emptyBigIntegerArray = new BigInteger[0]; + _nullBigIntegerArray = null; + + // Locale + _localeArray = new Locale[] { locale, locale, locale }; + _emptyLocaleArray = new Locale[0]; + _nullLocaleArray = null; + + // ArrayList + _arrayListArray = new ArrayList[2]; + ArrayList al = new ArrayList(); + al.add("hello"); + al.add(new Double(3.14159)); + _arrayListArray[0] = al; + + al = new ArrayList(); + al.add(new Integer(42)); + al.add(new Boolean(true)); + al.add(new Byte((byte)0xd)); + _arrayListArray[1] = al; + + _emptyArrayListArray = new ArrayList[0]; + _nullArrayListArray = null; + + // HashMap + _hashMapArray = new HashMap[2]; + HashMap hm = new HashMap(); + hm.put(new Character('d'), "d is 13"); + hm.put("wombat", bigDecimal); + _hashMapArray[0] = hm; + + hm = new HashMap(); + hm.put(new Integer(1), new Integer(42)); + hm.put(new Double(3.14159), new Float(6.02e+23)); + _hashMapArray[1] = hm; + + _emptyHashMapArray = new HashMap[0]; + _nullHashMapArray = null; + + // HashSet + _hashSetArray = new HashSet[3]; + HashSet hs = new HashSet(); + hs.add("home, home on the range..."); + hs.add(new Character('J')); + _hashSetArray[0] = hs; + + hs = new HashSet(); + hs.add(new Double(3.0e+6)); + hs.add(new Integer(13)); + _hashSetArray[1] = hs; + + hs = new HashSet(); + hs.add(new Float(6.02e+23)); + hs.add("when I was back there in seminary school, ..."); + _hashSetArray[2] = hs; + + _emptyHashSetArray = new HashSet[0]; + _nullHashSetArray = null; + + // Hashtable + _hashtableArray = new Hashtable[2]; + Hashtable ht = new Hashtable(); + ht.put(new Character('d'), "d is 13"); + ht.put("wombat", bigDecimal); + _hashtableArray[0] = ht; + + ht = new Hashtable(); + ht.put(new Integer(1), new Integer(42)); + ht.put(new Double(3.14159), new Float(6.02e+23)); + _hashtableArray[1] = ht; + + _emptyHashtableArray = new Hashtable[0]; + _nullHashtableArray = null; + + // LinkedList + _linkedListArray = new LinkedList[2]; + LinkedList ll = new LinkedList(); + ll.add("'hello, world'"); + ll.add(new Double(1234.56789)); + _linkedListArray[0] = ll; + + ll = new LinkedList(); + ll.add(new Integer(9876)); + _linkedListArray[1] = ll; + + _emptyLinkedListArray = new LinkedList[0]; + _nullLinkedListArray = null; + + + // TreeMap + _treeMapArray = new TreeMap[2]; + TreeMap tm = new TreeMap(); + tm.put(new Double(6.02e+23), new Integer(42)); + tm.put(new Double(3.14159), new Float(6.02e+23)); + _treeMapArray[0] = tm; + + tm = new TreeMap(); + tm.put(new Double(186000), "d is 13"); + _treeMapArray[1] = tm; + + _emptyTreeMapArray = new TreeMap[0]; + _nullTreeMapArray = null; + + // TreeSet + _treeSetArray = new TreeSet[2]; + TreeSet ts = new TreeSet(); + ts.add(new Double(6.02e+23)); + ts.add(new Double(3.14159)); + _treeSetArray[0] = ts; + + ts = new TreeSet(); + ts.add(new Double(186000)); + _treeSetArray[1] = ts; + + _emptyTreeSetArray = new TreeSet[0]; + _nullTreeSetArray = null; + + // Vector + _vectorArray = new Vector[3]; + Vector v = new Vector(); + v.addElement(new Byte((byte)13)); + v.addElement(new Boolean(true)); + _vectorArray[0] = v; + + v = new Vector(); + v.addElement("Call me Ishmael."); + v.addElement(new Boolean(false)); + _vectorArray[1] = v; + + v = new Vector(); + v.add("four score and twenty beers ago"); + v.add(new Double(0.0102030508)); + _vectorArray[2] = v; + + _emptyVectorArray = new Vector[0]; + _nullVectorArray = null; + } + + String stringify(Object arr, String name) { + StringBuffer rc =new StringBuffer("\n").append(name).append(": "); + + if (null == arr) { + rc.append(" __null__"); + } else try { + int length = Array.getLength(arr); + if (0 == length) { + rc.append(" __empty__"); + } else { + for (int i = 0; i < length; i++) { + if (i > 0) { + rc.append(","); + } + rc.append(" "); + Object obj = Array.get(arr, i); + if (obj instanceof Date) { + rc.append(Util.longFormatter.format((Date)obj)); + } else if (obj instanceof Map) { + rc.append(Util.sortMap((Map)obj)); + } else { + rc.append(obj); + } + } + } + } catch (IllegalArgumentException ex) { + throw new RuntimeException("illegal argument: " + arr.getClass().getName()); + } catch (ArrayIndexOutOfBoundsException ex) { + throw new RuntimeException("out of bounds: " + arr.getClass().getName()); + } + + return rc.toString(); + } + + public String toString() { + StringBuffer rc = new StringBuffer(Util.getClassName(this)); + + // boolean + rc.append(stringify(_booleanArray, "_booleanArray")); + rc.append(stringify(_emptyBooleanArray, "_emptyBooleanArray")); + rc.append(stringify(_nullBooleanArray, "_nullBooleanArray")); + rc.append("\n"); + + rc.append(stringify(_lang_BooleanArray, "_lang_BooleanArray")); + rc.append(stringify(_empty_lang_BooleanArray, "_empty_lang_BooleanArray")); + rc.append(stringify(_null_lang_BooleanArray, "_null_lang_BooleanArray")); + rc.append("\n"); + + // char + rc.append(stringify(_charArray, "_charArray")); + rc.append(stringify(_emptyCharArray, "_emptyCharArray")); + rc.append(stringify(_nullCharArray, "_nullCharArray")); + rc.append("\n"); + + rc.append(stringify(_lang_CharacterArray, "_lang_CharacterArray")); + rc.append(stringify(_empty_lang_CharacterArray, "_empty_lang_CharacterArray")); + rc.append(stringify(_null_lang_CharacterArray, "_null_lang_CharacterArray")); + rc.append("\n"); + + // byte + rc.append(stringify(_byteArray, "_byteArray")); + rc.append(stringify(_emptyByteArray, "_emptyByteArray")); + rc.append(stringify(_nullByteArray, "_nullByteArray")); + rc.append("\n"); + + rc.append(stringify(_lang_ByteArray, "_lang_ByteArray")); + rc.append(stringify(_empty_lang_ByteArray, "_empty_lang_ByteArray")); + rc.append(stringify(_null_lang_ByteArray, "_null_lang_ByteArray")); + rc.append("\n"); + + // short + rc.append(stringify(_shortArray, "_shortArray")); + rc.append(stringify(_emptyShortArray, "_emptyShortArray")); + rc.append(stringify(_nullShortArray, "_nullShortArray")); + rc.append("\n"); + + rc.append(stringify(_lang_ShortArray, "_lang_ShortArray")); + rc.append(stringify(_empty_lang_ShortArray, "_empty_lang_ShortArray")); + rc.append(stringify(_null_lang_ShortArray, "_null_lang_ShortArray")); + rc.append("\n"); + + // int + rc.append(stringify(_intArray, "_intArray")); + rc.append(stringify(_emptyIntArray, "_emptyIntArray")); + rc.append(stringify(_nullIntArray, "_nullIntArray")); + rc.append("\n"); + + rc.append(stringify(_lang_IntegerArray, "_lang_IntegerArray")); + rc.append(stringify(_empty_lang_IntegerArray, "_empty_lang_IntegerArray")); + rc.append(stringify(_null_lang_IntegerArray, "_null_lang_IntegerArray")); + rc.append("\n"); + + // long + rc.append(stringify(_longArray, "_longArray")); + rc.append(stringify(_emptyLongArray, "_emptyLongArray")); + rc.append(stringify(_nullLongArray, "_nullLongArray")); + rc.append("\n"); + + rc.append(stringify(_lang_LongArray, "_lang_LongArray")); + rc.append(stringify(_empty_lang_LongArray, "_empty_lang_LongArray")); + rc.append(stringify(_null_lang_LongArray, "_null_lang_LongArray")); + rc.append("\n"); + + // float + rc.append(stringify(_floatArray, "_floatArray")); + rc.append(stringify(_emptyFloatArray, "_emptyFloatArray")); + rc.append(stringify(_nullFloatArray, "_nullFloatArray")); + rc.append("\n"); + + rc.append(stringify(_lang_FloatArray, "_lang_FloatArray")); + rc.append(stringify(_empty_lang_FloatArray, "_empty_lang_FloatArray")); + rc.append(stringify(_null_lang_FloatArray, "_null_lang_FloatArray")); + rc.append("\n"); + + // double + rc.append(stringify(_doubleArray, "_doubleArray")); + rc.append(stringify(_emptyDoubleArray, "_emptyDoubleArray")); + rc.append(stringify(_nullDoubleArray, "_nullDoubleArray")); + rc.append("\n"); + + rc.append(stringify(_lang_DoubleArray, "_lang_DoubleArray")); + rc.append(stringify(_empty_lang_DoubleArray, "_empty_lang_DoubleArray")); + rc.append(stringify(_null_lang_DoubleArray, "_null_lang_DoubleArray")); + rc.append("\n"); + + // String + rc.append(stringify(_stringArray, "_stringArray")); + rc.append(stringify(_emptyStringArray, "_emptyStringArray")); + rc.append(stringify(_nullStringArray, "_nullStringArray")); + rc.append("\n"); + + // Date + rc.append(stringify(_dateArray, "_dateArray")); + rc.append(stringify(_emptyDateArray, "_emptyDateArray")); + rc.append(stringify(_nullDateArray, "_nullDateArray")); + rc.append("\n"); + + // BigDecimal + rc.append(stringify(_bigDecimalArray, "_bigDecimalArray")); + rc.append(stringify(_emptyBigDecimalArray, "_emptyBigDecimalArray")); + rc.append(stringify(_nullBigDecimalArray, "_nullBigDecimalArray")); + rc.append("\n"); + + // BigInteger + rc.append(stringify(_bigIntegerArray, "_bigIntegerArray")); + rc.append(stringify(_emptyBigIntegerArray, "_emptyBigIntegerArray")); + rc.append(stringify(_nullBigIntegerArray, "_nullBigIntegerArray")); + rc.append("\n"); + + // Locale + rc.append(stringify(_localeArray, "_localeArray")); + rc.append(stringify(_emptyLocaleArray, "_emptyLocaleArray")); + rc.append(stringify(_nullLocaleArray, "_nullLocaleArray")); + rc.append("\n"); + + // ArrayList + rc.append(stringify(_arrayListArray, "_arrayListArray")); + rc.append(stringify(_emptyArrayListArray, "_emptyArrayListArray")); + rc.append(stringify(_nullArrayListArray, "_nullArrayListArray")); + rc.append("\n"); + + // HashMap + rc.append(stringify(_hashMapArray, "_hashMapArray")); + rc.append(stringify(_emptyHashMapArray, "_emptyHashMapArray")); + rc.append(stringify(_nullHashMapArray, "_nullHashMapArray")); + rc.append("\n"); + + // HashSet + rc.append(stringify(_hashSetArray, "_hashSetArray")); + rc.append(stringify(_emptyHashSetArray, "_emptyHashSetArray")); + rc.append(stringify(_nullHashSetArray, "_nullHashSetArray")); + rc.append("\n"); + + // Hashtable + rc.append(stringify(_hashtableArray, "_hashtableArray")); + rc.append(stringify(_emptyHashtableArray, "_emptyHashtableArray")); + rc.append(stringify(_nullHashtableArray, "_nullHashtableArray")); + rc.append("\n"); + + // LinkedList + rc.append(stringify(_linkedListArray, "_linkedListArray")); + rc.append(stringify(_emptyLinkedListArray, "_emptyLinkedListArray")); + rc.append(stringify(_nullLinkedListArray, "_nullLinkedListArray")); + rc.append("\n"); + + // TreeMap + rc.append(stringify(_treeMapArray, "_treeMapArray")); + rc.append(stringify(_emptyTreeMapArray, "_emptyTreeMapArray")); + rc.append(stringify(_nullTreeMapArray, "_nullTreeMapArray")); + rc.append("\n"); + + // TreeSet + rc.append(stringify(_treeSetArray, "_treeSetArray")); + rc.append(stringify(_emptyTreeSetArray, "_emptyTreeSetArray")); + rc.append(stringify(_nullTreeSetArray, "_nullTreeSetArray")); + rc.append("\n"); + + // Vector + rc.append(stringify(_vectorArray, "_vectorArray")); + rc.append(stringify(_emptyVectorArray, "_emptyVectorArray")); + rc.append(stringify(_nullVectorArray, "_nullVectorArray")); + rc.append("\n"); + + return rc.toString(); + } +}
Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCBase.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCBase.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCBase.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCBase.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,23 @@ +/* + * 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.pc; + +public class PCBase { + public String s; + + public PCBase() { } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollection.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollection.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollection.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollection.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,69 @@ +/* + * 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.pc; + +import javax.jdo.spi.PersistenceCapable; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +/** + * Represents a PC type that holds a Set and Map of PC instances. + * @version 1.0.1 + */ +public class PCCollection { + private int id; + private Set set; + private Map map; + + public PCCollection() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Set getSet() { + return set; + } + + public void setSet(Set set) { + this.set = set; + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + public String toString() { + return "PCCollection:" + id + " Set (" + (set==null?"null":String.valueOf(set.size())) + + ") Map (" + (map==null?"null":String.valueOf(map.size())) + ")"; + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollections.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollections.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollections.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCollections.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,593 @@ +/* + * 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.pc; + +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Vector; + +import org.apache.jdo.test.util.Util; + + +/** +* Test ability to store & fetch instances of various collections. This class +* provides three fields for each type of collection we can store: one which +* has values, one which is empty, and one which represents the field being +* null. +* +* @author Dave Bristor +*/ +public class PCCollections { + public java.util.ArrayList _arrayList; + public java.util.ArrayList _emptyArrayList; + public java.util.ArrayList _nullArrayList; + + public java.util.ArrayList _sco_arrayList; + public java.util.ArrayList _sco_emptyArrayList; + public java.util.ArrayList _sco_nullArrayList; + + public java.util.Vector _vector; + public java.util.Vector _emptyVector; + public java.util.Vector _nullVector; + + public java.util.Vector _sco_vector; + public java.util.Vector _sco_emptyVector; + public java.util.Vector _sco_nullVector; + + public java.util.HashMap _hashMap; + public java.util.HashMap _emptyHashMap; + public java.util.HashMap _nullHashMap; + + public java.util.HashMap _sco_hashMap; + public java.util.HashMap _sco_emptyHashMap; + public java.util.HashMap _sco_nullHashMap; + + public java.util.Hashtable _hashtable; + public java.util.Hashtable _emptyHashtable; + public java.util.Hashtable _nullHashtable; + + public java.util.Hashtable _sco_hashtable; + public java.util.Hashtable _sco_emptyHashtable; + public java.util.Hashtable _sco_nullHashtable; + + public java.util.HashSet _hashSet; + public java.util.HashSet _emptyHashSet; + public java.util.HashSet _nullHashSet; + + public java.util.HashSet _sco_hashSet; + public java.util.HashSet _sco_emptyHashSet; + public java.util.HashSet _sco_nullHashSet; + + public java.util.LinkedList _linkedList; + public java.util.LinkedList _emptyLinkedList; + public java.util.LinkedList _nullLinkedList; + + public java.util.LinkedList _sco_linkedList; + public java.util.LinkedList _sco_emptyLinkedList; + public java.util.LinkedList _sco_nullLinkedList; + + public java.util.TreeMap _treeMap; + public java.util.TreeMap _emptyTreeMap; + public java.util.TreeMap _nullTreeMap; + + public java.util.TreeMap _sco_treeMap; + public java.util.TreeMap _sco_emptyTreeMap; + public java.util.TreeMap _sco_nullTreeMap; + + public java.util.TreeSet _treeSet; + public java.util.TreeSet _emptyTreeSet; + public java.util.TreeSet _nullTreeSet; + + public java.util.TreeSet _sco_treeSet; + public java.util.TreeSet _sco_emptyTreeSet; + public java.util.TreeSet _sco_nullTreeSet; + + private final Date date; + + private static final BigDecimal bigDecimal = new BigDecimal(3.14159); + private static final BigInteger bigInteger = new + BigInteger("12345678998765432112345"); + private static final Locale locale = new Locale("fr", "CA", "MAC"); + + public PCCollections() { + date = Util.moonWalkDate.getTime(); + } + + // get methods for SCO types. + + public java.util.ArrayList getSCOArrayList() { + return _sco_arrayList; + } + + public java.util.Vector getSCOVector() { + return _sco_vector; + } + + public java.util.TreeSet getSCOTreeSet() { + return _sco_treeSet; + } + + public java.util.HashSet getSCOHashSet() { + return _sco_hashSet; + } + + public java.util.LinkedList getSCOLinkedList() { + return _sco_linkedList; + } + + public java.util.HashMap getSCOHashMap() { + return _sco_hashMap; + } + + public java.util.Hashtable getSCOHashtable() { + return _sco_hashtable; + } + + public java.util.TreeMap getSCOTreeMap() { + return _sco_treeMap; + } + + // + // Notice the method pairs below, and that the first invokes the second. + // In fact, once enhanced, the first will invoke the *enhanced* version of + // the second, as defined in PCCollections, because that class is that of + // which Test_Collections makes an instance, and so of course the derived + // method is invoked. + // + + public void setSCOArrayList(java.util.ArrayList scoArrayList) { + _sco_arrayList = scoArrayList; + _sco_arrayList.add(new Short((short)18)); + _sco_arrayList.add("home, home on the range..."); + _sco_arrayList.add(new Float(9876.5432f)); + _sco_arrayList.add(date); + _sco_arrayList.add(bigDecimal); + _sco_arrayList.add(bigInteger); + _sco_arrayList.add(locale); + } + + public void setSCOVector(java.util.Vector scoVector) { + _sco_vector = scoVector; + _sco_vector.addElement(new Byte((byte)13)); + _sco_vector.addElement("Call me Ishmael."); + _sco_vector.addElement(new Boolean(true)); + _sco_vector.addElement(new Boolean(false)); + _sco_vector.addElement(date); + _sco_vector.addElement(bigDecimal); + _sco_vector.addElement(bigInteger); + _sco_vector.addElement(locale); + } + + public void setSCOHashSet(java.util.HashSet scoHashSet) { + _sco_hashSet = scoHashSet; + _sco_hashSet.add("home, home on the range..."); + _sco_hashSet.add(new Character('J')); + _sco_hashSet.add(new Double(3.0e+6)); + _sco_hashSet.add(date); + _sco_hashSet.add(bigDecimal); + _sco_hashSet.add(bigInteger); + _sco_hashSet.add(locale); + } + + public void setSCOLinkedList(java.util.LinkedList scoLinkedList) { + _sco_linkedList = scoLinkedList; + _sco_linkedList.add(new Byte((byte)13)); + _sco_linkedList.add("once upon a time ..."); + _sco_linkedList.add(new Boolean(true)); + _sco_linkedList.add(new Boolean(false)); + _sco_linkedList.add(date); + _sco_linkedList.add(bigDecimal); + _sco_linkedList.add(bigInteger); + _sco_linkedList.add(locale); + } + + public void setSCOHashMap(java.util.HashMap scoHashMap) { + _sco_hashMap = scoHashMap; + _sco_hashMap.put("veni, vidi, vici", "in vino veritas ..."); + _sco_hashMap.put(new Integer(1), new Integer(42)); + _sco_hashMap.put(new Double(3.14159), new Float(6.02e+23)); + _sco_hashMap.put(new Character('d'), "d is 13"); + _sco_hashMap.put(new Byte((byte)0xf), date); + _sco_hashMap.put("wombat", bigDecimal); + _sco_hashMap.put(new Float(0.1f), bigInteger); + _sco_hashMap.put(new Long(123456789), locale); + } + + public void setSCOHashtable(java.util.Hashtable scoHashtable) { + _sco_hashtable = scoHashtable; + _sco_hashtable.put("in the beginning", "here I am ..."); + _sco_hashtable.put(new Integer(1), new Integer(42)); + _sco_hashtable.put(new Double(3.14159), new Float(6.02e+23)); + _sco_hashtable.put(new Character('d'), "d is 13"); + _sco_hashtable.put(new Byte((byte)0xf), date); + _sco_hashtable.put("wombat", bigDecimal); + _sco_hashtable.put(new Float(0.1f), bigInteger); + _sco_hashtable.put(new Long(123456789), locale); + } + + public void setSCOTreeMap(java.util.TreeMap scoTreeMap) { + _sco_treeMap = scoTreeMap; + _sco_treeMap.put(new Double(100), "he who knows not ..."); + _sco_treeMap.put(new Double(3), new Float(6.02e+23)); + _sco_treeMap.put(new Double(1), new Integer(42)); + _sco_treeMap.put(new Double(-123), "d is 13"); + _sco_treeMap.put(new Double(111), bigDecimal); + _sco_treeMap.put(new Double(10), date); + _sco_treeMap.put(new Double(0), bigInteger); + _sco_treeMap.put(new Double(789), locale); + } + + public void setSCOTreeSet(java.util.TreeSet scoTreeSet) { + _sco_treeSet = scoTreeSet; + _sco_treeSet.add(new Double(100)); + _sco_treeSet.add(new Double(3)); + _sco_treeSet.add(new Double(3.0e+6)); + _sco_treeSet.add(new Double(-123)); + _sco_treeSet.add(new Double(111)); + _sco_treeSet.add(new Double(890)); + _sco_treeSet.add(new Double(411)); + } + + // Add the given PC to each collection type. The caller in fact *should* + // create a PCPoint, so that we can test that collections can contain PC's + // as well. + public void addPoint(PCPoint p) { + _arrayList.add(p); + _sco_arrayList.add(p); + _vector.addElement(p); + _sco_vector.addElement(p); + _hashMap.put("hello", p); + _sco_hashMap.put("hello", p); + _hashtable.put("hello", p); + _sco_hashtable.put("hello", p); + _hashSet.add(p); + _sco_hashSet.add(p); + _treeMap.put(new Double(300000), p); + _sco_treeMap.put(new Double(300000), p); + _linkedList.add(p); + _sco_linkedList.add(p); + } + + + // Create a PCCollections with "interesting" values. + public void init() { + + // ArrayList + _arrayList = new java.util.ArrayList(); + _arrayList.add(new Integer(42)); + _arrayList.add(new Double(3.14159)); + _arrayList.add("hello-world"); + _arrayList.add(date); + _arrayList.add(bigDecimal); + _arrayList.add(bigInteger); + _arrayList.add(locale); + + _emptyArrayList = new java.util.ArrayList(); + + _nullArrayList = null; + + // SCO ArrayList + _sco_arrayList = null; // No PM => Test_Collections uses setSCOArrayList + _sco_emptyArrayList = new java.util.ArrayList(); + _sco_nullArrayList = null; + + // Vector + _vector = new java.util.Vector(); + _vector.add("four score and twenty beers ago"); + _vector.add(new Double(0.0102030508)); + _vector.add(new Integer(13)); + _vector.add(new Character('z')); + _vector.add(date); + _vector.add(bigDecimal); + _vector.add(bigInteger); + _vector.add(locale); + + _emptyVector = new java.util.Vector(); + + _nullVector = null; + + // SCO Vector + _sco_vector = null; // No PM => Test_Collections uses setSCOVector + _sco_emptyVector = new java.util.Vector(); + _sco_nullVector = null; + + // HashMap + _hashMap = new java.util.HashMap(); + _hashMap.put(new Integer(1), new Integer(42)); + _hashMap.put(new Double(3.14159), new Float(6.02e+23)); + _hashMap.put(new Character('d'), "d is 13"); + _hashMap.put(new Byte((byte)0xf), date); + _hashMap.put("wombat", bigDecimal); + _hashMap.put(new Float(0.1f), bigInteger); + _hashMap.put(new Long(123456789), locale); + + _emptyHashMap = new HashMap(); + + _nullHashMap = null; + + // SCO HashMap + _sco_hashMap = null; // No PM => Test_Collections uses setSCOHashMap + _sco_emptyHashMap = new java.util.HashMap(); + _sco_nullHashMap = null; + + // Hashtable + _hashtable = new java.util.Hashtable(); + _hashtable.put(new Integer(1), new Integer(42)); + _hashtable.put(new Double(3.14159), new Float(6.02e+23)); + _hashtable.put(new Character('d'), "d is 13"); + _hashtable.put(new Byte((byte)0xf), date); + _hashtable.put("wombat", bigDecimal); + _hashtable.put(new Float(0.1f), bigInteger); + _hashtable.put(new Long(123456789), locale); + + _emptyHashtable = new Hashtable(); + + _nullHashtable = null; + + // SCO Hashtable + _sco_hashtable = null; // No PM => Test_Collections uses setSCOHashtable + _sco_emptyHashtable = new java.util.Hashtable(); + _sco_nullHashtable = null; + + // HashSet + _hashSet = new java.util.HashSet(); + _hashSet.add(new Integer(13)); + _hashSet.add(new Float(6.02e+23)); + _hashSet.add("when I was back there in seminary school, ..."); + _hashSet.add(date); + _hashSet.add(bigDecimal); + _hashSet.add(bigInteger); + _hashSet.add(locale); + + _emptyHashSet = new java.util.HashSet(); + + _nullHashSet = null; + + // SCO HashSet + _sco_hashSet = null; // No PM => Test_Collections uses setSCOHashSet + _sco_emptyHashSet = new java.util.HashSet(); + _sco_nullHashSet = null; + + // LinkedList + _linkedList = new java.util.LinkedList(); + _linkedList.add(new Double(.00001)); + _linkedList.add(new Integer(3800)); + _linkedList.add("four score and twenty years ago"); + _linkedList.add(date); + _linkedList.add(bigDecimal); + _linkedList.add(bigInteger); + _linkedList.add(locale); + + _emptyLinkedList = new LinkedList(); + + _nullLinkedList = null; + + // SCO LinkedList + _sco_linkedList = null; // No PM => Test_Collections uses setSCOLinkedList + _sco_emptyLinkedList = new java.util.LinkedList(); + _sco_nullLinkedList = null; + + // TreeMap + // Keys must all be of same type for TreeMap. + _treeMap = new java.util.TreeMap(); + _treeMap.put(new Double(6.02e+23), new Integer(42)); + _treeMap.put(new Double(3.14159), new Float(6.02e+23)); + _treeMap.put(new Double(186000), "d is 13"); + _treeMap.put(new Double(0.1), date); + _treeMap.put(new Double(0.12), bigDecimal); + _treeMap.put(new Double(0.123), bigInteger); + _treeMap.put(new Double(0.1234), locale); + + _emptyTreeMap = new TreeMap(); + + _nullTreeMap = null; + + // SCO TreeMap + _sco_treeSet = null; // No PM => Test_Collections uses setSCOTreeMap + _sco_emptyTreeMap = new java.util.TreeMap(); + _sco_nullTreeMap = null; + + // TreeSet + _treeSet = new java.util.TreeSet(); + _treeSet.add(new Double(13)); + _treeSet.add(new Double(6.02e+23)); + _treeSet.add(new Double(186000)); + _treeSet.add(new Double(0.1234)); + _treeSet.add(new Double(0.123)); + _treeSet.add(new Double(0.12)); + _treeSet.add(new Double(0.1)); + + _emptyTreeSet = new java.util.TreeSet(); + + _nullTreeSet = null; + + // SCO TreeSet + _sco_treeSet = null; // No PM => Test_Collections uses setSCOTreeSet + _sco_emptyTreeSet = new java.util.TreeSet(); + _sco_nullTreeSet = null; + + // + // Extra Collection and Map tests, putting maps and arrays into + // collections and maps. + // + + // Don't reuse the above _arrayList and _hashMap because they contain + // Date objects, which I've determined empirically to have different + // toString() representations in different JDK's (e.g. on Solaris and + // WinNT). + java.util.ArrayList al = new java.util.ArrayList(); + al.add(new Integer(42)); + al.add("hello-world"); + al.add(bigDecimal); + al.add(locale); + + java.util.HashMap hm = new java.util.HashMap(); + hm = new java.util.HashMap(); + hm.put(new Integer(1), new Integer(42)); + hm.put(new Character('d'), "d is 13"); + hm.put("wombat", bigDecimal); + hm.put(new Float(0.1f), bigInteger); + + int xyz[] = new int[] { 1, 2, 3, 4, 5 }; // Array of primitive + Date dates[] = new Date[] { date, date }; // Array of Object + + // Extra Collection tests: Collection of Collection, Collection of + // Map, Collection of array of primitive, Collection of array of Object. + _vector.add(al); // Collection of Collection + _vector.add(hm); // Collection of Map + _vector.add(xyz); + _vector.add(dates); + + // Extra tests: Map of Map, Map of Collection, Map of array of + // primitive, Map of array of Object. + _treeMap.put(new Double(1234.5), al); // Map of collection + _treeMap.put(new Double(1.0), hm); // Map of Map + _treeMap.put(new Double(2.345), xyz); // Map of array of primitive + _treeMap.put(new Double(0.0000000000000009), dates); // Map of array of SCO + } + + public String toString() { + StringBuffer rc = new StringBuffer(Util.getClassName(this)); + StringBuffer info; + try { + // ArrayList + rc.append(Util.stringifyList(_arrayList, + Util.getInfo("_arrayList", _arrayList))); + rc.append(Util.stringifyList(_emptyArrayList, "_emptyArrayList")); + rc.append(Util.stringifyList(_nullArrayList, "_nullArrayList")); + rc.append("\n"); + + // SCO ArrayList + rc.append(Util.stringifyList(_sco_arrayList, + Util.getInfo("_sco_arrayList", _sco_arrayList))); + rc.append(Util.stringifyList(_sco_emptyArrayList, "_sco_emptyArrayList")); + rc.append(Util.stringifyList(_sco_nullArrayList, "_sco_nullArrayList")); + rc.append("\n"); + + // Vector + rc.append(Util.stringifyList(_vector, Util.getInfo("_vector", _vector))); + rc.append(Util.stringifyList(_emptyVector, "_emptyVector")); + rc.append(Util.stringifyList(_nullVector, "_nullVector")); + rc.append("\n"); + + // SCO Vector + rc.append(Util.stringifyList(_sco_vector, + Util.getInfo("_sco_vector", _sco_vector))); + rc.append(Util.stringifyList(_sco_emptyVector, "_sco_emptyVector")); + rc.append(Util.stringifyList(_sco_nullVector, "_sco_nullVector")); + rc.append("\n"); + + // HashMap + rc.append(Util.stringifyMap(_hashMap, Util.getInfo("_hashMap", _hashMap))); + rc.append(Util.stringifyMap(_emptyHashMap, "_emptyHashMap")); + rc.append(Util.stringifyMap(_nullHashMap, "_nullHashMap")); + rc.append("\n"); + + // SCO HashMap + rc.append(Util.stringifyMap(_sco_hashMap, + Util.getInfo("_sco_hashMap", _sco_hashMap))); + rc.append(Util.stringifyMap(_sco_emptyHashMap, "_sco_emptyHashMap")); + rc.append(Util.stringifyMap(_sco_nullHashMap, "_sco_nullHashMap")); + rc.append("\n"); + + // Hashtable + rc.append(Util.stringifyMap(_hashtable, Util.getInfo("_hashtable", _hashtable))); + rc.append(Util.stringifyMap(_emptyHashtable, "_emptyHashtable")); + rc.append(Util.stringifyMap(_nullHashtable, "_nullHashtable")); + rc.append("\n"); + + // SCO Hashtable + rc.append(Util.stringifyMap(_sco_hashtable, + Util.getInfo("_sco_hashtable", _sco_hashtable))); + rc.append(Util.stringifyMap(_sco_emptyHashtable, "_sco_emptyHashtable")); + rc.append(Util.stringifyMap(_sco_nullHashtable, "_sco_nullHashtable")); + rc.append("\n"); + + // HashSet + rc.append(Util.stringifySet(_hashSet, Util.getInfo("_hashSet", _hashSet))); + rc.append(Util.stringifySet(_emptyHashSet, "_emptyHashSet")); + rc.append(Util.stringifySet(_nullHashSet, "_nullHashSet")); + rc.append("\n"); + + // SCO HashSet + rc.append(Util.stringifySet(_sco_hashSet, + Util.getInfo("_sco_hashSet", _sco_hashSet))); + rc.append(Util.stringifySet(_sco_emptyHashSet, "_sco_emptyHashSet")); + rc.append(Util.stringifySet(_sco_nullHashSet, "_sco_nullHashSet")); + rc.append("\n"); + + // LinkedList + rc.append(Util.stringifyList(_linkedList, Util.getInfo("_linkedList", _linkedList))); + rc.append(Util.stringifyList(_emptyLinkedList, "_emptyLinkedList")); + rc.append(Util.stringifyList(_nullLinkedList, "_nullLinkedList")); + rc.append("\n"); + + // SCO LinkedList + rc.append(Util.stringifyList(_sco_linkedList, + Util.getInfo("_sco_linkedList", _sco_linkedList))); + rc.append(Util.stringifyList(_sco_emptyLinkedList, "_sco_emptyLinkedList")); + rc.append(Util.stringifyList(_sco_nullLinkedList, "_sco_nullLinkedList")); + rc.append("\n"); + + // TreeMap + rc.append(Util.stringifyMap(_treeMap, Util.getInfo("_treeMap", _treeMap))); + rc.append(Util.stringifyMap(_emptyTreeMap, "_emptyTreeMap")); + rc.append(Util.stringifyMap(_nullTreeMap, "_nullTreeMap")); + rc.append("\n"); + + // SCO TreeMap + rc.append(Util.stringifyMap(_sco_treeMap, Util.getInfo("_sco_treeMap", _sco_treeMap))); + rc.append(Util.stringifyMap(_sco_emptyTreeMap, "_sco_emptyTreeMap")); + rc.append(Util.stringifyMap(_sco_nullTreeMap, "_sco_nullTreeMap")); + rc.append("\n"); + + // TreeSet + rc.append(Util.stringifySet(_treeSet, Util.getInfo("_treeSet", _treeSet))); + rc.append(Util.stringifySet(_emptyTreeSet, "_emptyTreeSet")); + rc.append(Util.stringifySet(_nullTreeSet, "_nullTreeSet")); + rc.append("\n"); + + // SCO TreeSet + rc.append(Util.stringifySet(_sco_treeSet, + Util.getInfo("_sco_treeSet", _sco_treeSet))); + rc.append(Util.stringifySet(_sco_emptyTreeSet, "_sco_emptyTreeSet")); + rc.append(Util.stringifySet(_sco_nullTreeSet, "_sco_nullTreeSet")); + rc.append("\n"); + + } catch (NullPointerException ex) { + ex.printStackTrace(); + return (rc.toString() + "\nPCCollections has null values"); + } + return rc.toString(); + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,69 @@ +/* + * 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.pc; + +// Test graph with cycles: each class contains a member of the other class. +// + + +/** +* A class whose instances refer to instances of this class, creating a cycle. +* +* @author Dave Bristor +*/ +public class PCCycle { + public String name; + public PCCycle2 c2; + + public PCCycle() { } + + public void init(String name, PCCycle2 c2) { + this.name = name; + this.c2 = c2; + } + + PCCycle2 getC2() { + return c2; + } + + public String toString(PCCycle2 c2) { + String rc = "loop!"; + if (this.c2 != c2) { + rc = toString(); + } + return rc; + } + + public String toString() { + String rc = null; + try { + rc = this.getClass().getName() + + " name=" + name; + try { + // Compare w/ PCCycle2.toString() + rc += " c2='" + getC2().toString() + "'"; + } catch (NullPointerException ex) { + ex.printStackTrace(System.err); + rc += " c2=<NPE>"; + } + } catch (NullPointerException ex) { + ex.printStackTrace(System.err); + rc = "PCCycle has no values"; + } + return rc; + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle2.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle2.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle2.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCCycle2.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,60 @@ +/* + * 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.pc; + +// Test graph with cycles: each class contains a member of the other class. +// + +/** +* A class whose instances refer to instances of this class, creating a cycle. +* +* @author Dave Bristor +*/ +public class PCCycle2 { + public int id; + public PCCycle c; + + public PCCycle2() { } + + public void init (int id, PCCycle c) { + this.id = id; + this.c = c; + } + + PCCycle getC() { + return c; + } + + public String toString() { + String rc = null; + try { + rc = this.getClass().getName() + + " id=" + id; + try { + // Compare w/ PCCycle.toString() + rc += " c='" + getC().toString(this) + "'"; + } catch (NullPointerException ex) { + ex.printStackTrace(System.err); + rc += " c=<NPE>"; + } + } catch (NullPointerException ex) { + ex.printStackTrace(System.err); + rc = "PCCycle has no values"; + } + return rc; + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,89 @@ +/* + * 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.pc; + +import java.util.HashSet; + +/** +* A sample department class, generated from an SQL schema. +*/ +public class PCDepartment { + public long deptid; + + public String name; + + public java.util.HashSet employees; + + public String toString() { + return "Dept: " + name + ", id=" + deptid + + ", emps: " + employees.size(); + } + + public PCDepartment() { + } + + public PCDepartment(long _id, String _name) { + deptid = _id; + name = _name; + } + + public long getDeptid() { + return deptid; + } + + public void setDeptid(long deptid) { + this. deptid = deptid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this. name = name; + } + + public java.util.HashSet getEmployees() { + return employees; + } + + public void setEmployees(java.util.HashSet employees) { + this. employees = employees; + } + + public static class Oid { + public long deptid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.deptid!=o.deptid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += deptid; + return( hashCode ); + } + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment1.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment1.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment1.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDepartment1.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,92 @@ +/* + * 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.pc; + +import java.util.HashSet; + +/** +* A sample department class. Used with other classes which +* names end with "1". +* +* @author Marina Vatkina. +*/ +public class PCDepartment1 { + public long deptid; + + public String name; + + public java.util.HashSet employees; + + public String toString() { + return "Dept: " + name + ", id=" + deptid + + ", emps: " + employees.size(); + } + + public PCDepartment1() { + } + + public PCDepartment1(long _id, String _name) { + deptid = _id; + name = _name; + } + + public long getDeptid() { + return deptid; + } + + public void setDeptid(long deptid) { + this. deptid = deptid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this. name = name; + } + + public java.util.HashSet getEmployees() { + return employees; + } + + public void setEmployees(java.util.HashSet employees) { + this. employees = employees; + } + + public static class Oid { + public long deptid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.deptid!=o.deptid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += deptid; + return( hashCode ); + } + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDerived.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDerived.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDerived.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCDerived.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,21 @@ +/* + * 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.pc; + +public class PCDerived extends PCBase { + public PCDerived() { } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,219 @@ +/* + * 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.pc; + +import java.util.HashSet; + +import org.apache.jdo.test.util.Util; + +/** +* A sample employee class, generated from an SQL schema. +*/ +public class PCEmployee { + public long empid; + + public String lastname; + + public String firstname; + + public java.util.Date hiredate; + + public java.util.Date birthdate; + + public double salary; + + public java.util.HashSet projects; + + public PCDepartment department; + + public PCEmployee manager; + + public java.util.HashSet employees; + + public PCInsurance insurance; + + public String toString() { + StringBuffer rc = new StringBuffer("Emp: "); + rc.append(lastname); + rc.append(", " + firstname); + rc.append(", id=" + empid); + rc.append(", born " + Util.shortFormatter.format(birthdate)); + rc.append(", hired " + Util.shortFormatter.format(hiredate)); + rc.append(" $" + salary); + String mgrName = "none"; + if (null != manager) { + mgrName = manager.getLastname(); + } + rc.append(" manager: " + mgrName); + rc.append(" dept: " + department.getName()); + int numEmps = 0; + if (null != employees) { + numEmps = employees.size(); + } + rc.append(" emps: " + numEmps); + if (null != insurance) { + rc.append(" insurance: " + insurance.getCarrier()); + } else { + rc.append(" insurance: null"); + } + + return rc.toString(); + } + + public PCEmployee() { + } + + public PCEmployee(long _empid, String _last, String _first, double _sal, + java.util.Date _born, java.util.Date _hired) { + empid = _empid; + lastname = _last; + firstname = _first; + salary = _sal; + birthdate = _born; + hiredate = _hired; + } + + public long getEmpid() { + return empid; + } + + public void setEmpid(long empid) { + this. empid = empid; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this. lastname = lastname; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this. firstname = firstname; + } + + public java.util.Date getHiredate() { + return hiredate; + } + + public void setHiredate(java.util.Date hiredate) { + this. hiredate = hiredate; + } + + public java.util.Date getBirthdate() { + return birthdate; + } + + public void setBirthdate(java.util.Date birthdate) { + this. birthdate = birthdate; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this. salary = salary; + } + + public java.util.HashSet getProjects() { + return projects; + } + + public void setProjects(java.util.HashSet projects) { + this. projects = projects; + } + + public PCDepartment getDepartment() { + return department; + } + + public void setDepartment(PCDepartment department) { + this. department = department; + } + + public PCEmployee getManager() { + return manager; + } + + public void setManager(PCEmployee manager) { + this. manager = manager; + } + + public java.util.HashSet getEmployees() { + return employees; + } + + public void setEmployees(java.util.HashSet employees) { + this. employees = employees; + } + + public PCInsurance getInsurance() { + return insurance; + } + + public void setInsurance(PCInsurance insurance) { + this. insurance = insurance; + } + + // Returns true iff the values of fields in this are == to those in the + // given object. + public boolean sameValues(Object o) { + PCEmployee other = (PCEmployee)o; + + return + (empid == other.empid) && + (lastname == other.lastname) && + (firstname == other.firstname) && + (hiredate == other.hiredate) && + (salary == other.salary) && + (projects == other.projects) && + (department == other.department) && + (manager == other.manager) && + (employees == other.employees) && + (insurance == other.insurance); + } + + public static class Oid { + public long empid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.empid!=o.empid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += empid; + return( hashCode ); + } + + + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee1.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee1.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee1.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCEmployee1.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,227 @@ +/* + * 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.pc; + +import org.apache.jdo.test.util.Util; + +/** +* A extended employee class that differs from Employee class +* in types of the relationship fields on the many side: +* Array of javax.jdo.spi.PersistenceCapable instances for +* manager-employees relationship, and LinkedList for the list +* of projects. +* +* @author Marina Vatkina +*/ +public class PCEmployee1 implements java.io.Serializable { + public long empid; + + public String lastname; + + public String firstname; + + public java.util.Date hiredate; + + public java.util.Date birthdate; + + public double salary; + + public java.util.LinkedList projects; + + public PCDepartment1 department; + + public PCEmployee1 manager; + + public Object[] employees; + + public PCInsurance1 insurance; + + public String toString() { + StringBuffer rc = new StringBuffer("Emp: "); + rc.append(lastname); + rc.append(", " + firstname); + rc.append(", id=" + empid); + rc.append(", born " + Util.shortFormatter.format(birthdate)); + rc.append(", hired " + Util.shortFormatter.format(hiredate)); + rc.append(" $" + salary); + String mgrName = "none"; + if (null != manager) { + mgrName = manager.getLastname(); + } + rc.append(" manager: " + mgrName); + String dname = "none"; + if (null != department) { + dname = department.getName(); + } + rc.append(" dept: " + dname); + int numEmps = 0; + if (null != employees) { + numEmps = employees.length; + } + rc.append(" emps: " + numEmps); + if (null != insurance) { + rc.append(" insurance: " + insurance.getCarrier()); + } else { + rc.append(" insurance: null"); + } + + return rc.toString(); + } + + public PCEmployee1() { + } + + public PCEmployee1(long _empid, String _last, String _first, double _sal, + java.util.Date _born, java.util.Date _hired) { + empid = _empid; + lastname = _last; + firstname = _first; + salary = _sal; + birthdate = _born; + hiredate = _hired; + } + + public long getEmpid() { + return empid; + } + + public void setEmpid(long empid) { + this. empid = empid; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this. lastname = lastname; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this. firstname = firstname; + } + + public java.util.Date getHiredate() { + return hiredate; + } + + public void setHiredate(java.util.Date hiredate) { + this. hiredate = hiredate; + } + + public java.util.Date getBirthdate() { + return birthdate; + } + + public void setBirthdate(java.util.Date birthdate) { + this. birthdate = birthdate; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this. salary = salary; + } + + public java.util.LinkedList getProjects() { + return projects; + } + + public void setProjects(java.util.LinkedList projects) { + this. projects = projects; + } + + public PCDepartment1 getDepartment() { + return department; + } + + public void setDepartment(PCDepartment1 department) { + this. department = department; + } + + public PCEmployee1 getManager() { + return manager; + } + + public void setManager(PCEmployee1 manager) { + this. manager = manager; + } + + public Object[] getEmployees() { + return employees; + } + + public void setEmployees(Object[] employees) { + this. employees = employees; + } + + public PCInsurance1 getInsurance() { + return insurance; + } + + public void setInsurance(PCInsurance1 insurance) { + this. insurance = insurance; + } + + // Returns true iff the values of fields in this are == to those in the + // given object. + public boolean sameValues(Object o) { + PCEmployee1 other = (PCEmployee1)o; + + return + (empid == other.empid) && + (lastname == other.lastname) && + (firstname == other.firstname) && + (hiredate == other.hiredate) && + (salary == other.salary) && + (projects == other.projects) && + (department == other.department) && + (manager == other.manager) && + (employees == other.employees) && + (insurance == other.insurance); + } + + public static class Oid { + public long empid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.empid!=o.empid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += empid; + return( hashCode ); + } + + + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCFullTimeEmployee1.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCFullTimeEmployee1.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCFullTimeEmployee1.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCFullTimeEmployee1.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/* + * PCFullTimeEmployee1.java + * + * Created on May 22, 2001, 9:36 AM + */ + +package org.apache.jdo.pc; + +/** + * + * @author clr + * @version + */ +public class PCFullTimeEmployee1 extends PCEmployee1 { + + public int range; + + /** Creates new PCFullTimeEmployee1 */ + public PCFullTimeEmployee1() { + } + public PCFullTimeEmployee1( + String _first, + String _last, + java.util.Date _born, + long _empid, + java.util.Date _hired, + double _sal, + int _range ) { + super (_empid, _last, _first, _sal, _born, _hired); + range = _range; + } + + public double getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public String toString() { + StringBuffer rc = new StringBuffer("PCFullTimeEmployee1: "); + rc.append(super.toString()); + rc.append(" range: " + range); + return rc.toString(); + } + + +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCId.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCId.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCId.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCId.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,58 @@ +/* + * 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.pc; + +public class PCId implements Comparable { + private int id; + private static int count = 0; + + public PCId() { + id = 100 + count; + count++; + } + + public int hashCode() { + return id; + } + + public boolean equals(Object o) { + boolean rc = false; + if (null != o && o instanceof PCId) { + PCId other = (PCId)o; + rc = (id == other.id); + } + return rc; + } + + public String toString() { + return "PCId=" + id; + } + + public int compareTo(Object obj) { + if (obj == null) { + throw new RuntimeException("Null cannot be compared."); + } + if (obj instanceof PCId) { + return id - ((PCId)obj).id; + } else { + throw new RuntimeException("Object of class " + + obj.getClass().getName() + + " cannot be compared to an instance of PCId."); + } + } + +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,92 @@ +/* + * 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.pc; + +import java.util.HashSet; + +/** +* A sample insurance class, generated from an SQL schema. +*/ +public class PCInsurance { + public long insid; + + public String carrier; + + public PCEmployee employee; + + public String toString() { + return "Ins: " + carrier + ", id=" + insid + + ", emp " + employee.getLastname(); + } + + public PCInsurance() { + } + + public PCInsurance(long _id, String _carrier, PCEmployee _emp) { + insid = _id; + carrier = _carrier; + employee = _emp; + } + + public long getInsid() { + return insid; + } + + public void setInsid(long insid) { + this. insid = insid; + } + + public String getCarrier() { + return carrier; + } + + public void setCarrier(String carrier) { + this. carrier = carrier; + } + + public PCEmployee getEmployee() { + return employee; + } + + public void setEmployee(PCEmployee employee) { + this. employee = employee; + } + + public static class Oid { + public long insid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += insid; + return( hashCode ); + } + + +} +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance1.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance1.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance1.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInsurance1.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,101 @@ +/* + * 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.pc; + +import java.util.HashSet; + +/** +* A sample insurance class. Used with other classes which names +* end with "1". +* +* @author Marina Vatkina +*/ +public class PCInsurance1 { + public long insid; + + public String carrier; + + public PCEmployee1 employee; + + public String toString() { + String ename = "none"; + try{ + ename = employee.getLastname(); + } catch (Exception e) { +//System.out.println("I: " + e); + } + return "Ins: " + carrier + ", id=" + insid + + ", emp " + ename; + } + + public PCInsurance1() { + } + + public PCInsurance1(long _id, String _carrier, PCEmployee1 _emp) { + insid = _id; + carrier = _carrier; + employee = _emp; + } + + public long getInsid() { + return insid; + } + + public void setInsid(long insid) { + this. insid = insid; + } + + public String getCarrier() { + return carrier; + } + + public void setCarrier(String carrier) { + this. carrier = carrier; + } + + public PCEmployee1 getEmployee() { + return employee; + } + + public void setEmployee(PCEmployee1 employee) { + this. employee = employee; + } + + public static class Oid { + public long insid; + + public Oid() { + } + + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += insid; + return( hashCode ); + } + + +} +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInterfaces.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInterfaces.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInterfaces.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCInterfaces.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,66 @@ +/* + * 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.pc; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Vector; + +import org.apache.jdo.test.util.Util; + + +/** +* Test ability to store & fetch instances of classes which refer to other +* PersistenceCapable classes, where the field type in the referring class is +* of an interface, not of an implementation. +* +* @author Dave Bristor +*/ +public class PCInterfaces { + public java.util.List _list; + public java.util.List _emptyList = new Vector(); + public java.util.List _nullList = null; + + public PCInterfaces() { } + + public void init() { + _list = new ArrayList(); + _list.add(new Integer(42)); + _list.add(new Long(5551212)); + } + + public boolean equals(Object o) { + // Note, this implementation assumes all _nullXXX fields are null + // and all _XXX fields are not null in this instance + if (null == o || !(o instanceof PCInterfaces)) + return false; + PCInterfaces other = (PCInterfaces)o; + return _list.equals(other._list) && + _emptyList.equals(other._emptyList) && + _nullList == other._nullList; + } + + public String toString() { + StringBuffer rc = new StringBuffer(this.getClass().getName()); + rc.append(Util.stringifyList(_list, + Util.getInfo("_list", _list))); + rc.append(Util.stringifyList(_emptyList, "_emptyList")); + rc.append(Util.stringifyList(_nullList, "_nullList")); + return rc.toString(); + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCLargeObj.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCLargeObj.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCLargeObj.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/PCLargeObj.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,70 @@ +/* + * 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.pc; + +/** +* A simple class with one field that's an array. Make it a big one, and +* verify() it's contents. +* +* @author Dave Bristor +*/ +public class PCLargeObj { + public int x[]; + + public PCLargeObj() { } + + public PCLargeObj(int length) { + this.x = new int[length]; + verify(true); + } + + public void init(int size) { + this.x = new int[size]; + verify(true); + } + + // If create is true, then put elements into x and return true; otherwise + // verify that the correct elements are there returning true or false as + // appropriate. + boolean verify(boolean create) { + boolean rc = true; + int length = x.length; + for (int i = 0; i < length; i++) { + if (create) { + x[i] = i; + } else if (x[i] != i) { + rc = false; + break; + } + } + return rc; + } + + public String toString() { + String rc = null; + try { + rc = this.getClass().getName() + name(); + } catch (NullPointerException ex) { + rc = "PCPCLargeObj has no values"; + } + return rc; + } + + public String name() { + return " length=" + x.length; + } +}