Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/build.xml URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/build.xml?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/build.xml (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/build.xml Fri Mar 18 17:02:29 2005 @@ -0,0 +1,128 @@ +<!-- + Copyright 2004 Sun Microsystems, Inc. All rights reserved. + Use is subject to license terms. +--> + +<project name="serializable-test" default="enh" basedir="."> + +<property name="lib" value="../../../release/lib/ext"/> + +<!-- JAR files required to run the tests +--> +<property name="btree" value="${lib}/btree.jar"/> +<property name="fscontext" value="${lib}/fscontext.jar"/> +<property name="providerutil" value="${lib}/providerutil.jar"/> +<property name="xerces" value="${lib}/xerces.jar"/> +<property name="jta" value="${lib}/jta.jar"/> +<property name="jdo" value="../../jdo.jar"/> +<property name="jdo-util" value="../../jdo-util.jar"/> +<property name="jdo-model" value="../../jdo-model.jar"/> +<property name="jdo-ri" value="../../jdo-ri.jar"/> +<property name="jdo-fostore" value="../../jdo-fostore.jar"/> +<property name="antlr" value="${lib}/antlrDev.jar"/> + +<property name="enhancer" value="org.apache.jdo.enhancer.Main"/> +<property name="enhanceDir" value="enh"/> +<property name="xmlExists" value="org.apache.jdo.impl.model.jdo.xml.XMLExists"/> + + <!-- CLASSPATH --> + <!-- CLASSPATH --> + <!-- CLASSPATH --> + +<property name="extjars" + value="${btree};${fscontext};${providerutil};${xerces};${antlr}"/> + +<property name="classpath" + value="..;${jdo};${jdo-util};${jdo-model};${jdo-ri};${jdo-fostore};pcclasses.jar;${extjars}"/> + +<property name="pcclasses.serializable.classes" value=" + test.serializable.PCClass1 + test.serializable.PCClass2A + test.serializable.PCClass2B + test.serializable.PCSuper + test.serializable.PCSub3 + test.serializable.PCSub4A + test.serializable.PCSub4B +"/> + +<property name="pcclasses.serializable.files" value=" + PCClass1.class + PCClass2A.class + PCClass2B.class + PCSuper.class + PCSub3.class + PCSub4A.class + PCSub4B.class +"/> + + <!-- RUNNING TESTS --> + <!-- RUNNING TESTS --> + <!-- RUNNING TESTS --> + +<target name="enh" depends="build, enhance, disassemble, javap"> +</target> + +<target name="build"> + <javac srcdir="." debug="on" classpath="${jdo};${jdo-util};${jdo-model};${jdo-ri};${jdo-fostore};../.." + includes="*.java"/> +</target> + +<target name="enhance"> + <!-- Test .jdo file(s) for pc classes in package "test.serializable" + for package/class name inconsistencies --> + <echo message="Check existence of XML metadata for pc classes in package test.serializable"/> + <java fork="yes" failonerror="yes" + classname="${xmlExists}" + classpath="../..;${jdo-enhancer};${xerces};${antlr};${jdo}"> + <arg line="${pcclasses.serializable.classes}"/> + </java> + + <!-- --> + <mkdir dir="${enhanceDir}"/> + <copy todir="${enhanceDir}" > + <fileset dir="../.." > + <include name="test/serializable/Transient.class"/> + <include name="test/serializable/package.jdo"/> + </fileset> + </copy> + + <!-- Enhance classes in package "test.serializable". --> + <echo message="Enhance classes in package test.serializable"/> + <java fork="yes" failonerror="yes" + classname="${enhancer}" classpath="${jdo-enhancer};${xerces};${antlr};${jdo}"> + <arg line="-f -d ${enhanceDir} -s ../.. ${pcclasses.serializable.files}"/> + </java> +</target> + +<target name="disassemble"> + <echo message="call Disassembler"/> + <java fork="yes" failonerror="yes" + classname="org.apache.jdo.impl.enhancer.util.Disassembler" + classpath="${enhanceDir};${jdo-enhancer};${xerces};${antlr};${jdo}" output="${enhanceDir}/output.dis"> + <arg line="-v"/> + <arg line="-s"/> + <arg path="${enhanceDir};${jdo}"/> + <arg line="${pcclasses.serializable.classes}"/> + </java> +</target> + +<target name="javap"> + <echo message="call javap"/> + <exec executable="javap" dir="." output="${enhanceDir}/output.javap" + failonerror="yes"> + <arg line="-classpath"/> + <arg path="${enhanceDir};${jdo-util};${jdo-model};${jdo-ri};${jdo-fostore};${xerces};${antlr};${jdo}"/> + <arg line="-c -private"/> + <arg line="${pcclasses.serializable.classes}"/> + </exec> +</target> + +<target name="clean"> + <delete includeEmptyDirs="true"> + <fileset dir="." includes="${enhanceDir}/**/*"/> + <fileset dir="." includes="${enhanceDir}"/> + <fileset dir="." includes="**/*.class"/> + </delete> +</target> + +</project>
Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/package.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/package.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/package.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/package.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.serializable"> + + <class name="PCClass1" + identity-type="datastore"> + <field name="s01" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t02" persistence-modifier="persistent"/> + </class> + + <class name="PCClass2A" + identity-type="datastore"> + <field name="s01" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t02" persistence-modifier="persistent"/> + </class> + + <class name="PCClass2B" + identity-type="datastore"> + <field name="s01" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t02" persistence-modifier="persistent"/> + </class> + + <class name="PCSuper" + identity-type="datastore"> + <field name="s01" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t02" persistence-modifier="persistent"/> + </class> + + <class name="PCSub3" + identity-type="datastore" + persistence-capable-superclass="PCSuper"> + <field name="s03" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t04" persistence-modifier="persistent"/> + </class> + + <class name="PCSub4A" + identity-type="datastore" + persistence-capable-superclass="PCSuper"> + <field name="s03" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t04" persistence-modifier="persistent"/> + </class> + + <class name="PCSub4B" + identity-type="datastore" + persistence-capable-superclass="PCSuper"> + <field name="s03" persistence-modifier="persistent" + default-fetch-group="false" /> + <field name="t04" persistence-modifier="persistent"/> + </class> + + </package> +</jdo> + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/serializable.jdoproperties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/serializable.jdoproperties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/serializable.jdoproperties (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/serializable/serializable.jdoproperties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,40 @@ +# Classnames can have the following attributes: +# jdo:{persistent|transient} +# super: <classname> +# oid: <classname> +# access: {public|protected|package|private} +# Fieldnames can have the following attributes: +# type:<type> +# access: {public|protected|package|private} +# jdo:{persistent|transactional|transient} +# annotation:{key|dfg|mediated} + +org.apache.jdo.pc.serializable.PCClass1=jdo:persistent +org.apache.jdo.pc.serializable.PCClass1#s01=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCClass1#t02=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.PCClass2A=jdo:persistent +org.apache.jdo.pc.serializable.PCClass2A#s01=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCClass2A#t02=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.PCClass2B=jdo:persistent +org.apache.jdo.pc.serializable.PCClass2B#s01=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCClass2B#t02=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.PCSuper=jdo:persistent +org.apache.jdo.pc.serializable.PCSuper#s01=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCSuper#t02=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.Transient=jdo:transient,super:org.apache.jdo.pc.serializable.PCSuper + +org.apache.jdo.pc.serializable.PCSub3=jdo:persistent,super:org.apache.jdo.pc.serializable.Transient +org.apache.jdo.pc.serializable.PCSub3#s03=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCSub3#t04=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.PCSub4A=jdo:persistent,super:org.apache.jdo.pc.serializable.Transient +org.apache.jdo.pc.serializable.PCSub4A#s03=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCSub4A#t04=jdo:persistent,annotation:dfg + +org.apache.jdo.pc.serializable.PCSub4B=jdo:persistent,super:org.apache.jdo.pc.serializable.Transient +org.apache.jdo.pc.serializable.PCSub4B#s03=jdo:persistent,annotation:mediated +org.apache.jdo.pc.serializable.PCSub4B#t04=jdo:persistent,annotation:dfg Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,139 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; + +public class Company implements Serializable, Identifiable { + + private String name; + private Date founded; + private String address; + private HashSet departments; + + public Object getOid() { + Oid oid = new Oid(); + oid.name = this.name; + oid.founded = this.founded; + return oid; + } + + public String toString() { + return "Company(" + name + + ", founded=" + founded + + ", address=" + address + + ", departments: " + ((departments == null) ? 0 : departments.size()) + + ")"; + } + + public Company() { + } + + public Company(String name, + Date founded, + String address, + HashSet departments) { + this.name = name; + this.founded = founded; + this.address = address; + this.departments = departments; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getFounded() { + return founded; + } + + public void setFounded(java.util.Date founded) { + this.founded = founded; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public HashSet getDepartments() { + return departments; + } + + public void setDepartments(HashSet departments) { + this.departments = departments; + } + + public static class Oid implements Serializable, Comparable { + + public String name; + + public java.util.Date founded; + + 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.name!=o.name) && + (this.name==null || !this.name.equals(o.name)) ) + return( false ); + if( (this.founded!=o.founded) && + (this.founded==null || !this.founded.equals(o.founded)) ) + return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + if( name!=null ) + hashCode += name.hashCode(); + if( founded!=null ) + hashCode += founded.hashCode(); + return( hashCode ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + // WARNING: this only compares the names + String thisName = name; + String otherName = ((Oid)o).name; + if (thisName == null) + return (otherName == null) ? 0 : -1; + if (otherName == null) + return 1; + return thisName.compareTo(otherName); + } + + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Company.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Company" + identity-type="datastore"> + <field name="name"/> + <field name="founded"/> + <field name="address"/> + <field name="departments"> + <collection element-type="Department"/> + </field> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,125 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.HashSet; + +public class Department implements Serializable, Identifiable { + + private long deptid; + private String name; + private Company company; + private HashSet employees; + + public Object getOid() { + Oid oid = new Oid(); + oid.deptid = this.deptid; + return oid; + } + + public String toString() { + return "Department(" + name + + ", id=" + deptid + + ", employees=" + ((employees == null) ? 0 : employees.size()) + + ", company=" + ((company == null) ? "null" : company.getName()) + + ")"; + } + + public Department() { + } + + public Department(long deptid, + String name, + Company company, + HashSet employees) { + this.deptid = deptid; + this.name = name; + this.company = company; + this.employees = employees; + } + + 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 Company getCompany() { + return company; + } + + public void setCompany(Company company) { + this.company = company; + } + + public java.util.HashSet getEmployees() { + return employees; + } + + public void setEmployees(HashSet employees) { + this.employees = employees; + } + + public static class Oid implements Serializable, Comparable { + + 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 ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherDeptid = ((Oid)o).deptid; + if (deptid == otherDeptid) + return 0; + else if (deptid < otherDeptid) + return -1; + return 1; + } + + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Department.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Department" + identity-type="datastore"> + <field name="deptid"/> + <field name="name"/> + <field name="company" persistence-modifier="persistent"/> + <field name="employees"> + <collection element-type="Employee"/> + </field> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,259 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Date; + +public class Employee + extends Person + implements Serializable, Identifiable +{ + private long empid; + private Date hiredate; + private double weeklyhours; + private char discriminator; + private HashSet reviewedProjects; + private HashSet projects; + private Insurance insurance; + private Department department; + private Employee manager; + private HashSet team; + private Employee mentor; + private Employee protege; + private Employee hradvisor; + private HashSet hradvisees; + + public Object getOid() + { + Oid oid = new Oid(); + oid.empid = this.empid; + return oid; + } + + public String toString() + { + StringBuffer repr = new StringBuffer(); + addFieldRepr(repr); + return "Employee(" + repr.toString() + ")"; + } + + public Employee() {} + + public Employee(long empid, + String lastname, + String firstname, + Date hiredate, + Date birthdate, + double weeklyhours, + char discriminator, + HashSet reviewedProjects, + HashSet projects, + Insurance insurance, + Department department, + Employee manager, + HashSet team, + Employee mentor, + Employee protege, + Employee hradvisor, + HashSet hradvisees) + { + super(lastname, firstname, birthdate); + this.empid = empid; + this.hiredate = hiredate; + this.weeklyhours = weeklyhours; + this.discriminator = discriminator; + this.reviewedProjects = reviewedProjects; + this.projects = projects; + this.insurance = insurance; + this.department = department; + this.manager = manager; + this.team = team; + this.mentor = mentor; + this.protege = protege; + this.hradvisor = hradvisor; + this.hradvisees = hradvisees; + } + + public long getEmpid() { + return empid; + } + + public void setEmpid(long empid) { + this.empid = empid; + } + + public Date getHiredate() { + return hiredate; + } + + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + public double getWeeklyhours() { + return weeklyhours; + } + + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + public char getDiscriminator() { + return discriminator; + } + + public void setDiscriminator(char discriminator) { + this.discriminator = discriminator; + } + + public HashSet getReviewedProjects() { + return reviewedProjects; + } + + public void setReviewedProjects(HashSet reviewedProjects) { + this.reviewedProjects = reviewedProjects; + } + + public HashSet getProjects() { + return projects; + } + + public void setProjects(HashSet projects) { + this.projects = projects; + } + + public Insurance getInsurance() { + return insurance; + } + + public void setInsurance(Insurance insurance) { + this.insurance = insurance; + } + + public Department getDepartment() { + return department; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Employee getManager() { + return manager; + } + + public void setManager(Employee manager) { + this.manager = manager; + } + + public HashSet getTeam() { + return team; + } + + public void setTeam(HashSet team) { + this.team = team; + } + + public Employee getMentor() { + return mentor; + } + + public void setMentor(Employee mentor) { + this.mentor = mentor; + } + + public Employee getProtege() { + return protege; + } + + public void setProtege(Employee protege) { + this.protege = protege; + } + + public Employee getHradvisor() { + return hradvisor; + } + + public void setHradvisor(Employee hradvisor) { + this.hradvisor = hradvisor; + } + + public HashSet getHradvisees() { + return hradvisees; + } + + public void setHradvisees(HashSet hradvisees) { + this.hradvisees = hradvisees; + } + + protected void addFieldRepr(StringBuffer repr) + { + super.addFieldRepr(repr); + repr.append(", empid="); repr.append(empid); + repr.append(", hiredate="); repr.append(hiredate); + repr.append(", weeklyhours="); repr.append(weeklyhours); + repr.append(", reviewedProjects="); repr.append(((reviewedProjects==null) ? 0 : reviewedProjects.size())); + repr.append(", projects="); repr.append(((projects==null) ? 0 : projects.size())); + repr.append(", insurance="); repr.append(((insurance==null) ? "null" : insurance.getCarrier())); + repr.append(", department="); repr.append(((department==null) ? "null" : department.getName())); + repr.append(", manager="); repr.append(((manager==null) ? "null" : manager.getLastname())); + repr.append(", team="); repr.append(((team==null) ? 0 : team.size())); + repr.append(", mentor="); repr.append(((mentor==null) ? "null" : mentor.getLastname())); + repr.append(", protege="); repr.append(((protege==null) ? "null" : protege.getLastname())); + repr.append(", hradvisor="); repr.append(((hradvisor==null) ? "null" : hradvisor.getLastname())); + repr.append(", hradvisees="); repr.append(((hradvisees ==null) ? 0 : hradvisees.size())); + } + + public static class Oid implements Serializable, Comparable { + + 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 ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherEmpid = ((Oid)o).empid; + if (empid == otherEmpid) + return 0; + else if (empid < otherEmpid) + return -1; + return 1; + } + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Employee.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Employee" + identity-type="datastore" + persistence-capable-superclass="Person"> + <field name="empid"/> + <field name="hiredate"/> + <field name="weeklyhours"/> + <field name="discriminator"/> + <field name="reviewedProjects"> + <collection element-type="Project"/> + </field> + <field name="projects"> + <collection element-type="Project"/> + </field> + <field name="insurance" persistence-modifier="persistent"/> + <field name="department" persistence-modifier="persistent"/> + <field name="manager" persistence-modifier="persistent"/> + <field name="team"> + <collection element-type="Employee"/> + </field> + <field name="mentor" persistence-modifier="persistent"/> + <field name="protege" persistence-modifier="persistent"/> + <field name="hradvisor" persistence-modifier="persistent"/> + <field name="hradvisees" persistence-modifier="persistent"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,77 @@ +/* + * 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.xempdept; + +import java.util.HashSet; +import java.util.Date; + +public class FullTimeEmployee + extends Employee +{ + private double salary; + + public String toString() + { + StringBuffer repr = new StringBuffer(); + addFieldRepr(repr); + return "FullTimeEmployee(" + repr.toString() + ")"; + } + + public FullTimeEmployee() {} + + public FullTimeEmployee(long empid, + String lastname, + String firstname, + Date hiredate, + Date birthdate, + double weeklyhours, + char discriminator, + HashSet reviewedProjects, + HashSet projects, + Insurance insurance, + Department department, + Employee manager, + HashSet team, + Employee mentor, + Employee protege, + Employee hradvisor, + HashSet hradvisees, + double salary) + { + super(empid, lastname, firstname, hiredate, birthdate, weeklyhours, + discriminator, reviewedProjects, projects, insurance, department, + manager, team, mentor, protege, hradvisor, hradvisees); + this.salary = salary; + } + + public double getSalary() + { + return salary; + } + + public void setSalary(double salary) + { + this.salary = salary; + } + + protected void addFieldRepr(StringBuffer repr) + { + super.addFieldRepr(repr); + repr.append(", salary="); repr.append(salary); + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/FullTimeEmployee.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="FullTimeEmployee" + identity-type="datastore" + persistence-capable-superclass="Employee"> + <field name="salary"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Identifiable.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Identifiable.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Identifiable.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Identifiable.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,22 @@ +/* + * 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.xempdept; + +public interface Identifiable +{ + public Object getOid(); +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,112 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.HashSet; + +public class Insurance implements Serializable, Identifiable { + + private long insid; + private String carrier; + private Employee employee; + + public Object getOid() { + Oid oid = new Oid(); + oid.insid = this.insid; + return oid; + } + + public String toString() { + return "Insurance(" + carrier + + ", insid=" + insid + + ", employee=" + ((employee==null) ? "null" : employee.getLastname()) + + ")"; + } + + public Insurance() { + } + + public Insurance(long insid, + String carrier, + Employee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = employee; + } + + 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 Employee getEmployee() { + return employee; + } + + public void setEmployee(Employee employee) { + this.employee = employee; + } + + public static class Oid implements Serializable, Comparable { + + 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 ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherInsid = ((Oid)o).insid; + if (insid == otherInsid) + return 0; + else if (insid < otherInsid) + return -1; + return 1; + } + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Insurance.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Insurance" + identity-type="datastore"> + <field name="insid"/> + <field name="carrier"/> + <field name="employee" persistence-modifier="persistent"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,77 @@ +/* + * 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.xempdept; + +import java.util.HashSet; +import java.util.Date; + +public class PartTimeEmployee + extends Employee +{ + private double wage; + + public String toString() + { + StringBuffer repr = new StringBuffer(); + addFieldRepr(repr); + return "PartTimeEmployee(" + repr.toString() + ")"; + } + + public PartTimeEmployee() {} + + public PartTimeEmployee(long empid, + String lastname, + String firstname, + Date hiredate, + Date birthdate, + double weeklyhours, + char discriminator, + HashSet reviewedProjects, + HashSet projects, + Insurance insurance, + Department department, + Employee manager, + HashSet team, + Employee mentor, + Employee protege, + Employee hradvisor, + HashSet hradvisees, + double wage) + { + super(empid, lastname, firstname, hiredate, birthdate, weeklyhours, + discriminator, reviewedProjects, projects, insurance, department, + manager, team, mentor, protege, hradvisor, hradvisees); + this.wage = wage; + } + + public double getWage() + { + return wage; + } + + public void setWage(double wage) + { + this.wage = wage; + } + + protected void addFieldRepr(StringBuffer repr) + { + super.addFieldRepr(repr); + repr.append(", wage="); repr.append(wage); + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PartTimeEmployee.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="PartTimeEmployee" + identity-type="datastore" + persistence-capable-superclass="Employee"> + <field name="wage"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,71 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.Date; + +public abstract class Person + implements Serializable +{ + private String lastname; + private String firstname; + private Date birthdate; + + public Person() {} + + public Person(String lastname, + String firstname, + Date birthdate) + { + this.lastname = lastname; + this.firstname = firstname; + this.birthdate = birthdate; + } + + 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 Date getBirthdate() { + return birthdate; + } + + public void setBirthdate(Date birthdate) { + this.birthdate = birthdate; + } + + protected void addFieldRepr(StringBuffer repr) + { + repr.append("firstname="); repr.append(firstname); + repr.append(", lastname="); repr.append(lastname); + repr.append(", birthdate="); repr.append(birthdate); + } +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Person.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Person" + identity-type="datastore"> + <field name="lastname"/> + <field name="firstname"/> + <field name="birthdate"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,321 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Date; +import java.math.BigDecimal; +import java.math.BigInteger; + +public class PrimitiveTypes implements Serializable, Identifiable { + + private long id; + private boolean booleanNotNull; + private Boolean booleanNull; + private byte byteNotNull; + private Byte byteNull; + private short shortNotNull; + private Short shortNull; + private int intNotNull; + private Integer intNull; + private long longNotNull; + private Long longNull; + private float floatNotNull; + private Float floatNull; + private double doubleNotNull; + private Double doubleNull; + private char charNotNull; + private Character charNull; + private Date dateNull; + private String stringNull; + private BigDecimal bigDecimal; + private BigInteger bigInteger; + private Long PrimitiveTypes; + + public Object getOid() { + Oid oid = new Oid(); + oid.id = this.id; + return oid; + } + + public String toString() { + return "PrimitiveTypes(" + id + ")"; + } + + public PrimitiveTypes() { + } + + public PrimitiveTypes(long id, + boolean booleanNotNull, + Boolean booleanNull, + byte byteNotNull, + Byte byteNull, + short shortNotNull, + Short shortNull, + int intNotNull, + Integer intNull, + long longNotNull, + Long longNull, + float floatNotNull, + Float floatNull, + double doubleNotNull, + Double doubleNull, + char charNotNull, + Character charNull, + Date dateNull, + String stringNull, + BigDecimal bigDecimal, + BigInteger bigInteger, + Long PrimitiveTypes) { + this.id = id; + this.booleanNotNull = booleanNotNull; + this.booleanNull = booleanNull; + this.byteNotNull = byteNotNull; + this.byteNull = byteNull; + this.shortNotNull = shortNotNull; + this.shortNull = shortNull; + this.intNotNull = intNotNull; + this.intNull = intNull; + this.longNotNull = longNotNull; + this.longNull =longNull; + this.floatNotNull = floatNotNull; + this.floatNull =floatNull; + this.doubleNotNull = doubleNotNull; + this.doubleNull = doubleNull; + this.charNotNull = charNotNull; + this.charNull = charNull; + this.dateNull = dateNull; + this.stringNull = stringNull; + this.bigDecimal = bigDecimal; + this.bigInteger = bigInteger; + this.PrimitiveTypes = PrimitiveTypes; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public boolean getBooleanNotNull() { + return booleanNotNull; + } + + public void setBooleanNotNull(boolean booleanNotNull) { + this.booleanNotNull = booleanNotNull; + } + + public Boolean getBooleanNull() { + return booleanNull; + } + + public void setBooleanNull(Boolean booleanNull) { + this.booleanNull = booleanNull; + } + + public byte getByteNotNull() { + return byteNotNull; + } + + public void setByteNotNull(byte byteNotNull) { + this.byteNotNull = byteNotNull; + } + + public Byte getByteNull() { + return byteNull; + } + + public void setByteNull(Byte byteNull) { + this.byteNull = byteNull; + } + + public short getShortNotNull() { + return shortNotNull; + } + + public void setShortNotNull(short shortNotNull) { + this.shortNotNull = shortNotNull; + } + + public Short getShortNull() { + return shortNull; + } + + public void setShortNull(Short shortNull) { + this.shortNull = shortNull; + } + + public int getIntNotNull() { + return intNotNull; + } + + public void setIntNotNull(int intNotNull) { + this.intNotNull = intNotNull; + } + + public Integer getIntNull() { + return intNull; + } + + public void setIntNull(Integer intNull) { + this.intNull = intNull; + } + + public long getLongNotNull() { + return longNotNull; + } + + public void setLongNotNull(long longNotNull) { + this.longNotNull = longNotNull; + } + + public Long getLongNull() { + return longNull; + } + + public void setLongNull(Long longNull) { + this.longNull = longNull; + } + + public float getFloatNotNull() { + return floatNotNull; + } + + public void setFloatNotNull(float floatNotNull) { + this.floatNotNull = floatNotNull; + } + + public Float getFloatNull() { + return floatNull; + } + + public void setFloatNull(Float floatNull) { + this.floatNull = floatNull; + } + + public double getDoubleNotNull() { + return doubleNotNull; + } + + public void setDoubleNotNull(double doubleNotNull) { + this.doubleNotNull = doubleNotNull; + } + + public Double getDoubleNull() { + return doubleNull; + } + + public void setDoubleNull(Double doubleNull) { + this.doubleNull = doubleNull; + } + + public char getCharNotNull() { + return charNotNull; + } + + public void setCharNotNull(char charNotNull) { + this.charNotNull = charNotNull; + } + + public Character getCharNull() { + return charNull; + } + + public void setCharNull(Character charNull) { + this.charNull = charNull; + } + + public Date getDateNull() { + return dateNull; + } + + public void setDateNull(Date dateNull) { + this.dateNull = dateNull; + } + + public String getStringNull() { + return stringNull; + } + + public void setStringNull(String stringNull) { + this.stringNull = stringNull; + } + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + public BigInteger getBigInteger() { + return bigInteger; + } + + public void setBigInteger(BigInteger bigInteger) { + this.bigInteger = bigInteger; + } + + public Long getPrimitiveTypes() { + return PrimitiveTypes; + } + + public void setPrimitiveTypes(Long primitiveTypes) { + this.PrimitiveTypes = PrimitiveTypes; + } + + public static class Oid implements Serializable, Comparable { + + public long id; + + 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.id!=o.id ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += id; + return( hashCode ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherId = ((Oid)o).id; + if (id == otherId) + return 0; + else if (id < otherId) + return -1; + return 1; + } + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/PrimitiveTypes.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="PrimitiveTypes" + identity-type="datastore"> + <field name="id"/> + <field name="booleanNotNull"/> + <field name="booleanNull"/> + <field name="byteNotNull"/> + <field name="byteNull"/> + <field name="shortNotNull"/> + <field name="shortNull"/> + <field name="intNotNull"/> + <field name="intNull"/> + <field name="longNotNull"/> + <field name="longNull"/> + <field name="floatNotNull"/> + <field name="floatNull"/> + <field name="doubleNotNull"/> + <field name="doubleNull"/> + <field name="charNotNull"/> + <field name="charNull"/> + <field name="dateNull"/> + <field name="stringNull"/> + <field name="bigDecimal"/> + <field name="bigInteger"/> + <field name="PrimitiveTypes"/> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,138 @@ +/* + * 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.xempdept; + +import java.io.Serializable; +import java.util.HashSet; +import java.math.BigDecimal; + +public class Project implements Serializable, Identifiable { + + private long projid; + private String name; + private BigDecimal budget; + private HashSet reviewers; + private HashSet employees; + + public Object getOid() { + Oid oid = new Oid(); + oid.projid = this.projid; + return oid; + } + + public String toString() { + return "Project(" + name + + ", projid=" + projid + + ", budget=" + budget + + ", reviewers=" + ((reviewers==null) ? 0 : reviewers.size()) + + ", employees=" + ((employees==null) ? 0 : employees.size()) + + ")"; + } + + public Project() { + } + + public Project(long projid, + String name, + BigDecimal budget, + HashSet reviewers, + HashSet employees) { + this.projid = projid; + this.name = name; + this.budget = budget; + this.reviewers = reviewers; + this.employees = employees; + } + + public long getProjid() { + return projid; + } + + public void setProjid(long projid) { + this.projid = projid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public BigDecimal getBudget() { + return budget; + } + + public void setBudget(BigDecimal budget) { + this.budget = budget; + } + + public HashSet getReviewers() { + return reviewers; + } + + public void setReviewers(HashSet reviewers) { + this.reviewers = reviewers; + } + + public HashSet getEmployees() { + return employees; + } + + public void setEmployees(HashSet employees) { + this.employees = employees; + } + + public static class Oid implements Serializable, Comparable { + + public long projid; + + 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.projid!=o.projid ) return( false ); + return( true ); + } + + public int hashCode() { + int hashCode=0; + hashCode += projid; + return( hashCode ); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherProjid = ((Oid)o).projid; + if (projid == otherProjid) + return 0; + else if (projid < otherProjid) + return -1; + return 1; + } + + } + +} + Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.jdo URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.jdo?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.jdo (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/Project.jdo Fri Mar 18 17:02:29 2005 @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd"> +<jdo> + <package name="org.apache.jdo.pc.xempdept"> + <class name="Project" + identity-type="datastore"> + <field name="projid"/> + <field name="name"/> + <field name="budget"/> + <field name="reviewers"> + <collection element-type="Employee"/> + </field> + <field name="employees"> + <collection element-type="Employee"/> + </field> + </class> + </package> +</jdo> Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jdoproperties URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jdoproperties?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jdoproperties (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jdoproperties Fri Mar 18 17:02:29 2005 @@ -0,0 +1,99 @@ +# Classnames can have the following attributes: +# jdo:{persistent|transient} +# super: <classname> +# oid: <classname> +# access: {public|protected|package|private} +# Fieldnames can have the following attributes: +# type:<type> +# access: {public|protected|package|private} +# jdo:{persistent|transactional|transient} +# annotation:{key|dfg|mediated} + +org.apache.jdo.pc.xempdept.Company=jdo:persistent +org.apache.jdo.pc.xempdept.Company#name=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Company#founded=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Company#address=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Company#departments=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Department=jdo:persistent +org.apache.jdo.pc.xempdept.Department#deptid=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Department#name=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Department#company=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Department#employees=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Person=jdo:persistent +org.apache.jdo.pc.xempdept.Person#firstname=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Person#lastname=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Person#birthdate=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Employee=jdo:persistent,super:org.apache.jdo.pc.xempdept.Person +org.apache.jdo.pc.xempdept.Employee#empid=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#hiredate=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#weeklyhours=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#discriminator=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#reviewedProjects=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#projects=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#insurance=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#department=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#manager=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#team=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#mentor=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#protege=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#hradvisor=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Employee#hradvisees=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.FullTimeEmployee=jdo:persistent,super:org.apache.jdo.pc.xempdept.Employee +org.apache.jdo.pc.xempdept.FullTimeEmployee#salary=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.PartTimeEmployee=jdo:persistent,super:org.apache.jdo.pc.xempdept.Employee +org.apache.jdo.pc.xempdept.PartTimeEmployee#wage=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Insurance=jdo:persistent +org.apache.jdo.pc.xempdept.Insurance#insid=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Insurance#carrier=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Insurance#employee=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Project=jdo:persistent +org.apache.jdo.pc.xempdept.Project#projid=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Project#name=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Project#budget=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Project#reviewers=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.Project#employees=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.PrimitiveTypes=jdo:persistent +org.apache.jdo.pc.xempdept.PrimitiveTypes#id=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#booleanNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#booleanNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#byteNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#byteNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#shortNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#shortNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#intNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#intNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#longNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#longNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#floatNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#floatNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#doubleNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#doubleNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#charNotNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#charNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#dateNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#stringNull=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#bigDecimal=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#bigInteger=jdo:persistent,annotation:mediated +org.apache.jdo.pc.xempdept.PrimitiveTypes#PrimitiveTypes=jdo:persistent,annotation:mediated + +org.apache.jdo.pc.xempdept.Company$Oid=jdo:transient +org.apache.jdo.pc.xempdept.Company$Oid#name=jdo:transient +org.apache.jdo.pc.xempdept.Company$Oid#founded=jdo:transient +org.apache.jdo.pc.xempdept.Department$Oid=jdo:transient +org.apache.jdo.pc.xempdept.Department$Oid#deptid=jdo:transient +org.apache.jdo.pc.xempdept.Employee$Oid=jdo:transient +org.apache.jdo.pc.xempdept.Employee$Oid#empid=jdo:transient +org.apache.jdo.pc.xempdept.Project$Oid=jdo:transient +org.apache.jdo.pc.xempdept.Project$Oid#projid=jdo:transient +org.apache.jdo.pc.xempdept.Insurance$Oid=jdo:transient +org.apache.jdo.pc.xempdept.Insurance$Oid#insid=jdo:transient +org.apache.jdo.pc.xempdept.PrimitiveTypes$Oid=jdo:transient +org.apache.jdo.pc.xempdept.PrimitiveTypes$Oid#id=jdo:transient Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jpg URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jpg?view=auto&rev=158176 ============================================================================== Binary file - no diff available. Propchange: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jpg ------------------------------------------------------------------------------ svn:executable = * Propchange: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/pc/xempdept/xempdept.jpg ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/EmpDeptSupport.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/EmpDeptSupport.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/EmpDeptSupport.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/EmpDeptSupport.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,177 @@ +/* + * 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.test; + +import java.util.*; + +import javax.jdo.*; + +import org.apache.jdo.test.util.AbstractTest; + +import org.apache.jdo.pc.empdept.PCDepartment; +import org.apache.jdo.pc.empdept.PCEmployee; +import org.apache.jdo.pc.empdept.PCFullTimeEmployee; +import org.apache.jdo.pc.empdept.PCInsurance; +import org.apache.jdo.pc.empdept.PCPartTimeEmployee; +import org.apache.jdo.pc.empdept.PCProject; + +/** +* This class is the superclass for test classes Test_Inheritance and +* Test_StringOID and provides common code. +* +* @author Michael Bouschen +*/ +class EmpDeptSupport extends AbstractTest { + + protected HashSet persistentInstances = new HashSet (9); + + // We override this from AbstractTest and insert our own objects. + // Use Test_Extent to read them back. + protected void insertObjects() { + PersistenceManager pm = null; + Transaction tx = null; + try { + pm = pmf.getPersistenceManager(); + tx = pm.currentTransaction(); + tx.begin(); + createObjects(pm); + checkObjects(pm); + tx.commit(); + } + finally { + if (tx != null && tx.isActive()) + tx.rollback(); + if (pm != null && !pm.isClosed()) + pm.close(); + } + } + + protected void createObjects(PersistenceManager pm) { + // Create and set up employees. Scott is Ed's manager. Ed is + // Scott's sole employee. + // + HashSet h; + + GregorianCalendar born = + new GregorianCalendar(TimeZone.getTimeZone("America/New_York")); + GregorianCalendar hired = + new GregorianCalendar(TimeZone.getTimeZone("America/New_York")); + + born.set(1969, 7, 20); + hired.set(1982, 5, 5); + PCEmployee scott = + new PCFullTimeEmployee( + "Scott", "McNealy", born.getTime(), + 1L, hired.getTime(), + 200000.0); + born.set(1960, 4, 8); + hired.set(1985, 2, 3); + PCEmployee ed = + new PCPartTimeEmployee( + "Ed", "Zander", born.getTime(), + 100L, hired.getTime(), + 400000.0); + + ed.setManager(scott); + + h = new HashSet(); + h.add(ed); + scott.setEmployees(h); + + // Set up their departments. + PCDepartment board = + new PCDepartment(100L, "board"); + h = new HashSet(); + h.add(scott); + board.setEmployees(h); + scott.setDepartment(board); + + PCDepartment emg = + new PCDepartment(200L, "emg"); + h = new HashSet(); + h.add(ed); + emg.setEmployees(h); + ed.setDepartment(emg); + + // Insure these guys + PCInsurance scottIns = new PCInsurance(1000, "Aetna", scott); + PCInsurance edIns = new PCInsurance(1001, "BlueCross", ed); + scott.setInsurance(scottIns); + ed.setInsurance(edIns); + + // Give them some projects to work on. Scott works on both; Ed only + // on one. + PCProject solaris = new PCProject(1L, "Solaris"); + PCProject sparc = new PCProject(2L, "Sparc"); + h = new HashSet(); + h.add(scott); + h.add(ed); + solaris.setEmployees(h); // Solaris is worked on by Scott and Ed + + h = new HashSet(); + h.add(scott); + sparc.setEmployees(h); // Sparc is worked on by Scott + + h = new HashSet(); + h.add(solaris); + h.add(sparc); + scott.setProjects(h); // Scott works on Solaris and Sparc + + h = new HashSet(); + h.add(solaris); + ed.setProjects(h); // Ed works on Solaris + + // Show what we've got + if (debug) { + logger.debug("Before insert: "); + logger.debug(scott.toString()); + logger.debug(ed.toString()); + logger.debug(board.toString()); + logger.debug(emg.toString()); + logger.debug(scottIns.toString()); + logger.debug(edIns.toString()); + logger.debug(solaris.toString()); + logger.debug(sparc.toString()); + } + + // Make it all persistent. If reachability were implemented, we'd + // only have to make scott and ed persistent, as everything else is + // reachable from them. + pm.makePersistent(scott); + persistentInstances.add(scott); + pm.makePersistent(ed); + persistentInstances.add(ed); + pm.makePersistent(board); + persistentInstances.add(board); + pm.makePersistent(emg); + persistentInstances.add(emg); + pm.makePersistent(scottIns); + persistentInstances.add(scottIns); + pm.makePersistent(edIns); + persistentInstances.add(edIns); + pm.makePersistent(solaris); + persistentInstances.add(solaris); + pm.makePersistent(sparc); + persistentInstances.add(sparc); + } + + /** This method can be overridden by a subclass to perform special checks. + */ + protected void checkObjects(PersistenceManager pm) { + } + +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Point.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Point.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Point.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Point.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,71 @@ +/* + * 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.test; + +import org.apache.jdo.test.util.Util; + +/** +* A simple class with two fields +* +* @author Dave Bristor +*/ +public class Point { + public int x; + public Integer y; + + public Point() { } + + public Point(int x, int y) { + this.x = x; + this.y = new Integer(y); + } + + public Point(int x, Integer y) { + this.x = x; + this.y = y; + } + + public String toString() { + String rc = null; + try { + rc = Util.getClassName(this) + name(); + } catch (NullPointerException ex) { + rc = "NPE getting Point's values"; + } + return rc; + } + + void setX(int x) { + this.x = x; + } + + public int getX() { + return x; + } + + void setY(Integer y) { + this.y = y; + } + + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4510817.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4510817.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4510817.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4510817.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,57 @@ +/* + * 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.test; + +import javax.jdo.PersistenceManager; + +import org.apache.jdo.test.util.AbstractTest; +import org.apache.jdo.test.util.JDORITestRunner; + +/** + * Test fix for bug 4510817: Ensure that PersistenceManager.getObjectIdClass + * returns null when given class does not implement PersistenceCapable or is + * null. + */ +public class Test_4510817 extends AbstractTest { + + /** */ + public static void main(String args[]) { + JDORITestRunner.run(Test_4510817.class); + } + + /** */ + public void test() { + PersistenceManager pm = pmf.getPersistenceManager(); + + try { + // First case: Given class does not implement PersistenceCapable. + Class c1 = pm.getObjectIdClass(Thread.class); + assertNull("ObjectIdClass for Thread.class is not null: " + c1, c1); + + // Second case: Given parameter is null. + Class c2 = pm.getObjectIdClass(null); + assertNull("ObjectIdClass for null is not null: " + c2, c2); + + if (debug) + logger.debug("Success: ObjectIdClass for Thread.class and null returns null"); + } + finally { + if (pm != null && !pm.isClosed()) + pm.close(); + } + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4515265.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4515265.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4515265.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_4515265.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,96 @@ +/* + * 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.test; + +import javax.jdo.*; + +import org.apache.jdo.test.util.AbstractTest; +import org.apache.jdo.test.util.JDORITestRunner; + +/** + * Test fix for bug 4515265: StoreManager.getClassForOid must throw + * JDOUserException if given parameter is not an OID (spec section 12.5.6). + */ +public class Test_4515265 extends AbstractTest { + + /** */ + public static void main(String args[]) { + JDORITestRunner.run(Test_4515265.class); + } + + // Test different wrong cases of application identity: + class PCPointKey { + int x; + Integer y; + + PCPointKey(int _x, int _y) { + x = _x; + y = new Integer(_y); + } + } + + class Oid { + int x; + Integer y; + + Oid(int _x, int _y) { + x = _x; + y = new Integer(_y); + } + } + + public void test() { + Oid oid = new Oid(1, 1); + PCPointKey key = new PCPointKey(1, 1); + + PersistenceManager pm = pmf.getPersistenceManager(); + + try { + try { + pm.getObjectById(key, true); + fail("getObjectById should throw an exception or non-existing PC Class."); + } catch (JDOUserException ex) { + // expected exception => OK + if (debug) + logger.debug("Caught expected JDOUserException for non-existing PC Class."); + } + + try { + pm.getObjectById(oid, true); + fail("getObjectById should throw an exception for non-PC Class."); + } catch (JDOUserException ex) { + // expected exception => OK + if (debug) + logger.debug("Caught expected JDOUserException for non-PC Class."); + } + + try { + pm.getObjectById(this, true); + fail("getObjectById should throw an exception for wrong OID Class name."); + } catch (JDOUserException ex) { + // expected exception => OK + if (debug) + logger.debug("Caught expected JDOUserException for wrong OID Class name."); + } + } + finally { + if (pm != null && !pm.isClosed()) + pm.close(); + } + + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_6214617.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_6214617.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_6214617.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_6214617.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,56 @@ +/* + * 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.test; + +import javax.jdo.PersistenceManager; +import javax.jdo.JDOUserException; + +import org.apache.jdo.test.util.AbstractTest; +import org.apache.jdo.test.util.JDORITestRunner; + +/** + * Test fix for bug 6214617: the pm is still open after pm.close fails + * because of an active transaction. + */ +public class Test_6214617 extends AbstractTest { + + /** */ + public static void main(String args[]) { + JDORITestRunner.run(Test_6214617.class); + } + + /** */ + public void test() { + PersistenceManager pm = pmf.getPersistenceManager(); + try { + pm.currentTransaction().begin(); + pm.close(); // fails because tx is still active + } + catch (JDOUserException ex) { + // expected exception: cannot close pm while tx is active + if (debug) + logger.debug("Caught expected JDOUserException cannot close pm while tx is active"); + } + finally { + // should succeed + pm.currentTransaction().rollback(); + pm.close(); + if (debug) + logger.debug("Could rollback tx and close pm"); + } + } +} Added: incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_ActivateClass.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_ActivateClass.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_ActivateClass.java (added) +++ incubator/jdo/trunk/ri11/test/java/org/apache/jdo/test/Test_ActivateClass.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,55 @@ +/* + * 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.test; + +import org.apache.jdo.test.util.AbstractTest; +import org.apache.jdo.test.util.JDORITestRunner; + +import org.apache.jdo.test.util.Factory; +import org.apache.jdo.pc.PointFactory; + +/** +* Tests that we can activate a class. Actually goes farther than that, +* storing the value of an instance of a class, since that's the only way we can +* cause a class to be activated. +* +* @author Dave Bristor +*/ +public class Test_ActivateClass extends AbstractTest { + + /** */ + public static void main(String args[]) { + JDORITestRunner.run(Test_ActivateClass.class); + } + + /** + * Inserts some number of objects in the database + */ + public void test() throws Exception { + insertObjects(); + } + + /** + * Determines the kind of objects that are inserted. Override this if + * you want to insert some other kind of object. + */ + protected Factory getFactory(int verify) { + PointFactory rc = new PointFactory(); + rc.setVerify(verify); + return rc; + } +}