Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 71780 invoked from network); 21 Apr 2010 20:42:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Apr 2010 20:42:49 -0000 Received: (qmail 83936 invoked by uid 500); 21 Apr 2010 20:42:49 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 83879 invoked by uid 500); 21 Apr 2010 20:42:49 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 83872 invoked by uid 99); 21 Apr 2010 20:42:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Apr 2010 20:42:49 +0000 X-ASF-Spam-Status: No, hits=-1218.3 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Apr 2010 20:42:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3EA5923889E7; Wed, 21 Apr 2010 20:42:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r936497 - in /openjpa/trunk/openjpa-xmlstore: ./ src/main/java/org/apache/openjpa/xmlstore/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/openjpa/ src/test/java/org/apache/openjpa/xmlstore/ s... Date: Wed, 21 Apr 2010 20:42:05 -0000 To: commits@openjpa.apache.org From: dwoods@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100421204205.3EA5923889E7@eris.apache.org> Author: dwoods Date: Wed Apr 21 20:42:04 2010 New Revision: 936497 URL: http://svn.apache.org/viewvc?rev=936497&view=rev Log: OPENJPA-1639 Create some simple openjpa-xmlstore tests Added: openjpa/trunk/openjpa-xmlstore/src/test/ openjpa/trunk/openjpa-xmlstore/src/test/java/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java (with props) openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java (with props) openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java (with props) openjpa/trunk/openjpa-xmlstore/src/test/resources/ openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/ openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml (with props) Modified: openjpa/trunk/openjpa-xmlstore/pom.xml openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java Modified: openjpa/trunk/openjpa-xmlstore/pom.xml URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/pom.xml?rev=936497&r1=936496&r2=936497&view=diff ============================================================================== --- openjpa/trunk/openjpa-xmlstore/pom.xml (original) +++ openjpa/trunk/openjpa-xmlstore/pom.xml Wed Apr 21 20:42:04 2010 @@ -21,23 +21,106 @@ Maven release plugin requires the project tag to be on a single line. --> + 4.0.0 - org.apache.openjpa - openjpa-xmlstore - jar - OpenJPA XML Store - OpenJPA XML Store - http://openjpa.apache.org + org.apache.openjpa openjpa-parent 2.1.0-SNAPSHOT + + org.apache.openjpa + openjpa-xmlstore + jar + OpenJPA XML Store + OpenJPA XML Store + org.apache.openjpa openjpa-kernel ${pom.version} + + org.apache.openjpa + openjpa-persistence-jdbc + ${pom.version} + + test-jar + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + attach-tests + verify + + test-jar + + + + + + + + org.codehaus.mojo + openjpa-maven-plugin + 1.1 + + org/apache/openjpa/xmlstore/**/Test*.class + org/apache/openjpa/persistence/**/*.class + true + true + + + + enhancer + process-test-classes + + test-enhance + + + + + + org.apache.openjpa + openjpa + ${pom.version} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + ${test.jvm.arguments} + + + openjpa.Log + ${openjpa.Log} + + + openjpa.DynamicEnhancementAgent + false + + + tests.openjpa.allowfailure + ${tests.openjpa.allowfailure} + + + + + + + + Modified: openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java?rev=936497&r1=936496&r2=936497&view=diff ============================================================================== --- openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java (original) +++ openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java Wed Apr 21 20:42:04 2010 @@ -116,6 +116,9 @@ public class XMLFileHandler { * configuration property. */ private File getFile(ClassMetaData meta) { + if (_conf.getConnectionURL() == null) { + throw new InternalException("Invalid ConnectionURL"); + } File baseDir = new File(_conf.getConnectionURL()); return new File(baseDir, meta.getDescribedType().getName()); } Added: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java?rev=936497&view=auto ============================================================================== --- openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java (added) +++ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java Wed Apr 21 20:42:04 2010 @@ -0,0 +1,368 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.openjpa.xmlstore.simple; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import javax.persistence.Entity; +import javax.persistence.OneToOne; +import javax.persistence.OneToMany; + +import org.apache.openjpa.persistence.PersistentCollection; + +@Entity +public class AllFieldTypes implements Serializable { + + private static final long serialVersionUID = 1L; + + public static enum EnumType {Value1, Value2}; + + // @Basic types + private short shortField; + private int intField; + private boolean booleanField; + private long longField; + private float floatField; + private char charField; + private double doubleField; + private byte byteField; + private Short wShortField; + private Integer wIntegerField; + private Boolean wBooleanField; + private Long wLongField; + private Float wFloatField; + private Character wCharacterField; + private Double wDoubleField; + private Byte wByteField; + private BigInteger bigIntegerField; + private BigDecimal bigDecimalField; + private String stringField; + private Date dateField; + private Calendar calendarField; + private java.sql.Date sqlDateField; + private java.sql.Time sqlTimeField; + private java.sql.Timestamp sqlTimestampField; + private byte[] byteLob; + private Byte[] wByteLob; + private char[] charLob; + private Character[] wCharacterLob; + private EnumType enumField; + private Serializable serializableField; + + // Additional types + private Set setOfStrings = new HashSet(); + private String[] arrayOfStrings; + + @PersistentCollection + private int[] arrayOfInts; + + // one-to-one and one-to-many relations to self + @OneToOne + private AllFieldTypes selfOneOne; + @OneToMany + private List selfOneMany = new ArrayList(); + + public void setShortField(short shortField) { + this.shortField = shortField; + } + + public short getShortField() { + return this.shortField; + } + + public void setIntField(int intField) { + this.intField = intField; + } + + public int getIntField() { + return this.intField; + } + + public void setBooleanField(boolean booleanField) { + this.booleanField = booleanField; + } + + public boolean getBooleanField() { + return this.booleanField; + } + + public void setLongField(long longField) { + this.longField = longField; + } + + public long getLongField() { + return this.longField; + } + + public void setFloatField(float floatField) { + this.floatField = floatField; + } + + public float getFloatField() { + return this.floatField; + } + + public void setCharField(char charField) { + this.charField = charField; + } + + public char getCharField() { + return this.charField; + } + + public void setDoubleField(double doubleField) { + this.doubleField = doubleField; + } + + public double getDoubleField() { + return this.doubleField; + } + + public void setByteField(byte byteField) { + this.byteField = byteField; + } + + public byte getByteField() { + return this.byteField; + } + + public void setStringField(String stringField) { + this.stringField = stringField; + } + + public String getStringField() { + return this.stringField; + } + + public void setDateField(Date dateField) { + this.dateField = dateField; + } + + public Date getDateField() { + return this.dateField; + } + + public void setSetOfStrings(Set setOfStrings) { + this.setOfStrings = setOfStrings; + } + + public Set getSetOfStrings() { + return this.setOfStrings; + } + + public void setArrayOfStrings(String[] arrayOfStrings) { + this.arrayOfStrings = arrayOfStrings; + } + + public String[] getArrayOfStrings() { + return this.arrayOfStrings; + } + + public void setArrayOfInts(int[] arrayOfInts) { + this.arrayOfInts = arrayOfInts; + } + + public int[] getArrayOfInts() { + return arrayOfInts; + } + + public BigDecimal getBigDecimalField() { + return bigDecimalField; + } + + public void setBigDecimalField(BigDecimal bigDecimalField) { + this.bigDecimalField = bigDecimalField; + } + + public BigInteger getBigIntegerField() { + return bigIntegerField; + } + + public void setBigIntegerField(BigInteger bigIntegerField) { + this.bigIntegerField = bigIntegerField; + } + + public byte[] getByteLob() { + return byteLob; + } + + public void setByteLob(byte[] byteLob) { + this.byteLob = byteLob; + } + + public Calendar getCalendarField() { + return calendarField; + } + + public void setCalendarField(Calendar calendarField) { + this.calendarField = calendarField; + } + + public char[] getCharLob() { + return charLob; + } + + public void setCharLob(char[] charLob) { + this.charLob = charLob; + } + + public EnumType getEnumField() { + return enumField; + } + + public void setEnumField(EnumType enumField) { + this.enumField = enumField; + } + + public Serializable getSerializableField() { + return serializableField; + } + + public void setSerializableField(Serializable serializableField) { + this.serializableField = serializableField; + } + + public java.sql.Date getSqlDateField() { + return sqlDateField; + } + + public void setSqlDateField(java.sql.Date sqlDateField) { + this.sqlDateField = sqlDateField; + } + + public java.sql.Time getSqlTimeField() { + return sqlTimeField; + } + + public void setSqlTimeField(java.sql.Time sqlTimeField) { + this.sqlTimeField = sqlTimeField; + } + + public java.sql.Timestamp getSqlTimestampField() { + return sqlTimestampField; + } + + public void setSqlTimestampField(java.sql.Timestamp sqlTimestampField) { + this.sqlTimestampField = sqlTimestampField; + } + + public Boolean getWBooleanField() { + return wBooleanField; + } + + public void setWBooleanField(Boolean booleanField) { + wBooleanField = booleanField; + } + + public Byte getWByteField() { + return wByteField; + } + + public void setWByteField(Byte byteField) { + wByteField = byteField; + } + + public Byte[] getWByteLob() { + return wByteLob; + } + + public void setWByteLob(Byte[] byteLob) { + wByteLob = byteLob; + } + + public Character getWCharacterField() { + return wCharacterField; + } + + public void setWCharacterField(Character characterField) { + wCharacterField = characterField; + } + + public Character[] getWCharacterLob() { + return wCharacterLob; + } + + public void setWCharacterLob(Character[] characterLob) { + wCharacterLob = characterLob; + } + + public Double getWDoubleField() { + return wDoubleField; + } + + public void setWDoubleField(Double doubleField) { + wDoubleField = doubleField; + } + + public Float getWFloatField() { + return wFloatField; + } + + public void setWFloatField(Float floatField) { + wFloatField = floatField; + } + + public Integer getWIntegerField() { + return wIntegerField; + } + + public void setWIntegerField(Integer integerField) { + wIntegerField = integerField; + } + + public Long getWLongField() { + return wLongField; + } + + public void setWLongField(Long longField) { + wLongField = longField; + } + + public Short getWShortField() { + return wShortField; + } + + public void setWShortField(Short shortField) { + wShortField = shortField; + } + + public AllFieldTypes getSelfOneOne() { + return selfOneOne; + } + + public void setSelfOneOne(AllFieldTypes selfOneOne) { + this.selfOneOne = selfOneOne; + } + + public List getSelfOneMany() { + return selfOneMany; + } + + public void setSelfOneMany(List selfOneMany) { + this.selfOneMany = selfOneMany; + } +} + Propchange: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/AllFieldTypes.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java?rev=936497&view=auto ============================================================================== --- openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java (added) +++ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java Wed Apr 21 20:42:04 2010 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.openjpa.xmlstore.simple; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Place implements Serializable { + private static final long serialVersionUID = 1L; + + private String location; + + @Id + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } +} + Propchange: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/Place.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java?rev=936497&view=auto ============================================================================== --- openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java (added) +++ openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java Wed Apr 21 20:42:04 2010 @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.openjpa.xmlstore.simple; + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; + +import org.apache.openjpa.persistence.OpenJPAEntityManager; +import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; +import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase; + +/** + * Simple XMLStore test case to get an EntityManager and perform some basic operations. + */ +public class TestPersistence extends AbstractPersistenceTestCase { + + public void testCreateEntityManager() { + OpenJPAEntityManagerFactorySPI emf = createNamedEMF("xmlstore-simple"); + try { + EntityManager em = emf.createEntityManager(); + + EntityTransaction t = em.getTransaction(); + assertNotNull(t); + t.begin(); + t.setRollbackOnly(); + t.rollback(); + + // openjpa-facade test + assertTrue(em instanceof OpenJPAEntityManager); + OpenJPAEntityManager ojem = (OpenJPAEntityManager) em; + ojem.getFetchPlan().setMaxFetchDepth(1); + assertEquals(1, ojem.getFetchPlan().getMaxFetchDepth()); + em.close(); + } finally { + closeEMF(emf); + } + } + + public void testQuery() { + OpenJPAEntityManagerFactorySPI emf = createNamedEMF("xmlstore-simple", + CLEAR_TABLES, AllFieldTypes.class); + try { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + AllFieldTypes aft = new AllFieldTypes(); + aft.setStringField("foo"); + aft.setIntField(10); + em.persist(aft); + em.getTransaction().commit(); + em.close(); + + em = emf.createEntityManager(); + em.getTransaction().begin(); + assertEquals(1, em.createQuery + ("select x from AllFieldTypes x where x.stringField = 'foo'"). + getResultList().size()); + assertEquals(0, em.createQuery + ("select x from AllFieldTypes x where x.stringField = 'bar'"). + getResultList().size()); + assertEquals(1, em.createQuery + ("select x from AllFieldTypes x where x.intField >= 10"). + getResultList().size()); + em.getTransaction().rollback(); + em.close(); + } finally { + closeEMF(emf); + } + } + + public void testNewDeleteNew() { + OpenJPAEntityManagerFactorySPI emf = createNamedEMF("xmlstore-simple", + CLEAR_TABLES, Place.class); + try { + EntityManager em = emf.createEntityManager(); + + // create new + Place place = new Place(); + place.setLocation("Lexington"); + assertFalse(em.contains(place)); + em.getTransaction().begin(); + em.persist(place); + em.getTransaction().commit(); + assertTrue(em.contains(place)); + + // find and verify + place = em.find(Place.class, "Lexington"); + assertNotNull(place); + assertEquals("Lexington", place.getLocation()); + + // delete + em.getTransaction().begin(); + em.remove(place); + em.getTransaction().commit(); + assertFalse(em.contains(place)); + + // recreate + place = new Place(); + place.setLocation("Lexington"); + assertFalse(em.contains(place)); + em.getTransaction().begin(); + em.persist(place); + em.getTransaction().commit(); + assertTrue(em.contains(place)); + + // find and verify + place = em.find(Place.class, "Lexington"); + assertNotNull(place); + assertEquals("Lexington", place.getLocation()); + em.close(); + } finally { + closeEMF(emf); + } + } + +} + Propchange: openjpa/trunk/openjpa-xmlstore/src/test/java/org/apache/openjpa/xmlstore/simple/TestPersistence.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml?rev=936497&view=auto ============================================================================== --- openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml (added) +++ openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml Wed Apr 21 20:42:04 2010 @@ -0,0 +1,46 @@ + + + + + + org.apache.openjpa.xmlstore.simple.AllFieldTypes + org.apache.openjpa.xmlstore.simple.Place + + + + + + + + + + + Propchange: openjpa/trunk/openjpa-xmlstore/src/test/resources/META-INF/persistence.xml ------------------------------------------------------------------------------ svn:eol-style = native