Revision: 1feb43c4b92e
Author:   [email protected] <[email protected]>
Date:     Tue May 14 07:22:33 2013
Log:      fixed tests failing due to persistence

http://code.google.com/p/jss7/source/detail?r=1feb43c4b92e

Modified:
/sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImplProxy.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageReassemblyTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageSegmentationTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpRemoveSpcTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/CallingPartyAddressTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageMultiSapTest.java /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java

=======================================
--- /sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java Wed May 8 07:39:39 2013 +++ /sccp/sccp-impl/src/main/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImpl.java Tue May 14 07:22:33 2013
@@ -82,11 +82,11 @@
  *
  */
 public class SccpStackImpl implements SccpStack, Mtp3UserPartListener {
-       private final Logger logger;
+       protected final Logger logger;

- private static final String SCCP_MANAGEMENT_PERSIST_DIR_KEY = "sccpmanagement.persist.dir";
-       private static final String USER_DIR_KEY = "user.dir";
-       private static final String PERSIST_FILE_NAME = "management2.xml";
+ protected static final String SCCP_MANAGEMENT_PERSIST_DIR_KEY = "sccpmanagement.persist.dir";
+       protected static final String USER_DIR_KEY = "user.dir";
+       protected static final String PERSIST_FILE_NAME = "management2.xml";
        private static final String TAB_INDENT = "\t";
        private static final String CLASS_ATTRIBUTE = "type";

@@ -144,11 +144,11 @@
        // protected int localSpc;
        // protected int ni = 2;

-       private final String name;
+       protected final String name;

-       private final TextBuilder persistFile = TextBuilder.newInstance();
+       protected final TextBuilder persistFile = TextBuilder.newInstance();

-       private String persistDir = null;
+       protected String persistDir = null;

        private volatile int segmentationLocalRef = 0;
        private volatile int slsCounter = 0;
@@ -956,7 +956,7 @@

                        writer.close();
                } catch (Exception e) {
- this.logger.error("Error while persisting the Sccp Resource state in file", e); + this.logger.error(String.format("Error while persisting the Sccp Resource state in file=%s", persistFile.toString()), e);
                }
        }

@@ -965,8 +965,7 @@
         *
         * @throws Exception
         */
-       private void load() throws FileNotFoundException {
-
+       protected void load() throws FileNotFoundException {
                XMLObjectReader reader = null;
                try {
reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString()));
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImplProxy.java Tue Nov 13 06:18:58 2012 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/SccpStackImplProxy.java Tue May 14 07:22:33 2013
@@ -22,6 +22,8 @@

 package org.mobicents.protocols.ss7.sccp.impl;

+import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.concurrent.Executors;

 import javolution.util.FastMap;
@@ -52,6 +54,24 @@

        @Override
        public void start() {
+               this.persistFile.clear();
+
+               if (persistDir != null) {
+ this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_")
+                                       .append(PERSIST_FILE_NAME);
+               } else {
+ persistFile.append(System.getProperty(SCCP_MANAGEMENT_PERSIST_DIR_KEY, System.getProperty(USER_DIR_KEY))) + .append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
+               }
+
+ logger.info(String.format("SCCP Management configuration file path %s", persistFile.toString()));
+
+               try {
+                       this.load();
+               } catch (FileNotFoundException e) {
+ logger.warn(String.format("Failed to load the Sccp Management configuration file. \n%s", e.getMessage()));
+               }
+
                this.messageFactory = new MessageFactoryImpl(this);

                this.sccpProvider = new SccpProviderImpl(this);
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageReassemblyTest.java Wed Mar 20 18:23:08 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageReassemblyTest.java Tue May 14 07:22:33 2013
@@ -56,22 +56,24 @@

        @BeforeClass
        public void setUpClass() throws Exception {
-               this.sccpStack1Name = "sspTestSccpStack1";
-               this.sccpStack2Name = "sspTestSccpStack2";
+               this.sccpStack1Name = "MessageReassemblyTestStack1";
+               this.sccpStack2Name = "MessageReassemblyTestStack2";
        }

        @AfterClass
        public void tearDownClass() throws Exception {
        }

+       @Override
        protected void createStack1() {
-        sccpStack1 = createStack(sccpStack1Name);
-        sccpProvider1 = sccpStack1.getSccpProvider();
+        this.sccpStack1 = createStack(sccpStack1Name);
+        this.sccpProvider1 = sccpStack1.getSccpProvider();
     }

+       @Override
     protected void createStack2() {
-        sccpStack2 = createStack(sccpStack2Name);
-        sccpProvider2 = sccpStack2.getSccpProvider();
+               this.sccpStack2 = createStack(sccpStack2Name);
+               this.sccpProvider2 = sccpStack2.getSccpProvider();
     }

     @Override
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageSegmentationTest.java Wed May 8 07:23:03 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/MessageSegmentationTest.java Tue May 14 07:22:33 2013
@@ -26,6 +26,7 @@
 import java.io.ByteArrayInputStream;
 import java.util.Arrays;
 import org.apache.log4j.Logger;
+import org.mobicents.protocols.ss7.Util;
 import org.mobicents.protocols.ss7.indicator.NatureOfAddress;
 import org.mobicents.protocols.ss7.indicator.NumberingPlan;
 import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
@@ -53,7 +54,7 @@
 public class MessageSegmentationTest {

        private Logger logger;
-       private SccpStackImpl stack = new SccpStackImpl("TestStack");
+ private SccpStackImpl stack = new SccpStackImpl("MessageSegmentationTestStack");
        private MessageFactoryImpl messageFactory;
        private static byte[] dataA;

@@ -69,14 +70,16 @@

        @BeforeMethod
        public void setUp() {
+               this.stack.setPersistDir(Util.getTmpTestDir());
+               this.stack.start();
                this.messageFactory = new MessageFactoryImpl(stack);
                this.logger = 
Logger.getLogger(SccpStackImpl.class.getCanonicalName());
-
                stack.setMaxDataMessage(2000);
        }

        @AfterMethod
        public void tearDown() {
+               this.stack.stop();
        }

        public static byte[] getDataA() {
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageTest.java Tue Nov 13 06:18:58 2012 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpDataMessageTest.java Tue May 14 07:22:33 2013
@@ -30,6 +30,7 @@
 import static org.testng.Assert.*;

 import org.apache.log4j.Logger;
+import org.mobicents.protocols.ss7.Util;
 import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
 import org.mobicents.protocols.ss7.sccp.LongMessageRuleType;
 import org.mobicents.protocols.ss7.sccp.impl.SccpStackImpl;
@@ -52,11 +53,12 @@
 public class SccpDataMessageTest {

        private Logger logger;
-       private SccpStackImpl stack = new SccpStackImpl("TestStack");
+ private SccpStackImpl stack = new SccpStackImpl("SccpDataMessageTestStack");
        private MessageFactoryImpl messageFactory;

        @BeforeMethod
        public void setUp() {
+               this.stack.setPersistDir(Util.getTmpTestDir());
                this.messageFactory = new MessageFactoryImpl(stack);
                this.logger = 
Logger.getLogger(SccpStackImpl.class.getCanonicalName());
        }
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageTest.java Tue Nov 13 06:18:58 2012 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpNoticeMessageTest.java Tue May 14 07:22:33 2013
@@ -30,6 +30,7 @@
 import static org.testng.Assert.*;

 import org.apache.log4j.Logger;
+import org.mobicents.protocols.ss7.Util;
 import org.mobicents.protocols.ss7.indicator.NatureOfAddress;
 import org.mobicents.protocols.ss7.indicator.NumberingPlan;
 import org.mobicents.protocols.ss7.indicator.RoutingIndicator;
@@ -60,17 +61,20 @@
 public class SccpNoticeMessageTest {

        private Logger logger;
-       private SccpStackImpl stack = new SccpStackImpl("TestStack");
+ private SccpStackImpl stack = new SccpStackImpl("SccpNoticeMessageTestStack");
        private MessageFactoryImpl messageFactory;

        @BeforeMethod
        public void setUp() {
+               this.stack.setPersistDir(Util.getTmpTestDir());
+               this.stack.start();
                this.messageFactory = new MessageFactoryImpl(stack);
                this.logger = 
Logger.getLogger(SccpStackImpl.class.getCanonicalName());
        }

        @AfterMethod
        public void tearDown() {
+               this.stack.stop();
        }

        public byte[] getDataUdtS() {
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpRemoveSpcTest.java Wed May 1 09:26:40 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/message/SccpRemoveSpcTest.java Tue May 14 07:22:33 2013
@@ -54,12 +54,14 @@
        @BeforeMethod
        public void setUp() {
                this.stack.setPersistDir(Util.getTmpTestDir());
+               this.stack.start();
                this.messageFactory = new MessageFactoryImpl(stack);
                this.logger = 
Logger.getLogger(SccpStackImpl.class.getCanonicalName());
        }

        @AfterMethod
        public void tearDown() {
+               this.stack.stop();
        }

        public byte[] getDataUdt_GT_WithDpc() {
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/CallingPartyAddressTest.java Wed Mar 20 18:23:08 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/CallingPartyAddressTest.java Tue May 14 07:22:33 2013
@@ -57,8 +57,8 @@

        @BeforeClass
        public void setUpClass() throws Exception {
-               this.sccpStack1Name = "sspTestSccpStack1";
-               this.sccpStack2Name = "sspTestSccpStack2";
+               this.sccpStack1Name = "CallingPartyAddressTestStack1";
+               this.sccpStack2Name = "CallingPartyAddressTestStack2";
        }

        @AfterClass
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java Wed Mar 20 18:23:08 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/LoadSharingTest.java Tue May 14 07:22:33 2013
@@ -59,8 +59,8 @@

        @BeforeClass
        public void setUpClass() throws Exception {
-               this.sccpStack1Name = "sspTestSccpStack1";
-               this.sccpStack2Name = "sspTestSccpStack2";
+               this.sccpStack1Name = "LoadSharingTestStack1";
+               this.sccpStack2Name = "LoadSharingTestStack2";
        }

        @AfterClass
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageMultiSapTest.java Wed Mar 20 18:23:08 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageMultiSapTest.java Tue May 14 07:22:33 2013
@@ -58,8 +58,8 @@

        @BeforeClass
        public void setUpClass() throws Exception {
-               this.sccpStack1Name = "sspTestSccpStack1";
-               this.sccpStack2Name = "sspTestSccpStack2";
+               this.sccpStack1Name = "MessageMultiSapTestStack1";
+               this.sccpStack2Name = "MessageMultiSapTestStack2";
        }

        @AfterClass
=======================================
--- /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java Wed Mar 20 18:23:08 2013 +++ /sccp/sccp-impl/src/test/java/org/mobicents/protocols/ss7/sccp/impl/messageflow/MessageTransferTest.java Tue May 14 07:22:33 2013
@@ -63,8 +63,8 @@

        @BeforeClass
        public void setUpClass() throws Exception {
-               this.sccpStack1Name = "sspTestSccpStack1";
-               this.sccpStack2Name = "sspTestSccpStack2";
+               this.sccpStack1Name = "MessageTransferTestStack1";
+               this.sccpStack2Name = "MessageTransferTestStack2";
        }

        @AfterClass

--

--- 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