cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
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 GMT
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;
+}



Mime
View raw message