Update of /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/slp/internal
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1549/utst/org/sblim/cimclient/unittest/slp/internal
Modified Files:
ConvertTest.java
Log Message:
2650 SLP opaque value handling incorrect
Index: ConvertTest.java
===================================================================
RCS file: /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/slp/internal/ConvertTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ConvertTest.java 27 Aug 2009 14:31:35 -0000 1.8
+++ ConvertTest.java 1 Aug 2013 11:45:18 -0000 1.9
@@ -1,5 +1,5 @@
/**
- * (C) Copyright IBM Corp. 2007, 2009
+ * (C) Copyright IBM Corp. 2007, 2013
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
@@ -20,6 +20,7 @@
* 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2)
* 2763216 2009-04-14 blaschke-oss Code cleanup: visible spelling/grammar errors
* 2823494 2009-08-03 rgummada Change Boolean constructor to static
+ * 2650 2013-07-18 blaschke-oss SLP opaque value handling incorrect
*/
package org.sblim.cimclient.unittest.slp.internal;
@@ -29,6 +30,7 @@
import org.sblim.cimclient.unittest.GenericUTestExts;
import org.sblim.cimclient.unittest.TestCase;
import org.sblim.slp.ServiceLocationAttribute;
+import org.sblim.slp.ServiceLocationException;
import org.sblim.slp.internal.AttributeHandler;
import org.sblim.slp.internal.Convert;
@@ -40,8 +42,8 @@
private static final String[] RAW_STRINGS = { "(hi,joe)", "hello~(hi,joe!) world" };
- private static final String[] ESCAPED_STRINGS = { "\\28hi\\2cjoe\\29",
- "hello\\7e\\28hi\\2cjoe\\21\\29 world" };
+ private static final String[] ESCAPED_STRINGS = { "\\28hi\\2Cjoe\\29",
+ "hello\\7E\\28hi\\2Cjoe\\21\\29 world" };
/**
* testEscaping
@@ -95,6 +97,88 @@
}
}
+ private static final String[] ATTR_TAG = { //
+ "attrib-integer1", // 0
+ "attrib-integer2", // 1
+ "attrib-integer3", // 2
+ "attrib-boolean1", // 3
+ "attrib-boolean2", // 4
+ "attrib-opaque1", // 5
+ "attrib-opaque2", // 6
+ "attrib-opaque3", // 7
+ "attrib-opaque4", // 8
+ "attrib-opaque5", // 9
+ "attrib-opaque6", // 10
+ };
+
+ private static final Object[][] ATTR_VAL = {//
+ new Object[] { new Integer(42) }, // 0
+ new Object[] { new Integer(12), new Integer(34) }, // 1
+ new Object[] { new Integer(-86) }, // 2
+ new Object[] { Boolean.TRUE }, // 3
+ new Object[] { Boolean.TRUE, Boolean.FALSE }, // 4
+ new Object[] { new byte[] { 0x00 } }, // 5
+ new Object[] { new byte[] { 0x01, 0x02 } }, // 6
+ new Object[] { new byte[] { 0x03 }, new byte[] { 0x04 } }, // 7
+ new Object[] { new byte[] { 5, 6 }, new byte[] { 7, 8 } }, // 8
+ new Object[] { new byte[] { 62, 63, 64, 65, 66 } }, // 9
+ new Object[] { new byte[] { -34, -79 } }, // 10
+ };
+
+ private static final String[] ATTR_EXP = {//
+ "(attrib-integer1=42)", // 0
+ "(attrib-integer2=12,34)", // 1
+ "(attrib-integer3=-86)", // 2
+ "(attrib-boolean1=true)", // 3
+ "(attrib-boolean2=true,false)", // 4
+ "(attrib-opaque1=\\FF\\00)", // 5
+ "(attrib-opaque2=\\FF\\01\\02)", // 6
+ "(attrib-opaque3=\\FF\\03,\\FF\\04)", // 7
+ "(attrib-opaque4=\\FF\\05\\06,\\FF\\07\\08)", // 8
+ "(attrib-opaque5=\\FF\\3E\\3F\\40\\41\\42)", // 9
+ "(attrib-opaque6=\\FF\\DE\\B1)", // 10
+ };
+
+ /**
+ * testValidAttribs
+ *
+ * @throws Exception
+ */
+ public void testValidAttribs() throws Exception {
+ verify("testValidAttribs arrays not of same length!", (ATTR_TAG.length == ATTR_VAL.length)
+ && (ATTR_TAG.length == ATTR_EXP.length));
+
+ for (int i = 0; i < ATTR_TAG.length; i++) {
+ String tag = ATTR_TAG[i];
+ Vector<Object> val = GenericUTestExts.mkVec(ATTR_VAL[i]);
+ ServiceLocationAttribute sla = new ServiceLocationAttribute(tag, val);
+
+ verify("Unexpected attribute value for tag " + tag + ": " + sla.toString(), ATTR_EXP[i]
+ .equalsIgnoreCase(sla.toString()));
+ }
+ }
+
+ private static final String[] ATTR_BAD = { "(tag=\\FF)", "(tag=\\FF\\)", "(tag=\\FF\\1)",
+ "(tag=\\FF\\123)", "(tag=\\FF\\1G)", "(tag=\\FF789)", "(tag=\\FF\\\\1)" };
+
+ /**
+ * testInvalidAttribs
+ *
+ * @throws Exception
+ */
+ public void testInvalidAttribs() throws Exception {
+ for (int i = 0; i < ATTR_BAD.length; i++) {
+ try {
+ new ServiceLocationAttribute(ATTR_BAD[i]);
+ fail("Invalid attribute " + ATTR_BAD[i] + " did not generate exception");
+ } catch (Exception e) {
+ debug(ATTR_BAD[i] + " produced " + e.getMessage());
+ verify("Attribute " + ATTR_BAD[i] + " generated unexpected exception "
+ + e.getClass().getName(), e instanceof ServiceLocationException);
+ }
+ }
+ }
+
/**
* @param pMsg
*/
|