You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/12/01 23:04:09 UTC
[57/77] [abbrv] tomee git commit: testing we can lookup
comp/TransactionSynchronizationRegistry using app composer
testing we can lookup comp/TransactionSynchronizationRegistry using app composer
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5f0adffb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5f0adffb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5f0adffb
Branch: refs/heads/tomee-7.0.0-M1
Commit: 5f0adffb5952c4b079a0745cfe6980343f26d268
Parents: df52d03
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Tue Nov 24 23:07:34 2015 +0100
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Tue Nov 24 23:07:34 2015 +0100
----------------------------------------------------------------------
.../AppComposerTransactionRegistryTest.java | 66 ++++++++++++++++++++
1 file changed, 66 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0adffb/container/openejb-core/src/test/java/org/apache/openejb/testing/AppComposerTransactionRegistryTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/testing/AppComposerTransactionRegistryTest.java b/container/openejb-core/src/test/java/org/apache/openejb/testing/AppComposerTransactionRegistryTest.java
new file mode 100644
index 0000000..8a2f5e8
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/testing/AppComposerTransactionRegistryTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.openejb.testing;
+
+import org.apache.openejb.junit.ApplicationComposerRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@SimpleLog
+@Classes(context = "app")
+public class AppComposerTransactionRegistryTest {
+ @Rule
+ public final ApplicationComposerRule rule = new ApplicationComposerRule(this);
+
+ @Test
+ public void transactionSynchronizationRegistryLookupInNotManagedThread() throws Exception {
+ final AtomicReference<Exception> ex = new AtomicReference<>();
+ final Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ final Object lookup;
+ try {
+ lookup = new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry");
+ assertNotNull("java:comp/TransactionSynchronizationRegistry lookup got an object", lookup);
+ assertTrue("java:comp/TransactionSynchronizationRegistry is a TransactionSynchronizationRegistry", TransactionSynchronizationRegistry.class.isInstance(lookup));
+ } catch (final Exception e) {
+ ex.set(e);
+ }
+ }
+ });
+ thread.start();
+ try {
+ thread.join(TimeUnit.MINUTES.toMillis(1));
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ fail();
+ }
+ assertNull("error: " + ex.get(), ex.get());
+ }
+}