From: Dave B. <bla...@us...> - 2013-05-10 00:30:17
|
Update of /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/wbem In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27250/utst/org/sblim/cimclient/unittest/wbem Modified Files: Tag: Experimental NestedEmbInstTest.java Log Message: 2637 Add nested embedded instance builder test Index: NestedEmbInstTest.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/wbem/Attic/NestedEmbInstTest.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- NestedEmbInstTest.java 8 May 2013 17:02:50 -0000 1.1.2.1 +++ NestedEmbInstTest.java 10 May 2013 00:30:15 -0000 1.1.2.2 @@ -14,18 +14,25 @@ * Flag Date Prog Description * ------------------------------------------------------------------------------- * 2636 2013-05-08 blaschke-oss Nested embedded instances cause CIMXMLParseException + * 2637 2013-05-09 blaschke-oss Add nested embedded instance builder test */ package org.sblim.cimclient.unittest.wbem; +import java.io.ByteArrayOutputStream; import java.io.InputStream; +import javax.cim.CIMDataType; import javax.cim.CIMInstance; +import javax.cim.CIMObjectPath; import javax.cim.CIMProperty; import javax.cim.UnsignedInteger64; import javax.wbem.CloseableIterator; import javax.wbem.WBEMException; +import org.sblim.cimclient.internal.cimxml.CIMClientXML_HelperImpl; +import org.sblim.cimclient.internal.cimxml.CimXmlSerializer; import org.sblim.cimclient.unittest.TestCase; +import org.w3c.dom.Document; /** * @@ -115,4 +122,82 @@ checkEnumInstResult(Common.parseWithPULL(getInstIS())); } + /** + * testNestedEmbInstBuilder + * + * @throws Exception + */ + public void testNestedEmbInstBuilder() throws Exception { + CIMProperty<String> prop4a = new CIMProperty<String>("CreationClassName", + CIMDataType.STRING_T, "LMI_StorageExtent", true, false, null); + CIMProperty<String> prop4b = new CIMProperty<String>("DeviceID", CIMDataType.STRING_T, + "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-1", true, false, null); + CIMProperty<String> prop4c = new CIMProperty<String>("SystemCreationClassName", + CIMDataType.STRING_T, "Linux_ComputerSystem", true, false, null); + CIMProperty<String> prop4d = new CIMProperty<String>("SystemName", CIMDataType.STRING_T, + "rawhide", true, false, null); + CIMProperty<?>[] props4 = new CIMProperty[] { prop4a, prop4b, prop4c, prop4d }; + + CIMProperty<CIMObjectPath> prop3a = new CIMProperty<CIMObjectPath>("Extent", + new CIMDataType(""), new CIMObjectPath(null, null, null, "root/cimv2", + "CIM_StorageExtent", props4)); + CIMProperty<UnsignedInteger64> prop3b = new CIMProperty<UnsignedInteger64>("Size", + CIMDataType.UINT64_T, new UnsignedInteger64("10000000")); + CIMProperty<?>[] props3 = new CIMProperty[] { prop3a, prop3b }; + CIMInstance inst3 = new CIMInstance(new CIMObjectPath(null, null, null, null, + "CIM_ManagedElement", null), props3); + + CIMProperty<CIMInstance> prop2a = new CIMProperty<CIMInstance>("JobInParameters", + CIMDataType.OBJECT_T, inst3); + CIMProperty<String> prop2b = new CIMProperty<String>("InstanceID", CIMDataType.STRING_T, + "LMI:LMI_StorageJob:1"); + CIMProperty<?>[] props2 = new CIMProperty[] { prop2a, prop2b }; + CIMInstance inst2 = new CIMInstance(new CIMObjectPath(null, null, null, null, + "LMI_StorageJob", null), props2); + + CIMProperty<CIMInstance> prop1a = new CIMProperty<CIMInstance>("SourceInstance", + CIMDataType.OBJECT_T, inst2); + CIMProperty<String> prop1b = new CIMProperty<String>("SourceInstanceModelPath", + CIMDataType.STRING_T, + "//rawhide/root/cimv2:LMI_StorageJob.InstanceID=\"LMI:LMI_StorageJob:1\""); + CIMProperty<?>[] props1 = new CIMProperty[] { prop1a, prop1b }; + CIMInstance inst1 = new CIMInstance(new CIMObjectPath(null, null, null, null, + "LMI_StorageInstModification", null), props1); + + CIMClientXML_HelperImpl helper = new CIMClientXML_HelperImpl(); + helper.setId(3); + Document doc = helper.newDocument(); + helper.createCIMMessage(doc, helper.createInstance_request(doc, new CIMObjectPath(null, + null, null, null, "CIM_ManagedElement", null), inst3)); + ByteArrayOutputStream stream3 = new ByteArrayOutputStream(4096); + CimXmlSerializer.serialize(stream3, doc, false); + + helper.setId(2); + doc = helper.newDocument(); + helper.createCIMMessage(doc, helper.createInstance_request(doc, new CIMObjectPath(null, + null, null, null, "LMI_StorageJob", null), inst2)); + ByteArrayOutputStream stream2 = new ByteArrayOutputStream(4096); + CimXmlSerializer.serialize(stream2, doc, false); + + helper.setId(1); + doc = helper.newDocument(); + helper.createCIMMessage(doc, helper.createInstance_request(doc, new CIMObjectPath(null, + null, null, null, "LMI_StorageInstModification", null), inst1)); + ByteArrayOutputStream stream1 = new ByteArrayOutputStream(4096); + CimXmlSerializer.serialize(stream1, doc, false); + + String level1 = stream3.toString(); + String level2 = stream2.toString(); + String level3 = stream1.toString(); + + String levelExpectedSubstring1 = "<PROPERTY NAME=\"Size\" TYPE=\"uint64\"><VALUE>10000000</VALUE></PROPERTY>"; + // levelExpectedSubstring2 is escaped version of levelExpectedSubstring1 + String levelExpectedSubstring2 = "<PROPERTY NAME="Size" TYPE="uint64"><VALUE>10000000</VALUE></PROPERTY>"; + // levelExpectedSubstring3 is escaped version of levelExpectedSubstring2 + String levelExpectedSubstring3 = "&lt;PROPERTY NAME=&quot;Size&quot; TYPE=&quot;uint64&quot;&gt;&lt;VALUE&gt;10000000&lt;/VALUE&gt;&lt;/PROPERTY&gt;"; + + verify("1st level nesting error!", level1.indexOf(levelExpectedSubstring1) != -1); + verify("2nd level nesting error!", level2.indexOf(levelExpectedSubstring2) != -1); + verify("3rd level nesting error!", level3.indexOf(levelExpectedSubstring3) != -1); + } } |