Author: aadamchik
Date: Wed Aug 30 03:40:55 2006
New Revision: 438451
URL: http://svn.apache.org/viewvc?rev=438451&view=rev
Log:
trying new test case naming convention - class names starting with the spec
chapter #
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_1_PeristentFieldsAndPropertiesTest.java
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_4_PrimaryKeyAndIdentityTest.java
Removed:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PeristentFieldsAndProperties_2_1_1_Test.java
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/PrimaryKeyAndIdentity_2_1_4_Test.java
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_1_PeristentFieldsAndPropertiesTest.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_1_PeristentFieldsAndPropertiesTest.java?rev=438451&view=auto
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_1_PeristentFieldsAndPropertiesTest.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_1_PeristentFieldsAndPropertiesTest.java
Wed Aug 30 03:40:55 2006
@@ -0,0 +1,103 @@
+/*****************************************************************
+ * 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.cayenne.jpa.itest.entity;
+
+import java.util.Collections;
+
+import javax.persistence.EntityManager;
+
+import org.apache.cayenne.jpa.itest.ItestDBUtils;
+import org.apache.cayenne.jpa.itest.ItestSetup;
+import org.apache.cayenne.jpa.itest1.entity.CollectionFieldPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.FieldPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity1;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity2;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity3;
+import org.apache.cayenne.jpa.itest1.entity.HelperEntity4;
+import org.apache.cayenne.jpa.itest1.entity.PropertyPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.TransientFieldsEntity;
+
+public class _2_1_1_PeristentFieldsAndPropertiesTest extends Unit1Case {
+
+ protected EntityManager em;
+
+ @Override
+ protected void setUp() throws Exception {
+ em = ItestSetup.getInstance().createEntityManager();
+ em.getTransaction().begin();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ public void testFieldBasedPersistence() throws Exception {
+
+ ItestDBUtils.deleteAll("FieldPersistenceEntity");
+
+ FieldPersistenceEntity o1 = new FieldPersistenceEntity();
+ em.persist(o1);
+ em.getTransaction().commit();
+
+ assertEquals(FieldPersistenceEntity.INITIAL_VALUE,
ItestDBUtils.getSingleValue(
+ "FieldPersistenceEntity",
+ "property1"));
+ }
+
+ // TODO: andrus 8/10/2006 - fails
+ public void _testPropertyBasedPersistence() {
+ PropertyPersistenceEntity o1 = new PropertyPersistenceEntity();
+ o1.setProperty1("p1");
+ o1.setProperty2(true);
+ em.persist(o1);
+ em.getTransaction().commit();
+ }
+
+ public void testSkipTransientProperties() {
+ TransientFieldsEntity o1 = new TransientFieldsEntity();
+ em.persist(o1);
+ em.getTransaction().commit();
+ }
+
+ // TODO: andrus 8/30/2006 - fails
+ public void _testCollectionTypesProperties() {
+ CollectionFieldPersistenceEntity o1 = new
CollectionFieldPersistenceEntity();
+ o1.setCollection(Collections.singleton(new HelperEntity1()));
+ o1.setSet(Collections.singleton(new HelperEntity2()));
+ o1.setList(Collections.singletonList(new HelperEntity3()));
+ o1.setMap(Collections.singletonMap(new Object(), new HelperEntity4()));
+
+ em.persist(o1);
+ em.getTransaction().commit();
+ }
+
+ // TODO: andrus 8/30/2006 - implement me
+ public void testExceptionInPropertyAccessors() {
+ // Runtime exceptions thrown by property accessor methods cause the
current
+ // transaction to be rolled back.
+ // Exceptions thrown by such methods when used by the persistence
runtime to load
+ // or store persistent state cause the persistence runtime to rollback
the current
+ // transaction and to throw a PersistenceException that wraps the
application
+ // exception.
+ }
+}
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_4_PrimaryKeyAndIdentityTest.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_4_PrimaryKeyAndIdentityTest.java?rev=438451&view=auto
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_4_PrimaryKeyAndIdentityTest.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_4_PrimaryKeyAndIdentityTest.java
Wed Aug 30 03:40:55 2006
@@ -0,0 +1,95 @@
+/*****************************************************************
+ * 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.cayenne.jpa.itest.entity;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
+
+import org.apache.cayenne.jpa.itest.ItestDBUtils;
+import org.apache.cayenne.jpa.itest.ItestSetup;
+import org.apache.cayenne.jpa.itest1.entity.EmbeddedIdEntity;
+import org.apache.cayenne.jpa.itest1.entity.FieldPersistenceEntity;
+import org.apache.cayenne.jpa.itest1.entity.IdClassEntity;
+import org.apache.cayenne.jpa.itest1.entity.NoPkEntity;
+
+public class _2_1_4_PrimaryKeyAndIdentityTest extends Unit1Case {
+
+ protected EntityManager em;
+
+ @Override
+ protected void setUp() throws Exception {
+ em = ItestSetup.getInstance().createEntityManager();
+ em.getTransaction().begin();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ public void testNoPkEntity() {
+ NoPkEntity o1 = new NoPkEntity();
+
+ try {
+ em.persist(o1);
+
+ }
+ catch (IllegalArgumentException e) {
+ return;
+ }
+
+ try {
+ em.getTransaction().commit();
+ }
+ catch (PersistenceException e) {
+ return;
+ }
+
+ fail("Must have thrown on an attempt to persist or flush "
+ + "an entity without defined id");
+ }
+
+ public void testSimplePk() throws Exception {
+ FieldPersistenceEntity o1 = new FieldPersistenceEntity();
+ em.persist(o1);
+ }
+
+ // TODO: andrus 8/10/2006 - fails
+ public void _testIdClassPk() throws Exception {
+ IdClassEntity o1 = new IdClassEntity();
+ o1.setProperty1("p1");
+ em.persist(o1);
+ em.getTransaction().commit();
+
+ assertEquals("p1", ItestDBUtils.getSingleValue("IdClassEntity",
"property1"));
+ }
+
+ // TODO: andrus 8/10/2006 - fails
+ public void _testEmbeddedIdPk() throws Exception {
+ EmbeddedIdEntity o1 = new EmbeddedIdEntity();
+ o1.setProperty1("p1");
+ em.persist(o1);
+ em.getTransaction().commit();
+
+ assertEquals("p1", ItestDBUtils.getSingleValue("EmbeddedIdEntity",
"property1"));
+ }
+}