Return-Path: Delivered-To: apmail-incubator-cayenne-commits-archive@locus.apache.org Received: (qmail 29441 invoked from network); 30 Aug 2006 10:41:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Aug 2006 10:41:17 -0000 Received: (qmail 64549 invoked by uid 500); 30 Aug 2006 10:41:17 -0000 Delivered-To: apmail-incubator-cayenne-commits-archive@incubator.apache.org Received: (qmail 64530 invoked by uid 500); 30 Aug 2006 10:41:17 -0000 Mailing-List: contact cayenne-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-dev@incubator.apache.org Delivered-To: mailing list cayenne-commits@incubator.apache.org Received: (qmail 64520 invoked by uid 99); 30 Aug 2006 10:41:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 03:41:17 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 03:41:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 474031A981A; Wed, 30 Aug 2006 03:40:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r438451 - /incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/ Date: Wed, 30 Aug 2006 10:40:55 -0000 To: cayenne-commits@incubator.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060830104056.474031A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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")); + } +}