title: How do I write Junit test case for marshalling and unmarshalling
body: <p>I have the below snippet of code which uses unmarshalling to read the data received from service response. I need to write test cases using junit to test if the code is able to parse both the success and error XML.</p>
  
  <p>Code snippet :</p>
  
  <pre><code>ExecuteLegacyAPICallResponse.ExecuteLegacyAPICallResult result = port.executeLegacyAPICall(sessionID,
                      "srtUpdateRealignment", parameters);
              List&lt;Object&gt; resultList = result.getContent();
  
  Iterator&lt;Object&gt; itr = resultList.iterator();
              while (itr.hasNext()) {
                  Object o = itr.next();
                  LOGGER.info("Object---" + o + " Class----" + o.getClass());
  
                  JAXBContext jaxBContext = JAXBContext.newInstance("webservice.client.wddx");
                  Unmarshaller unmarshallerObj = jaxBContext.createUnmarshaller();
                  WddxPacket wddxPacket = (WddxPacket) unmarshallerObj.unmarshal((Node) o);
  
                  LOGGER.info("wddxPacket----" + wddxPacket);
  
                  Struct structRealign = (Struct) wddxPacket.getData()
                          .getNullOrBooleanOrNumberOrDateTimeOrStringOrArrayOrStructOrRecordsetOrBinary().get(0);
  
                  LOGGER.info("structRealign----" + structRealign);
  
                  for (Var var : structRealign.getVar()) {
                      if ("return_status".equalsIgnoreCase(var.getName())) {
                          Struct dataStruct = (Struct) var
                                  .getNullOrBooleanOrNumberOrDateTimeOrStringOrArrayOrStructOrRecordsetOrBinary().get(0);
                          LOGGER.info("dataStruct return_status----" + dataStruct);
                          isSuccess = isValidStatus(dataStruct);
  
                          if (!isSuccess) {
                              String errDescription = getStatusDescription(dataStruct);
                              throw new ServiceUnavailableException(errDescription);
                          }
                      }
  
                      if ("return_data".equalsIgnoreCase(var.getName())) {
                          Struct dataStruct = (Struct) var
                                  .getNullOrBooleanOrNumberOrDateTimeOrStringOrArrayOrStructOrRecordsetOrBinary().get(0);
                          for (Var dataVar : dataStruct.getVar()) {
                              LOGGER.info("dataStruct return_data----" + dataStruct);
                              if ("recordset_data".equalsIgnoreCase(dataVar.getName())) {
                                  Recordset recordSet = (Recordset) dataVar
                                          .getNullOrBooleanOrNumberOrDateTimeOrStringOrArrayOrStructOrRecordsetOrBinary()
                                          .get(0);
                                  LOGGER.info("recordSet ----" + recordSet);
                                  for (Field field : recordSet.getField()) {
                                      if ("confirmnum".equalsIgnoreCase(field.getName())) {
                                          List&lt;Object&gt; list = field.getNullOrBooleanOrNumberOrDateTimeOrStringOrBinary();
                                          webservice.client.wddx.String value = (webservice.client.wddx.String) list
                                                  .get(0);
                                          confirmNum = value.getvalue();
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
  </code></pre>
  
  <p>The class info comes as <code>org.apache.xerces.dom.ElementNSImpl</code>.</p>
  
  <p>How do I convert the sample XML to this object so that my code is able to unmarshall and parse the result?</p>
  
  <p>Sample XML - </p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
     &lt;soap:Body&gt;
        &lt;ExecuteLegacyAPICallResponse xmlns="http://sdda.schwabrt.com/"&gt;
           &lt;ExecuteLegacyAPICallResult&gt;
              &lt;wddxPacket version="1.0" xmlns=""&gt;
                 &lt;header/&gt;
                 &lt;data&gt;
                    &lt;struct&gt;
                       &lt;var name="return_status"&gt;
                          &lt;struct&gt;
                             &lt;var name="source"&gt;
                                &lt;string&gt;SRTPAS_EXE:processRealignment&lt;/string&gt;
                             &lt;/var&gt;
                             &lt;var name="severity"&gt;
                                &lt;string&gt;Error&lt;/string&gt;
                             &lt;/var&gt;
                             &lt;var name="statuscode"&gt;
                                &lt;number&gt;1&lt;/number&gt;
                             &lt;/var&gt;
                             &lt;var name="statusdesc"&gt;
                                &lt;string&gt;Could not convert variant of type (Null) into type (OleStr)&lt;/string&gt;
                             &lt;/var&gt;
                          &lt;/struct&gt;
                       &lt;/var&gt;
                       &lt;var name="return_request"&gt;
                          &lt;struct&gt;
                             &lt;var name="_tk"&gt;
                                &lt;string&gt;www&lt;/string&gt;
                             &lt;/var&gt;
                             &lt;var name="_rpc"&gt;
                                &lt;string&gt;srtUpdateRealignment&lt;/string&gt;
                             &lt;/var&gt;
                             &lt;var name="_sid"&gt;
                                &lt;string&gt;PAS-1E70CCA1CCC54479A620C1DE2D58987A-80&lt;/string&gt;
                             &lt;/var&gt;
                          &lt;/struct&gt;
                       &lt;/var&gt;
                    &lt;/struct&gt;
                 &lt;/data&gt;
              &lt;/wddxPacket&gt;
           &lt;/ExecuteLegacyAPICallResult&gt;
        &lt;/ExecuteLegacyAPICallResponse&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>Please let me know if any other input is required.</p>