Author: aadamchik
Date: Sat Nov 25 19:58:22 2006
New Revision: 479266
URL: http://svn.apache.org/viewvc?view=rev&rev=479266
Log:
itests support for temporary blocking database queries
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/BlockingTransactionDelegate.java
Modified:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/ItestSetup.java
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoContextCase.java
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoTestCase.java
Added:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/BlockingTransactionDelegate.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/BlockingTransactionDelegate.java?view=auto&rev=479266
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/BlockingTransactionDelegate.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/BlockingTransactionDelegate.java
Sat Nov 25 19:58:22 2006
@@ -0,0 +1,51 @@
+/*****************************************************************
+ * 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.pojo;
+
+import java.sql.Connection;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.Transaction;
+import org.apache.cayenne.access.TransactionDelegate;
+
+public class BlockingTransactionDelegate implements TransactionDelegate {
+
+ public void didCommit(Transaction transaction) {
+ }
+
+ public void didRollback(Transaction transaction) {
+ }
+
+ public boolean willAddConnection(Transaction transaction, Connection
connection) {
+ throw new CayenneRuntimeException("Database access is not allowed.");
+ }
+
+ public boolean willCommit(Transaction transaction) {
+ return true;
+ }
+
+ public boolean willMarkAsRollbackOnly(Transaction transaction) {
+ return true;
+ }
+
+ public boolean willRollback(Transaction transaction) {
+ return true;
+ }
+
+}
Modified:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/ItestSetup.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/ItestSetup.java?view=diff&rev=479266&r1=479265&r2=479266
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/ItestSetup.java
(original)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/ItestSetup.java
Sat Nov 25 19:58:22 2006
@@ -23,7 +23,6 @@
import junit.framework.Assert;
import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.DataChannel;
import org.apache.cayenne.access.DataContext;
import org.apache.cayenne.access.DataDomain;
import org.apache.cayenne.access.DataNode;
@@ -73,7 +72,7 @@
}
}
- public DataChannel getChannel() {
+ public DataDomain getDataDomain() {
return domain;
}
Modified:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoContextCase.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoContextCase.java?view=diff&rev=479266&r1=479265&r2=479266
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoContextCase.java
(original)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoContextCase.java
Sat Nov 25 19:58:22 2006
@@ -48,4 +48,16 @@
context.setChannel(((BlockingDataChannel) channel).getChannel());
}
}
+
+ /**
+ * Ensures that DataDomain can't send queries to the DB.
+ */
+ protected void blockDomainQueries() {
+ ItestSetup.getInstance().getDataDomain().setTransactionDelegate(
+ new BlockingTransactionDelegate());
+ }
+
+ protected void unblockDomainQueries() {
+ ItestSetup.getInstance().getDataDomain().setTransactionDelegate(null);
+ }
}
Modified:
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoTestCase.java?view=diff&rev=479266&r1=479265&r2=479266
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoTestCase.java
(original)
+++
incubator/cayenne/main/trunk/integration-test/itest-common/src/main/java/org/apache/cayenne/itest/pojo/PojoTestCase.java
Sat Nov 25 19:58:22 2006
@@ -36,7 +36,7 @@
}
protected static ClassFileTransformer initEnhancer() {
- DataChannel channel = ItestSetup.getInstance().getChannel();
+ DataChannel channel = ItestSetup.getInstance().getDataDomain();
return new Enhancer(
new
CayenneEnhancerVisitorFactory(channel.getEntityResolver()));
}