Author: aadamchik
Date: Mon Oct 9 22:11:12 2006
New Revision: 454617
URL: http://svn.apache.org/viewvc?view=rev&rev=454617
Log:
adding Cayenne (non-jpa) integration test superclasses
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneItestSetup.java
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneTestCase.java
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ObjectContextTestCase.java
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneItestSetup.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneItestSetup.java?view=auto&rev=454617
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneItestSetup.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneItestSetup.java
Mon Oct 9 22:11:12 2006
@@ -0,0 +1,73 @@
+/*****************************************************************
+ * 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;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.ObjectContext;
+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.map.DataMap;
+
+public class CayenneItestSetup {
+
+ private static CayenneItestSetup sharedInstance;
+
+ protected DataDomain domain;
+
+ public static void initInstance() {
+ sharedInstance = new CayenneItestSetup();
+ }
+
+ public static CayenneItestSetup getInstance() {
+ Assert.assertNotNull(
+ "Null shared instance, call 'initInstance' first",
+ sharedInstance);
+
+ return sharedInstance;
+ }
+
+ protected CayenneItestSetup() {
+ 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);
+ }
+ }
+ }
+
+ public ObjectContext createObjectContext() {
+ return domain.createDataContext();
+ }
+}
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneTestCase.java?view=auto&rev=454617
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneTestCase.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/CayenneTestCase.java
Mon Oct 9 22:11:12 2006
@@ -0,0 +1,33 @@
+/*****************************************************************
+ * 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;
+
+import junit.framework.TestCase;
+
+/**
+ * Abstract test case that bootstraps default Cayenne stack and generates
schema.
+ *
+ * @author Andrus Adamchik
+ */
+public class CayenneTestCase extends TestCase {
+
+ static {
+ CayenneItestSetup.initInstance();
+ }
+}
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ObjectContextTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ObjectContextTestCase.java?view=auto&rev=454617
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ObjectContextTestCase.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/ObjectContextTestCase.java
Mon Oct 9 22:11:12 2006
@@ -0,0 +1,39 @@
+/*****************************************************************
+ * 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;
+
+import org.apache.cayenne.ObjectContext;
+
+public class ObjectContextTestCase extends CayenneTestCase {
+
+ protected ObjectContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ this.context = CayenneItestSetup.getInstance().createObjectContext();
+ }
+
+ public ObjectContext getContext() {
+ return context;
+ }
+
+ public void setContext(ObjectContext context) {
+ this.context = context;
+ }
+}