Revision: be489907eb6f
Author:   Sergey Vetyutnev <[email protected]>
Date:     Thu Sep  6 10:31:31 2012
Log:      TCAP.setDialogIdRanges() are splithed into two methods
http://code.google.com/p/jss7/source/detail?r=be489907eb6f

Modified:
/tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java /tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/DialogIdRangeTest.java

=======================================
--- /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java Wed Aug 1 23:25:10 2012 +++ /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java Thu Sep 6 10:31:31 2012
@@ -85,14 +85,14 @@
        public int getMaxDialogs();

        /**
-       * Sets the range of the generated dialog ids.
-       * In order to sanely normalize maxDialogs and avoid complexity,
-       * separate setters are not provided.
-       *
-       * @param start value
-       * @param end value
+       * Sets the start of the range of the generated dialog ids.
        */
-       public void setDialogIdRanges(long start, long end);
+       public void setDialogIdRangeStart(long val);
+
+       /**
+       * Sets the start of the range of the generated dialog ids.
+       */
+       public void setDialogIdRangeEnd(long val);

        /**
        *
=======================================
--- /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Sun Sep 2 11:15:43 2012 +++ /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Thu Sep 6 10:31:31 2012
@@ -411,6 +411,18 @@

        void start() {
                logger.info("Starting TCAP Provider");
+
+               if (stack.getDialogIdRangeStart() >= 
stack.getDialogIdRangeEnd())
+ throw new IllegalArgumentException("Range start value cannot be equal/greater than Range end value");
+               if (stack.getDialogIdRangeStart() < 1)
+ throw new IllegalArgumentException("Range start value must be greater or equal 1");
+               if (stack.getDialogIdRangeEnd() > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Range end value must be less or equal " + Integer.MAX_VALUE);
+               if (stack.getDialogIdRangeEnd() - stack.getDialogIdRangeStart() 
< 10000)
+ throw new IllegalArgumentException("Range \"end - start\" must has at least 10000 possible dialogs"); + if (stack.getDialogIdRangeEnd() - stack.getDialogIdRangeStart() <= stack.maxDialogs) + throw new IllegalArgumentException("MaxDialog must be less than DialogIdRange");
+
                this._EXECUTOR = Executors.newScheduledThreadPool(4);
                this.sccpProvider.registerSccpListener(ssn, this);
                logger.info("Registered SCCP listener with address " + ssn);
=======================================
--- /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java Thu Aug 2 01:31:27 2012 +++ /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java Thu Sep 6 10:31:31 2012
@@ -56,7 +56,7 @@
        private long dialogTimeout = _DIALOG_TIMEOUT;
        private long invokeTimeout = _INVOKE_TIMEOUT;
        // TODO: make this configurable
-       private int maxDialogs = _MAX_DIALOGS;
+       protected int maxDialogs = _MAX_DIALOGS;

        // TODO: make this configurable
        private long dialogIdRangeStart = 1;
@@ -166,21 +166,29 @@
                return maxDialogs;
        }

-       public void setDialogIdRanges(long start, long end) {
-               if (start >= end)
- throw new IllegalArgumentException("Range start value cannot be equal/greater than Range end value");
-               if (start < 1)
- throw new IllegalArgumentException("Range start value must be greater or equal 1");
-               if (end > Integer.MAX_VALUE)
- throw new IllegalArgumentException("Range end value must be less or equal " + Integer.MAX_VALUE);
-               if (end - start < 10000)
- throw new IllegalArgumentException("Range \"end - start\" must has at least 10000 possible dialogs");
-               if (end - start <= maxDialogs)
- throw new IllegalArgumentException("MaxDialog must be less than DialogIdRange");
+       public void setDialogIdRangeStart(long val){
+               dialogIdRangeStart = val;
+       }

-               dialogIdRangeStart = start;
-               dialogIdRangeEnd = end;
+       public void setDialogIdRangeEnd(long val) {
+               dialogIdRangeEnd = val;
        }
+
+//     public void setDialogIdRanges(long start, long end) {
+//             if (start >= end)
+// throw new IllegalArgumentException("Range start value cannot be equal/greater than Range end value");
+//             if (start < 1)
+// throw new IllegalArgumentException("Range start value must be greater or equal 1");
+//             if (end > Integer.MAX_VALUE)
+// throw new IllegalArgumentException("Range end value must be less or equal " + Integer.MAX_VALUE);
+//             if (end - start < 10000)
+// throw new IllegalArgumentException("Range \"end - start\" must has at least 10000 possible dialogs");
+//             if (end - start <= maxDialogs)
+// throw new IllegalArgumentException("MaxDialog must be less than DialogIdRange");
+//
+//             dialogIdRangeStart = start;
+//             dialogIdRangeEnd = end;
+//     }

        public long getDialogIdRangeStart() {
                return dialogIdRangeStart;
=======================================
--- /tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/DialogIdRangeTest.java Thu Aug 2 01:31:27 2012 +++ /tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/DialogIdRangeTest.java Thu Sep 6 10:31:31 2012
@@ -94,32 +94,83 @@
// d = this.tcapStack1.getProvider().getNewDialog(peer1Address, peer2Address);
 //             assertEquals((long)d.getDialogId(), 21);
 //             d.release();
-
-               this.tcapStack1.setDialogIdRanges(20, 10020);

-               assertEquals(this.tcapStack1.getDialogIdRangeStart(), 20);
-               assertEquals(this.tcapStack1.getDialogIdRangeEnd(), 10020);
+               this.tcapStack1.stop();

+               this.tcapStack1.setDialogIdRangeStart(20);
+               this.tcapStack1.setDialogIdRangeEnd(10020);
+               this.tcapStack1.start();
+               this.tcapStack1.stop();
+
+               this.tcapStack1.setDialogIdRangeStart(20);
+               this.tcapStack1.setDialogIdRangeEnd(10019);
                try {
-                       this.tcapStack1.setDialogIdRanges(20, 10019);
+                       this.tcapStack1.start();
+                       this.tcapStack1.stop();
                        fail("Must be exception");
                } catch (Exception e) {
-               }
+               }
+
+               this.tcapStack1.setDialogIdRangeStart(20000);
+               this.tcapStack1.setDialogIdRangeEnd(20);
                try {
-                       this.tcapStack1.setDialogIdRanges(20000, 20);
+                       this.tcapStack1.start();
+                       this.tcapStack1.stop();
                        fail("Must be exception");
                } catch (Exception e) {
-               }
+               }
+
+               this.tcapStack1.setDialogIdRangeStart(-1);
+               this.tcapStack1.setDialogIdRangeEnd(20000);
                try {
-                       this.tcapStack1.setDialogIdRanges(-1, 20000);
+                       this.tcapStack1.start();
+                       this.tcapStack1.stop();
                        fail("Must be exception");
                } catch (Exception e) {
-               }
+               }
+
+               this.tcapStack1.setDialogIdRangeStart(1);
+               this.tcapStack1.setDialogIdRangeEnd(20000000000L);
                try {
-                       this.tcapStack1.setDialogIdRanges(1, 20000000000L);
+                       this.tcapStack1.start();
+                       this.tcapStack1.stop();
                        fail("Must be exception");
                } catch (Exception e) {
-               }
+               }
+
+
+               this.tcapStack1.setDialogIdRangeStart(20);
+               this.tcapStack1.setDialogIdRangeEnd(10020);
+               this.tcapStack1.start();
+
+
+
+
+//             this.tcapStack1.setDialogIdRanges(20, 10020);
+//
+//             assertEquals(this.tcapStack1.getDialogIdRangeStart(), 20);
+//             assertEquals(this.tcapStack1.getDialogIdRangeEnd(), 10020);
+//
+//             try {
+//                     this.tcapStack1.setDialogIdRanges(20, 10019);
+//                     fail("Must be exception");
+//             } catch (Exception e) {
+//             }
+//             try {
+//                     this.tcapStack1.setDialogIdRanges(20000, 20);
+//                     fail("Must be exception");
+//             } catch (Exception e) {
+//             }
+//             try {
+//                     this.tcapStack1.setDialogIdRanges(-1, 20000);
+//                     fail("Must be exception");
+//             } catch (Exception e) {
+//             }
+//             try {
+//                     this.tcapStack1.setDialogIdRanges(1, 20000000000L);
+//                     fail("Must be exception");
+//             } catch (Exception e) {
+//             }

d = this.tcapStack1.getProvider().getNewDialog(peer1Address, peer2Address);
                assertEquals((long)d.getDialogId(), 20);

Reply via email to