activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/3] activemq-6 git commit: ACTIVEMQ6-55: add a test of the listener method throwing the NPE
Date Thu, 12 Mar 2015 14:57:06 GMT
Repository: activemq-6
Updated Branches:
  refs/heads/master d47fba425 -> 341e49e3a


ACTIVEMQ6-55: add a test of the listener method throwing the NPE


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/7ef95ae9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/7ef95ae9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/7ef95ae9

Branch: refs/heads/master
Commit: 7ef95ae977f7c9dcaf13da2959feafb897e8ea80
Parents: 983effc
Author: Robert Gemmell <robbie@apache.org>
Authored: Thu Mar 12 14:25:57 2015 +0000
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Mar 12 10:54:17 2015 -0400

----------------------------------------------------------------------
 .../plug/context/AbstractConnectionContext.java |   3 +-
 .../context/AbstractConnectionContextTest.java  | 114 +++++++++++++++++++
 2 files changed, 116 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/7ef95ae9/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
----------------------------------------------------------------------
diff --git a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
index 20b2d8b..3d0d0bc 100644
--- a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
+++ b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
@@ -47,12 +47,13 @@ public abstract class AbstractConnectionContext extends ProtonInitializable
impl
 
    private final Map<Session, AbstractProtonSessionContext> sessions = new ConcurrentHashMap<>();
 
+   protected LocalListener listener = new LocalListener();
 
    public AbstractConnectionContext(AMQPConnectionCallback connectionCallback)
    {
       this.connectionCallback = connectionCallback;
       connectionCallback.setConnection(this);
-      handler.addEventHandler(new LocalListener());
+      handler.addEventHandler(listener);
    }
 
    public SASLResult getSASLResult()

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/7ef95ae9/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
----------------------------------------------------------------------
diff --git a/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
b/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
new file mode 100644
index 0000000..2396b1e
--- /dev/null
+++ b/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
@@ -0,0 +1,114 @@
+/**
+ * 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.proton.plug.context;
+
+import io.netty.buffer.ByteBuf;
+
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.Link;
+import org.apache.qpid.proton.engine.Session;
+import org.junit.Test;
+import org.proton.plug.AMQPConnectionCallback;
+import org.proton.plug.AMQPConnectionContext;
+import org.proton.plug.AMQPSessionCallback;
+import org.proton.plug.ServerSASL;
+import org.proton.plug.exceptions.ActiveMQAMQPException;
+import org.proton.plug.handler.EventHandler;
+
+public class AbstractConnectionContextTest
+{
+
+   @Test
+   public void testListenerDoesntThrowNPEWhenClosingLinkWithNullContext() throws Exception
+   {
+      TestConnectionContext connectionContext = new TestConnectionContext(new TestConnectionCallback());
+      EventHandler listener = connectionContext.getListener();
+
+      Connection protonConnection = Connection.Factory.create();
+      Session protonSession = protonConnection.session();
+      Link link = protonSession.receiver("link");
+
+      link.setContext(null);
+
+      listener.onRemoteClose(link);
+   }
+
+   private class TestConnectionContext extends AbstractConnectionContext
+   {
+
+      public TestConnectionContext(AMQPConnectionCallback connectionCallback)
+      {
+         super(connectionCallback);
+      }
+
+      @Override
+      protected void remoteLinkOpened(Link link) throws Exception
+      {
+
+      }
+
+      @Override
+      protected AbstractProtonSessionContext newSessionExtension(Session realSession) throws
ActiveMQAMQPException
+      {
+         return null;
+      }
+
+      public EventHandler getListener()
+      {
+         return listener;
+      }
+   }
+
+   private class TestConnectionCallback implements AMQPConnectionCallback
+   {
+      @Override
+      public void close()
+      {
+
+      }
+
+      @Override
+      public void onTransport(ByteBuf bytes, AMQPConnectionContext connection)
+      {
+
+      }
+
+      @Override
+      public AMQPSessionCallback createSessionCallback(AMQPConnectionContext connection)
+      {
+         return null;
+      }
+
+      @Override
+      public void setConnection(AMQPConnectionContext connection)
+      {
+
+      }
+
+      @Override
+      public AMQPConnectionContext getConnection()
+      {
+         return null;
+      }
+
+      @Override
+      public ServerSASL[] getSASLMechnisms()
+      {
+         return null;
+      }
+   }
+}


Mime
View raw message