Removed the requirement that the COPSData member (aka. _data) cannot be null. Found... 53/19453/2
authorSteven Pisarski <s.pisarski@cablelabs.com>
Fri, 1 May 2015 20:56:06 +0000 (14:56 -0600)
committerThomas Kee <xsited@yahoo.com>
Fri, 8 May 2015 19:51:59 +0000 (12:51 -0700)
Change-Id: I02e5c8d9562b2ecfbcb30c9ffcc7ac649262a1db
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-driver/src/main/java/org/umu/cops/stack/COPSDecision.java
packetcable-driver/src/test/java/org/umu/cops/stack/COPSDecisionTest.java
packetcable-driver/src/test/java/org/umu/cops/stack/COPSLPDPDecisionTest.java

index 4e152bc890995425c84ab9ad913b075841de1b21..a3847c247a0592739739a3e0f5a79ba987cf4baf 100644 (file)
@@ -112,7 +112,7 @@ public class COPSDecision extends COPSObjBase {
      * @throws java.lang.IllegalArgumentException
      */
     public COPSDecision(final Command cmdCode) {
-        this(CType.DEF, cmdCode, DecisionFlag.NA, new COPSData());
+        this(CType.DEF, cmdCode, DecisionFlag.NA, null);
     }
 
     /**
@@ -132,7 +132,7 @@ public class COPSDecision extends COPSObjBase {
      * @throws java.lang.IllegalArgumentException
      */
     public COPSDecision(final Command cmdCode, final DecisionFlag flags) {
-        this(CType.DEF, cmdCode, flags, new COPSData());
+        this(CType.DEF, cmdCode, flags, null);
     }
 
     /**
@@ -143,7 +143,7 @@ public class COPSDecision extends COPSObjBase {
      * @throws java.lang.IllegalArgumentException
      */
     public COPSDecision(final CType cType, final Command cmdCode, final DecisionFlag flags) {
-        this(cType, cmdCode, flags, new COPSData());
+        this(cType, cmdCode, flags, null);
     }
 
     /**
@@ -178,11 +178,12 @@ public class COPSDecision extends COPSObjBase {
         if (hdr.getCType().equals(CType.NA)) throw new IllegalArgumentException("CType must not be " + CType.NA);
         if (cmdCode == null) throw new IllegalArgumentException("Command code must not be null");
         if (flags == null) throw new IllegalArgumentException("Flags must not be null");
-        if (data == null) throw new IllegalArgumentException("Data object must not be null");
 
         _cmdCode = cmdCode;
         _flags = flags;
-        _data = data;
+
+        if (data == null) _data = new COPSData();
+        else _data = data;
 
         if ((_data.length() % 4) != 0) {
             final int padLen = 4 - (_data.length() % 4);
index 4a80f87e36c8d43ab3139e8a0146938efe89d98b..79582127fd688a70e2b18bd463cc5c7bb64734cc 100644 (file)
@@ -31,11 +31,6 @@ public class COPSDecisionTest {
         new COPSDecision(CType.NA, new COPSData());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void constructor2NullData() {
-        new COPSDecision(CType.DEF, null);
-    }
-
     @Test(expected = IllegalArgumentException.class)
     public void constructor3NullCommand() {
         new COPSDecision(null, DecisionFlag.NA);
@@ -87,11 +82,6 @@ public class COPSDecisionTest {
         new COPSDecision(CType.CSI, Command.INSTALL, null, new COPSData());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void constructor5NullData() {
-        new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.NA, null);
-    }
-
     @Test(expected = IllegalArgumentException.class)
     public void constructor6NullHeader() {
         final COPSObjHeader hdr = null;
@@ -116,7 +106,14 @@ public class COPSDecisionTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void constructor6NullData() {
-        new COPSDecision(new COPSObjHeader(CNum.DEC, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+        new COPSDecision(new COPSObjHeader(CNum.CSI, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+    }
+
+    @Test
+    public void cNumDECAndNullData() {
+        final COPSDecision decision = new COPSDecision(CType.DEF, null);
+        Assert.assertNotNull(decision.getData());
+        Assert.assertEquals(0, decision.getData().getData().length);
     }
 
     @Test
index 3590702ca4ff95cfd99ad542e4ce490580923364..97b2673cbd6392fc2fa7dcb3b674e4058651dcf8 100644 (file)
@@ -37,11 +37,6 @@ public class COPSLPDPDecisionTest {
         new COPSLPDPDecision(CType.CSI, Command.INSTALL, null, new COPSData());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void constructor1NullData() {
-        new COPSLPDPDecision(CType.CSI, Command.INSTALL, DecisionFlag.NA, null);
-    }
-
     @Test(expected = IllegalArgumentException.class)
     public void constructor2NullHeader() {
         final COPSObjHeader hdr = null;
@@ -64,9 +59,10 @@ public class COPSLPDPDecisionTest {
         new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI), Command.INSTALL, null, new COPSData());
     }
 
-    @Test(expected = IllegalArgumentException.class)
     public void constructor2NullData() {
-        new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+        final COPSLPDPDecision decision = new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI),
+                Command.INSTALL, DecisionFlag.NA, null);
+        Assert.assertEquals(0, decision.getData().getData().length);
     }
 
     @Test