You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/07/28 18:02:22 UTC
svn commit: r560559 - in
/cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa:
./ CPAContextCase.java CPATestCase.java ItestSetup.java
Author: aadamchik
Date: Sat Jul 28 09:02:22 2007
New Revision: 560559
URL: http://svn.apache.org/viewvc?view=rev&rev=560559
Log:
adding base API for Cayenne Persistence API (aka CPA) integration tests
Added:
cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/
cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPATestCase.java
cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/ItestSetup.java
Added: cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java?view=auto&rev=560559
==============================================================================
--- cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java (added)
+++ cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java Sat Jul 28 09:02:22 2007
@@ -0,0 +1,36 @@
+/*****************************************************************
+ * 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.itest.cpa;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.access.DataContext;
+
+public class CPAContextCase extends CPATestCase {
+
+ protected DataContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ this.context = ItestSetup.getInstance().createDataContext();
+ }
+
+ public ObjectContext getContext() {
+ return context;
+ }
+}
Added: cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPATestCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPATestCase.java?view=auto&rev=560559
==============================================================================
--- cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPATestCase.java (added)
+++ cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPATestCase.java Sat Jul 28 09:02:22 2007
@@ -0,0 +1,34 @@
+/*****************************************************************
+ * 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.itest.cpa;
+
+import junit.framework.TestCase;
+
+import org.apache.cayenne.itest.ItestDBUtils;
+
+public class CPATestCase extends TestCase {
+
+ static {
+ ItestSetup.initInstance();
+ }
+
+ protected ItestDBUtils getDbHelper() {
+ return ItestSetup.getInstance().getDbHelper();
+ }
+}
Added: cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/ItestSetup.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/ItestSetup.java?view=auto&rev=560559
==============================================================================
--- cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/ItestSetup.java (added)
+++ cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/ItestSetup.java Sat Jul 28 09:02:22 2007
@@ -0,0 +1,86 @@
+/*****************************************************************
+ * 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.itest.cpa;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.conf.Configuration;
+import org.apache.cayenne.itest.ItestDBUtils;
+import org.apache.cayenne.map.DataMap;
+
+public class ItestSetup {
+
+ private static ItestSetup sharedInstance;
+
+ protected ItestDBUtils dbHelper;
+ protected DataDomain domain;
+
+ public static void initInstance() {
+ sharedInstance = new ItestSetup();
+ }
+
+ public static ItestSetup getInstance() {
+ Assert.assertNotNull(
+ "Null shared instance, call 'initInstance' first",
+ sharedInstance);
+
+ return sharedInstance;
+ }
+
+ protected ItestSetup() {
+ domain = Configuration.getSharedConfiguration().getDomain();
+
+ Iterator it = domain.getDataMaps().iterator();
+ while (it.hasNext()) {
+ DataMap map = (DataMap) it.next();
+ DataNode node = domain.lookupDataNode(map);
+
+ DbGenerator generator = new DbGenerator(node.getAdapter(), map);
+ try {
+ generator.runGenerator(node.getDataSource());
+ }
+ catch (Exception e) {
+ throw new CayenneRuntimeException("Error generating schema for DataMap "
+ + map.getName(), e);
+ }
+
+ // only single node is expected...
+ dbHelper = new ItestDBUtils(node.getDataSource());
+ }
+ }
+
+ public DataDomain getDataDomain() {
+ return domain;
+ }
+
+ public DataContext createDataContext() {
+ return domain.createDataContext();
+ }
+
+ public ItestDBUtils getDbHelper() {
+ return dbHelper;
+ }
+}