Author: aadamchik
Date: Fri Apr 28 09:39:22 2006
New Revision: 397950
URL: http://svn.apache.org/viewcvs?rev=397950&view=rev
Log:
updating license to apache
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/main/java/org/objectstyle/cayenne/jpa/tck/object/TestTable1.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/EntityManagerTest.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/NamedQueryTest.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DBManager.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DerbyDBManager.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/Environment.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/GenericDBManager.java
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/JPATestBase.java
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/main/java/org/objectstyle/cayenne/jpa/tck/object/TestTable1.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/main/java/org/objectstyle/cayenne/jpa/tck/object/TestTable1.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/main/java/org/objectstyle/cayenne/jpa/tck/object/TestTable1.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/main/java/org/objectstyle/cayenne/jpa/tck/object/TestTable1.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.object;
import org.objectstyle.cayenne.jpa.tck.object.auto._TestTable1;
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/EntityManagerTest.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/EntityManagerTest.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/EntityManagerTest.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/EntityManagerTest.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck;
import org.objectstyle.cayenne.jpa.tck.util.JPATestBase;
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/NamedQueryTest.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/NamedQueryTest.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/NamedQueryTest.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/NamedQueryTest.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck;
import java.util.List;
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DBManager.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DBManager.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DBManager.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DBManager.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.util;
import org.objectstyle.cayenne.access.DataDomain;
@@ -9,26 +24,27 @@
*/
public interface DBManager {
- /**
- * Lifectycle method called before Cayenne stack is loaded, allowing
DBManager to
- * configure global environment prior to any connection attempts.
- */
- void beforeCayenneLoaded();
-
- void afterCayenneLoaded(DataDomain domain);
-
- /**
- * Drops and recreates a database schema.
- */
- void rebuildSchema();
-
- /**
- * Deletes all table data.
- */
- void truncateTable(String tableName);
-
- /**
- * Returns a count of rows in the table.
- */
- int getRowCount(String tableName);
+ /**
+ * Lifectycle method called before Cayenne stack is loaded, allowing
+ * DBManager to configure global environment prior to any connection
+ * attempts.
+ */
+ void beforeCayenneLoaded();
+
+ void afterCayenneLoaded(DataDomain domain);
+
+ /**
+ * Drops and recreates a database schema.
+ */
+ void rebuildSchema();
+
+ /**
+ * Deletes all table data.
+ */
+ void truncateTable(String tableName);
+
+ /**
+ * Returns a count of rows in the table.
+ */
+ int getRowCount(String tableName);
}
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DerbyDBManager.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DerbyDBManager.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DerbyDBManager.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/DerbyDBManager.java
Fri Apr 28 09:39:22 2006
@@ -1,24 +1,40 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.util;
import java.io.File;
public class DerbyDBManager extends GenericDBManager {
- static final String DERBY_SYSTEM_PROPERTY = "derby.system.home";
+ static final String DERBY_SYSTEM_PROPERTY = "derby.system.home";
- @Override
- public void beforeCayenneLoaded() {
- // configure derby HOME ... assume maven project layout, and TMP as a
second
- // choice...
-
- File targetDir = new File("target");
- if (!targetDir.isDirectory()) {
- targetDir = new File(System.getProperty("java.io.tmpdir"));
- }
+ @Override
+ public void beforeCayenneLoaded() {
+ // configure derby HOME ... assume maven project layout, and
TMP as a
+ // second
+ // choice...
+
+ File targetDir = new File("target");
+ if (!targetDir.isDirectory()) {
+ targetDir = new
File(System.getProperty("java.io.tmpdir"));
+ }
- File testDBRoot = new File(targetDir, "jpa-test-db");
- testDBRoot.mkdirs();
+ File testDBRoot = new File(targetDir, "jpa-test-db");
+ testDBRoot.mkdirs();
- System.setProperty(DERBY_SYSTEM_PROPERTY,
testDBRoot.getAbsolutePath());
- }
+ System.setProperty(DERBY_SYSTEM_PROPERTY,
testDBRoot.getAbsolutePath());
+ }
}
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/Environment.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/Environment.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/Environment.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/Environment.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.util;
import java.util.HashMap;
@@ -14,88 +29,88 @@
import org.objectstyle.cayenne.conf.DefaultConfiguration;
/**
- * A singleton that provides a Cayenne DataChannel that is used by the unit
tests as a
- * "window" to the test database, thus allowing to prepare DB test fixtures
and verify the
- * results of the JPA provider tests.
+ * A singleton that provides a Cayenne DataChannel that is used by the unit
+ * tests as a "window" to the test database, thus allowing to prepare DB test
+ * fixtures and verify the results of the JPA provider tests.
*
* @author Andrus Adamchik
*/
class Environment {
- public static final String TCK_DOMAIN_NAME = "tck-domain";
+ public static final String TCK_DOMAIN_NAME = "tck-domain";
- static final Environment sharedInstance;
+ static final Environment sharedInstance;
- static {
- sharedInstance = new Environment();
- }
-
- DataDomain testDomain;
- DBManager dbManager;
- Map<String, EntityManagerFactory> factories;
-
- /**
- * Returns a TestDatabase singleton.
- */
- static Environment getInstance() {
- return sharedInstance;
- }
-
- Environment() {
-
- this.factories = new HashMap<String, EntityManagerFactory>();
-
- // TODO: andrus, 3/3/2006 - we may load DBManager using a property
name to support
- // DB's other than Derby...
- this.dbManager = new DerbyDBManager();
-
- dbManager.beforeCayenneLoaded();
-
- Configuration config = new DefaultConfiguration();
- try {
- config.initialize();
- }
- catch (Exception e) {
- throw new CayenneRuntimeException(
- "Test configuration initialization failed",
- e);
- }
- config.didInitialize();
- this.testDomain = config.getDomain(TCK_DOMAIN_NAME);
- this.dbManager.afterCayenneLoaded(testDomain);
- this.dbManager.rebuildSchema();
- }
-
- /**
- * Returns Cayenne DataChannel that can be used to access test DB.
- */
- DataChannel getDataChannel() {
- return testDomain;
- }
-
- /**
- * Creates a new DataContext based on the internal DataChannel.
- */
- DataContext createDataContext() {
- return testDomain.createDataContext();
- }
-
- DBManager getDbManager() {
- return dbManager;
- }
-
- EntityManagerFactory getEntityManagerFactory(String unit) {
- EntityManagerFactory factory;
-
- // make sure we cache null factories as well...
- if (!factories.containsKey(unit)) {
- factory = Persistence.createEntityManagerFactory(unit);
- factories.put(unit, factory);
- }
- else {
- factory = factories.get(unit);
- }
+ static {
+ sharedInstance = new Environment();
+ }
+
+ DataDomain testDomain;
+
+ DBManager dbManager;
+
+ Map<String, EntityManagerFactory> factories;
+
+ /**
+ * Returns a TestDatabase singleton.
+ */
+ static Environment getInstance() {
+ return sharedInstance;
+ }
+
+ Environment() {
+
+ this.factories = new HashMap<String, EntityManagerFactory>();
+
+ // TODO: andrus, 3/3/2006 - we may load DBManager using a
property name
+ // to support
+ // DB's other than Derby...
+ this.dbManager = new DerbyDBManager();
+
+ dbManager.beforeCayenneLoaded();
+
+ Configuration config = new DefaultConfiguration();
+ try {
+ config.initialize();
+ } catch (Exception e) {
+ throw new CayenneRuntimeException(
+ "Test configuration initialization
failed", e);
+ }
+ config.didInitialize();
+ this.testDomain = config.getDomain(TCK_DOMAIN_NAME);
+ this.dbManager.afterCayenneLoaded(testDomain);
+ this.dbManager.rebuildSchema();
+ }
+
+ /**
+ * Returns Cayenne DataChannel that can be used to access test DB.
+ */
+ DataChannel getDataChannel() {
+ return testDomain;
+ }
+
+ /**
+ * Creates a new DataContext based on the internal DataChannel.
+ */
+ DataContext createDataContext() {
+ return testDomain.createDataContext();
+ }
+
+ DBManager getDbManager() {
+ return dbManager;
+ }
+
+ EntityManagerFactory getEntityManagerFactory(String unit) {
+ EntityManagerFactory factory;
+
+ // make sure we cache null factories as well...
+ if (!factories.containsKey(unit)) {
+ factory = Persistence.createEntityManagerFactory(unit);
+ factories.put(unit, factory);
+ } else {
+ factory = factories.get(unit);
+ }
- return factory;
- }
+ return factory;
+ }
}
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/GenericDBManager.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/GenericDBManager.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/GenericDBManager.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/GenericDBManager.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.util;
import java.util.Map;
@@ -18,105 +33,102 @@
*/
public class GenericDBManager implements DBManager {
- DataDomain domain;
- ObjEntity someEntity;
+ DataDomain domain;
+
+ ObjEntity someEntity;
- public void beforeCayenneLoaded() {
- // noop
- }
-
- public void afterCayenneLoaded(DataDomain domain) {
- this.domain = domain;
-
- if (domain.getDataNodes().size() > 1) {
- // it shouldn't be too hard to ass support for multiple nodes,
just that there
- // is no pressing need...
- throw new IllegalArgumentException(
- "Only domains with a single node are currently
supported.");
- }
-
- this.someEntity = (ObjEntity) domain
- .getEntityResolver()
- .getObjEntities()
- .iterator()
- .next();
- }
-
- public void rebuildSchema() {
- try {
- if (schemaExists()) {
- dropSchema();
- }
-
- createSchema();
- }
- catch (RuntimeException e) {
- throw e;
- }
- catch (Exception e) {
- throw new CayenneRuntimeException("Error setting up schema", e);
- }
- }
-
- public void truncateTable(String tableName) {
- domain.onQuery(null, new SQLTemplate(someEntity, "delete from " +
tableName));
- }
-
- public int getRowCount(String tableName) {
- QueryResponse response = domain.onQuery(null, new SQLTemplate(
- someEntity,
- "select count(1) from " + tableName));
- Map firstRow = (Map) response.firstList().get(0);
- Number count = (Number) firstRow.values().iterator().next();
- return count.intValue();
- }
-
- /**
- * Runs a test query to see if a schema is initialized.
- */
- protected boolean schemaExists() {
-
- SelectQuery query = new SelectQuery(someEntity);
-
- // as we are using random entity and don't know how much data could be
there, make
- // sure query does not flood us with data
- query.setFetchLimit(1);
- query.setFetchingDataRows(true);
-
- try {
- domain.onQuery(null, query);
- return true;
- }
- catch (Throwable th) {
- return false;
- }
- }
-
- protected void dropSchema() throws Exception {
- DataNode node = getDataNode();
- DbGenerator generator = new DbGenerator(node.getAdapter(), someEntity
- .getDataMap());
- generator.setShouldDropTables(true);
- generator.setShouldDropPKSupport(true);
- generator.setShouldCreateFKConstraints(false);
- generator.setShouldCreatePKSupport(false);
- generator.setShouldCreateTables(false);
- generator.runGenerator(node.getDataSource());
- }
-
- protected void createSchema() throws Exception {
- DataNode node = getDataNode();
- DbGenerator generator = new DbGenerator(node.getAdapter(), someEntity
- .getDataMap());
- generator.setShouldDropTables(false);
- generator.setShouldDropPKSupport(false);
- generator.setShouldCreateFKConstraints(true);
- generator.setShouldCreatePKSupport(true);
- generator.setShouldCreateTables(true);
- generator.runGenerator(node.getDataSource());
- }
-
- private DataNode getDataNode() {
- return domain.lookupDataNode(someEntity.getDataMap());
- }
+ public void beforeCayenneLoaded() {
+ // noop
+ }
+
+ public void afterCayenneLoaded(DataDomain domain) {
+ this.domain = domain;
+
+ if (domain.getDataNodes().size() > 1) {
+ // it shouldn't be too hard to ass support for multiple
nodes, just
+ // that there
+ // is no pressing need...
+ throw new IllegalArgumentException(
+ "Only domains with a single node are
currently supported.");
+ }
+
+ this.someEntity = (ObjEntity) domain.getEntityResolver()
+ .getObjEntities().iterator().next();
+ }
+
+ public void rebuildSchema() {
+ try {
+ if (schemaExists()) {
+ dropSchema();
+ }
+
+ createSchema();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new CayenneRuntimeException("Error setting up
schema", e);
+ }
+ }
+
+ public void truncateTable(String tableName) {
+ domain.onQuery(null, new SQLTemplate(someEntity, "delete from "
+ + tableName));
+ }
+
+ public int getRowCount(String tableName) {
+ QueryResponse response = domain.onQuery(null, new SQLTemplate(
+ someEntity, "select count(1) from " +
tableName));
+ Map firstRow = (Map) response.firstList().get(0);
+ Number count = (Number) firstRow.values().iterator().next();
+ return count.intValue();
+ }
+
+ /**
+ * Runs a test query to see if a schema is initialized.
+ */
+ protected boolean schemaExists() {
+
+ SelectQuery query = new SelectQuery(someEntity);
+
+ // as we are using random entity and don't know how much data
could be
+ // there, make
+ // sure query does not flood us with data
+ query.setFetchLimit(1);
+ query.setFetchingDataRows(true);
+
+ try {
+ domain.onQuery(null, query);
+ return true;
+ } catch (Throwable th) {
+ return false;
+ }
+ }
+
+ protected void dropSchema() throws Exception {
+ DataNode node = getDataNode();
+ DbGenerator generator = new DbGenerator(node.getAdapter(),
someEntity
+ .getDataMap());
+ generator.setShouldDropTables(true);
+ generator.setShouldDropPKSupport(true);
+ generator.setShouldCreateFKConstraints(false);
+ generator.setShouldCreatePKSupport(false);
+ generator.setShouldCreateTables(false);
+ generator.runGenerator(node.getDataSource());
+ }
+
+ protected void createSchema() throws Exception {
+ DataNode node = getDataNode();
+ DbGenerator generator = new DbGenerator(node.getAdapter(),
someEntity
+ .getDataMap());
+ generator.setShouldDropTables(false);
+ generator.setShouldDropPKSupport(false);
+ generator.setShouldCreateFKConstraints(true);
+ generator.setShouldCreatePKSupport(true);
+ generator.setShouldCreateTables(true);
+ generator.runGenerator(node.getDataSource());
+ }
+
+ private DataNode getDataNode() {
+ return domain.lookupDataNode(someEntity.getDataMap());
+ }
}
Modified:
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/JPATestBase.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/JPATestBase.java?rev=397950&r1=397949&r2=397950&view=diff
==============================================================================
---
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/JPATestBase.java
(original)
+++
incubator/cayenne/trunk/cayenne-jpa-tck/src/test/java/org/objectstyle/cayenne/jpa/tck/util/JPATestBase.java
Fri Apr 28 09:39:22 2006
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.objectstyle.cayenne.jpa.tck.util;
import javax.persistence.EntityManager;
@@ -8,38 +23,41 @@
import org.objectstyle.cayenne.DataChannel;
/**
- * A common superclass of the EntityManager test cases that ensures proper
environment
- * setup.
+ * A common superclass of the EntityManager test cases that ensures proper
+ * environment setup.
*
* @author Andrus Adamchik
*/
public abstract class JPATestBase extends TestCase {
- public static final String DEFAULT_PERSISTENCE_UNIT = "TckUnit";
- protected EntityManager entityManager;
+ public static final String DEFAULT_PERSISTENCE_UNIT = "TckUnit";
+
+ protected EntityManager entityManager;
- @Override
- protected void setUp() throws Exception {
- EntityManagerFactory factory =
Environment.getInstance().getEntityManagerFactory(
- DEFAULT_PERSISTENCE_UNIT);
- assertNotNull("Persistence unit not found: " +
DEFAULT_PERSISTENCE_UNIT, factory);
- entityManager = factory.createEntityManager();
- }
-
- @Override
- protected void tearDown() throws Exception {
- entityManager.close();
- }
-
- protected DBManager getDbManager() {
- return Environment.getInstance().getDbManager();
- }
-
- protected EntityManager getEntityManager() {
- return entityManager;
- }
-
- protected DataChannel getDataChannel() {
- return Environment.getInstance().getDataChannel();
- }
+ @Override
+ protected void setUp() throws Exception {
+ EntityManagerFactory factory = Environment.getInstance()
+
.getEntityManagerFactory(DEFAULT_PERSISTENCE_UNIT);
+ assertNotNull(
+ "Persistence unit not found: " +
DEFAULT_PERSISTENCE_UNIT,
+ factory);
+ entityManager = factory.createEntityManager();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ entityManager.close();
+ }
+
+ protected DBManager getDbManager() {
+ return Environment.getInstance().getDbManager();
+ }
+
+ protected EntityManager getEntityManager() {
+ return entityManager;
+ }
+
+ protected DataChannel getDataChannel() {
+ return Environment.getInstance().getDataChannel();
+ }
}