From eea933da35ca713b4a800785afa00b60a4fe4807 Mon Sep 17 00:00:00 2001 From: Vojtech Krasa Date: Sun, 19 Apr 2015 01:38:59 +0200 Subject: [PATCH 1/2] #93 the session is closed when the channel is --- .../java/com/cloudhopper/smpp/impl/DefaultSmppSession.java | 1 + .../com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java b/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java index 66ff11b7..632f753e 100644 --- a/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java +++ b/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java @@ -708,6 +708,7 @@ public void fireChannelClosed() { // do nothing -- ignore it logger.debug("Unbind/close was requested, ignoring channelClosed event"); } else { + this.state.set(STATE_CLOSED); this.sessionHandler.fireChannelUnexpectedlyClosed(); } } diff --git a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java index 05edc849..28e8b4f9 100644 --- a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java +++ b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java @@ -730,8 +730,9 @@ public void remoteCloseDoesTriggerUnexpectedlyClosedEvent() throws Exception { Thread.sleep(500); Assert.assertEquals(1, sessionHandler.getClosedCount()); - // DEFAULT handling is that we don't do anything special with this... - Assert.assertEquals(true, session.isBound()); + // the session is closed when the channel is + Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); // unbind the session now -- this should work okay even though the channel is closed session.unbind(100); From 32ad71f60369c1ddca32f0c8ed883253b8921c0b Mon Sep 17 00:00:00 2001 From: Vojtech Krasa Date: Sun, 19 Apr 2015 01:39:26 +0200 Subject: [PATCH 2/2] more session state assertions --- .../java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java index 28e8b4f9..3e764cc1 100644 --- a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java +++ b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java @@ -629,6 +629,7 @@ public void closeDoesNotTriggerUnexpectedlyClosedEvent() throws Exception { Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @@ -650,6 +651,7 @@ public void unbindWithNoResponseDoesNotTriggerUnexpectedlyClosedEvent() throws E Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @Test @@ -676,6 +678,7 @@ public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @Test