cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [4/4] cayenne git commit: CAY-2442 Broken EventBridge providers implementations tests
Date Thu, 05 Jul 2018 15:26:39 GMT
CAY-2442 Broken EventBridge providers implementations
  tests


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e795b287
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e795b287
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e795b287

Branch: refs/heads/STABLE-4.0
Commit: e795b287b5a92c7911e135cdde9d79621564a230
Parents: 63f7375
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Jul 5 18:21:05 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Jul 5 18:21:05 2018 +0300

----------------------------------------------------------------------
 .../apache/cayenne/event/JavaGroupsBridge.java  |  7 +--
 .../apache/cayenne/event/JGroupsModuleIT.java   | 53 ++++++++++++++++++++
 .../event/JavaGroupsBridgeProviderTest.java     |  9 ++--
 .../cayenne/event/JMSBridgeProviderTest.java    |  6 +--
 .../org/apache/cayenne/event/JMSModuleIT.java   | 53 ++++++++++++++++++++
 .../cayenne/event/XMPPBridgeProviderTest.java   |  9 ++--
 .../org/apache/cayenne/event/XMPPModuleIT.java  | 53 ++++++++++++++++++++
 7 files changed, 176 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-jgroups/src/main/java/org/apache/cayenne/event/JavaGroupsBridge.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-jgroups/src/main/java/org/apache/cayenne/event/JavaGroupsBridge.java
b/eventbridges/cayenne-jgroups/src/main/java/org/apache/cayenne/event/JavaGroupsBridge.java
index cd7bae2..eee4622 100644
--- a/eventbridges/cayenne-jgroups/src/main/java/org/apache/cayenne/event/JavaGroupsBridge.java
+++ b/eventbridges/cayenne-jgroups/src/main/java/org/apache/cayenne/event/JavaGroupsBridge.java
@@ -197,9 +197,10 @@ public class JavaGroupsBridge extends EventBridge implements MessageListener
{
                 adapter.stop();
             }
 
-            channel.close();
-        }
-        finally {
+            if(channel != null) {
+                channel.close();
+            }
+        } finally {
             adapter = null;
             channel = null;
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JGroupsModuleIT.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JGroupsModuleIT.java
b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JGroupsModuleIT.java
new file mode 100644
index 0000000..cc5e7e0
--- /dev/null
+++ b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JGroupsModuleIT.java
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   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.event;
+
+import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.server.ServerModule;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @since 4.0
+ */
+public class JGroupsModuleIT {
+
+    @Test
+    public void testModule() {
+
+        Module configModule = new Module() {
+            public void configure(Binder binder) {
+                ServerModule.contributeProperties(binder).put(Constants.SERVER_DOMAIN_NAME_PROPERTY,
"test");
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(new ServerModule(), new JGroupsModule(),
configModule);
+        EventBridge bridge = injector.getInstance(EventBridge.class);
+
+        assertThat(bridge, instanceOf(JavaGroupsBridge.class));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java
b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java
index 7f47201..c732296 100644
--- a/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java
+++ b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java
@@ -37,12 +37,13 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class JavaGroupsBridgeProviderTest {
 
-    private final DataDomain DOMAIN = new DataDomain("test");
-    private final EventManager EVENT_MANAGER = new DefaultEventManager();
+    private static final DataDomain DOMAIN = new DataDomain("test");
+    private static final EventManager EVENT_MANAGER = new DefaultEventManager();
     protected static final String MCAST_ADDRESS_TEST = "192.168.0.0";
     protected static final String MCAST_PORT_TEST = "1521";
     protected static final String CONFIG_URL_TEST = "somehost.com";
@@ -81,10 +82,10 @@ public class JavaGroupsBridgeProviderTest {
 
         assertEquals(JavaGroupsBridge.MCAST_ADDRESS_DEFAULT, bridge.getMulticastAddress());
         assertEquals(JavaGroupsBridge.MCAST_PORT_DEFAULT, bridge.getMulticastPort());
-        assertEquals(null, bridge.getConfigURL());
+        assertNull(bridge.getConfigURL());
     }
 
-    class DefaultBindings implements Module {
+    static class DefaultBindings implements Module {
         @Override
         public void configure(Binder binder) {
             binder.bindMap(String.class, Constants.PROPERTIES_MAP);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java
b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java
index a96e349..83c09a1 100644
--- a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java
+++ b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java
@@ -41,8 +41,8 @@ import static org.junit.Assert.assertTrue;
 
 public class JMSBridgeProviderTest {
 
-    private final DataDomain DOMAIN = new DataDomain("test");
-    private final EventManager EVENT_MANAGER = new DefaultEventManager();
+    private static final DataDomain DOMAIN = new DataDomain("test");
+    private static final EventManager EVENT_MANAGER = new DefaultEventManager();
     protected static final String TOPIC_CONNECTION_FACTORY_TEST = "SomeTopicConnectionFactory";
 
     @Test
@@ -77,7 +77,7 @@ public class JMSBridgeProviderTest {
         assertEquals(JMSBridge.TOPIC_CONNECTION_FACTORY_DEFAULT, bridge.getTopicConnectionFactoryName());
     }
 
-    class DefaultBindings implements Module {
+    static class DefaultBindings implements Module {
         @Override
         public void configure(Binder binder) {
             binder.bindMap(String.class, Constants.PROPERTIES_MAP);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSModuleIT.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSModuleIT.java
b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSModuleIT.java
new file mode 100644
index 0000000..c8391ea
--- /dev/null
+++ b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSModuleIT.java
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   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.event;
+
+import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.server.ServerModule;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @since 4.0
+ */
+public class JMSModuleIT {
+
+    @Test
+    public void testModule() {
+
+        Module configModule = new Module() {
+            public void configure(Binder binder) {
+                ServerModule.contributeProperties(binder).put(Constants.SERVER_DOMAIN_NAME_PROPERTY,
"test");
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(new ServerModule(), new JMSModule(),
configModule);
+        EventBridge bridge = injector.getInstance(EventBridge.class);
+
+        assertThat(bridge, instanceOf(JMSBridge.class));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java
b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java
index 93b2c0f..6c0440f 100644
--- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java
+++ b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java
@@ -36,13 +36,14 @@ import org.apache.cayenne.tx.TransactionManager;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class XMPPBridgeProviderTest {
 
-    private final DataDomain DOMAIN = new DataDomain("test");
-    private final EventManager EVENT_MANAGER = new DefaultEventManager();
+    private static final DataDomain DOMAIN = new DataDomain("test");
+    private static final EventManager EVENT_MANAGER = new DefaultEventManager();
     protected static final String HOST_TEST = "somehost.com";
     protected static final String CHAT_SERVICE_TEST = "conference";
     protected static final String LOGIN_TEST = "login";
@@ -89,10 +90,10 @@ public class XMPPBridgeProviderTest {
 
         assertEquals(XMPPBridge.DEFAULT_CHAT_SERVICE, bridge.getChatService());
         assertEquals(0, bridge.getXmppPort());
-        assertEquals(false, bridge.isSecureConnection());
+        assertFalse(bridge.isSecureConnection());
     }
 
-    class DefaultBindings implements Module {
+    static class DefaultBindings implements Module {
         @Override
         public void configure(Binder binder) {
             binder.bindMap(String.class, Constants.PROPERTIES_MAP);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e795b287/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPModuleIT.java
----------------------------------------------------------------------
diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPModuleIT.java
b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPModuleIT.java
new file mode 100644
index 0000000..45173bb
--- /dev/null
+++ b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPModuleIT.java
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   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.event;
+
+import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.server.ServerModule;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @since 4.0
+ */
+public class XMPPModuleIT {
+
+    @Test
+    public void testModule() {
+
+        Module configModule = new Module() {
+            public void configure(Binder binder) {
+                ServerModule.contributeProperties(binder).put(Constants.SERVER_DOMAIN_NAME_PROPERTY,
"test");
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(new ServerModule(), new XMPPModule(),
configModule);
+        EventBridge bridge = injector.getInstance(EventBridge.class);
+
+        assertThat(bridge, instanceOf(XMPPBridge.class));
+    }
+
+}


Mime
View raw message