コード例 #1
0
  @Test
  public void testProcessErrorResponse() throws Exception {
    final HttpClientUtilResponse response = new HttpClientUtilResponse();
    final String mockError =
        "<error>\n"
            + "<errorCode>905</errorCode>\n"
            + "<message>contactZipCode parameter should be 5 numeric characters</message>\n"
            + "</error>";
    response.setResponseByteArray(mockError.getBytes("UTF-8"));

    final ServiceResponseException mockServiceResponseException = new ServiceResponseException();
    mockServiceResponseException.setErrorCode("905");
    mockServiceResponseException.setMessage(
        "contactZipCode parameter should be 5 numeric characters");

    PowerMockito.when(marshaller.unmarshal(Mockito.any(Source.class)))
        .thenReturn(mockServiceResponseException);

    final FormHandlerResponseInterface result =
        customerCareService.processErrorResponse(null, response, true);

    assertNotNull(result);
    assertEquals(new Integer(905), ((Errors) result).getErrors().get(0).getCode());
    assertEquals(
        "contactZipCode parameter should be 5 numeric characters",
        ((Errors) result).getErrors().get(0).getMessage());
  }
コード例 #2
0
ファイル: Maven.java プロジェクト: christophd/jellycastle
 /**
  * Loads project from normal POM location in working directory.
  *
  * @return
  */
 public Project fromPom() {
   try {
     return (Project) marshaller.unmarshal(new StreamSource(getPomFile().getInputStream()));
   } catch (IOException e) {
     throw new RuntimeException("Failed to read Maven pom.xml", e);
   }
 }
コード例 #3
0
 @Override
 protected Lfm unmarshalllData(String xmlData) {
   try {
     oxmLastFMTrackSearch.setSchema(new ClassPathResource("xsd/LastFMTrackSearch.xsd"));
     Lfm returnXMl =
         (Lfm) oxmLastFMTrackSearch.unmarshal(new StreamSource(new StringReader(xmlData)));
     return returnXMl;
   } catch (XmlMappingException e) {
     LOGGER.warn("Error while unmarshalling normal data", e);
     return null;
   }
 }
コード例 #4
0
  @Test
  public void JaxbPos14Test() {

    Jaxb2Marshaller jaxb2Marshaller = (Jaxb2Marshaller) context.getBean("getJaxb2Marshaller");

    EvcomRequestHead erh = new EvcomRequestHead(32423423, 234, "cid string", 234, 2989);

    StringReader reader =
        new StringReader(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<evcom>\n"
                + "<hd>\n"
                + " <stm v=\"20151126105322\"/>\n"
                + " <sid v=\"2\"/>\n"
                + " <cid v=\"01\"/>\n"
                + " <sts v=\"111111\"/>\n"
                + " <tid v=\"2323\"/>\n"
                + "</hd>\n"
                + "<bd>\n"
                + "  <pg>\n"
                + "    <pg_knd v=\"완속 1\"/>\n"
                + "    <ver v=\"fw ver 1.2\"/>\n"
                + "  </pg>\n"
                + "  <pg>\n"
                + "    <pg_knd v=\"급속 2\"/>\n"
                + "    <ver v=\"fw ver 0.8\"/>\n"
                + "  </pg>\n"
                + "  <pg>\n"
                + "    <pg_knd v=\"완속 2\"/>\n"
                + "    <ver v=\"fw ver 1.5\"/>\n"
                + "  </pg>\n"
                + "  <pg>\n"
                + "    <pg_knd v=\"급속 1\"/>\n"
                + "    <ver v=\"fw ver 0.8.1\"/>\n"
                + "  </pg>\n"
                + "</bd>\n"
                + "</evcom>");
    EvcomReqPos14 pos14 = (EvcomReqPos14) jaxb2Marshaller.unmarshal(new StreamSource(reader));

    StreamResult result = new StreamResult(System.out);
    jaxb2Marshaller.marshal(pos14, result);
  }
コード例 #5
0
  @Test
  public void testProcessCustomerCareServiceResponse() throws Exception {
    final HttpClientUtilResponse mockResponse = new HttpClientUtilResponse();
    final String sample =
        "<customer-care-case>\n"
            + "<vin>WAURFAFR7AA078877</vin>\n"
            + "<case-number>71300077</case-number>\n"
            + "</customer-care-case>\n";
    mockResponse.setResponseByteArray(sample.getBytes("UTF-8"));

    final CustomerCareServiceResponseVO mockMarshallResponse = new CustomerCareServiceResponseVO();
    mockMarshallResponse.setVin("WAURFAFR7AA078877");
    mockMarshallResponse.setCaseNumber("71300077");

    PowerMockito.when(marshaller.unmarshal(Mockito.any(Source.class)))
        .thenReturn(mockMarshallResponse);

    final FormHandlerResponseInterface result =
        customerCareService.processCustomerCareServiceResponse(null, mockResponse);

    assertNotNull(result);
    assertEquals("WAURFAFR7AA078877", ((Formhandler) result).getVin());
    assertEquals("71300077", ((Formhandler) result).getCaseNumber());
  }
コード例 #6
0
 @Test
 public void unmarshallTest() throws XmlMappingException, DocumentException {
   Object obj =
       marshaller.unmarshal(new DocumentSource(DocumentHelper.parseText(Themes.scenerioTemplate)));
   assertNotNull(obj);
 }