Revision: 1331b496bc0f
Author:   [email protected] <[email protected]>
Date:     Thu May  9 04:11:33 2013
Log: Fixed issue #279 SCTP Server is allowed to be removed even though Server Associations are still present

http://code.google.com/p/sctp/source/detail?r=1331b496bc0f

Modified:
 /sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java
 /sctp-impl/src/test/java/org/mobicents/protocols/sctp/ManagementTest.java

=======================================
--- /sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java Thu Apr 25 06:26:50 2013 +++ /sctp-impl/src/main/java/org/mobicents/protocols/sctp/ManagementImpl.java Thu May 9 04:11:33 2013
@@ -554,12 +554,16 @@
                synchronized (this) {
                        Server removeServer = null;
for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
-                               Server serverTemp = n.getValue();
+                               ServerImpl serverTemp = 
(ServerImpl)n.getValue();

                                if (serverName.equals(serverTemp.getName())) {
                                        if (serverTemp.isStarted()) {
throw new Exception(String.format("Server=%s is started. Stop the server before removing", serverName));
                                        }
+
+ if(serverTemp.anonymAssociations.size() !=0 || serverTemp.associations.size() != 0){ + throw new Exception(String.format("Server=%s has Associations. Remove all those Associations before removing Server", serverName));
+                                       }
                                        removeServer = serverTemp;
                                        break;
                                }
=======================================
--- /sctp-impl/src/test/java/org/mobicents/protocols/sctp/ManagementTest.java Wed Aug 15 09:38:13 2012 +++ /sctp-impl/src/test/java/org/mobicents/protocols/sctp/ManagementTest.java Thu May 9 04:11:33 2013
@@ -119,7 +119,24 @@
                server = servers.get(0);
                assertTrue(server.isStarted());

+               // Add association
+ management.addServerAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_NAME, SERVER_ASSOCIATION_NAME, ipChannelType);
+
+               assertEquals(management.getAssociations().size(), 1);
+
                management.stopServer(SERVER_NAME);
+
+               // Try to delete and it should throw error
+               try {
+                       management.removeServer(SERVER_NAME);
+                       fail("Expected Exception");
+               } catch (Exception e) {
+ assertEquals("Server=testserver has Associations. Remove all those Associations before removing Server", e.getMessage());
+               }
+
+               //Try removing Association now
+               // Remove Assoc
+               management.removeAssociation(SERVER_ASSOCIATION_NAME);

                management.removeServer(SERVER_NAME);

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to