Return-Path: Delivered-To: apmail-incubator-cayenne-commits-archive@locus.apache.org Received: (qmail 43776 invoked from network); 1 Sep 2006 20:56:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2006 20:56:37 -0000 Received: (qmail 42470 invoked by uid 500); 1 Sep 2006 20:56:37 -0000 Delivered-To: apmail-incubator-cayenne-commits-archive@incubator.apache.org Received: (qmail 42454 invoked by uid 500); 1 Sep 2006 20:56:37 -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 42445 invoked by uid 99); 1 Sep 2006 20:56:37 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2006 13:56:37 -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; Fri, 01 Sep 2006 13:56:36 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D78511A981A; Fri, 1 Sep 2006 13:56:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r439474 - in /incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa: bridge/DataMapConverterTest.java entity/MockTypesEntity.java Date: Fri, 01 Sep 2006 20:56:16 -0000 To: cayenne-commits@incubator.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060901205616.D78511A981A@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: Fri Sep 1 13:56:15 2006 New Revision: 439474 URL: http://svn.apache.org/viewvc?rev=439474&view=rev Log: Calendar type unit tests Added: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/MockTypesEntity.java Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java?rev=439474&r1=439473&r2=439474&view=diff ============================================================================== --- incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java (original) +++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java Fri Sep 1 13:56:15 2006 @@ -19,11 +19,15 @@ package org.apache.cayenne.jpa.bridge; +import java.sql.Types; + import junit.framework.TestCase; +import org.apache.cayenne.dba.TypesMapping; import org.apache.cayenne.jpa.conf.EntityMapAnnotationLoader; import org.apache.cayenne.jpa.conf.EntityMapDefaultsProcessor; import org.apache.cayenne.jpa.conf.EntityMapLoaderContext; +import org.apache.cayenne.jpa.entity.MockTypesEntity; import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity1; import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity2; import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntityMap1; @@ -32,6 +36,8 @@ import org.apache.cayenne.jpa.map.JpaEntityMap; import org.apache.cayenne.jpa.spi.MockPersistenceUnitInfo; import org.apache.cayenne.map.DataMap; +import org.apache.cayenne.map.DbAttribute; +import org.apache.cayenne.map.DbEntity; public class DataMapConverterTest extends TestCase { @@ -76,5 +82,37 @@ .hasFailures()); new DataMapMappingAssertion().testDataMap(dataMap); + } + + public void testDataMapTypes() { + EntityMapLoaderContext context = new EntityMapLoaderContext( + new MockPersistenceUnitInfo()); + EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context); + + loader.loadClassMapping(MockTypesEntity.class); + + // apply defaults before conversion + new EntityMapDefaultsProcessor().applyDefaults(context); + + assertFalse("Found conflicts: " + context.getConflicts(), context + .getConflicts() + .hasFailures()); + + DataMap dataMap = new DataMapConverter().toDataMap("n1", context); + assertFalse("Found DataMap conflicts: " + context.getConflicts(), context + .getConflicts() + .hasFailures()); + + DbEntity typesTable = dataMap.getDbEntity("MockTypesEntity"); + assertNotNull(typesTable); + + DbAttribute defaultCalColumn = (DbAttribute) typesTable + .getAttribute("defaultCalendar"); + assertNotNull(defaultCalColumn); + assertEquals( + "Invalid calendar type: " + + TypesMapping.getSqlNameByType(defaultCalColumn.getType()), + Types.TIMESTAMP, + defaultCalColumn.getType()); } } Added: incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/MockTypesEntity.java URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/MockTypesEntity.java?rev=439474&view=auto ============================================================================== --- incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/MockTypesEntity.java (added) +++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/MockTypesEntity.java Fri Sep 1 13:56:15 2006 @@ -0,0 +1,29 @@ +/***************************************************************** + * 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.entity; + +import java.util.Calendar; + +import javax.persistence.Entity; + +@Entity +public class MockTypesEntity { + + protected Calendar defaultCalendar; +}