public void testIssueNavigatorSearchRequestViews() throws Exception {
    try {
      tester.getDialog().getWebClient().setExceptionsThrownOnErrorStatus(false);

      executeIssueNavigatorSearchRequestView(
          400,
          "Error in the JQL Query: The character '#' is a reserved JQL character. You must enclose it in a string or use the escape '\\u0023' instead. (line 1, character 4)",
          "jqlQuery=" + JQL_NOT_PARSEABLE,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          400,
          "The value 'New Component 5' does not exist for the field 'component'.",
          "jqlQuery=" + JQL_IN_VALID_DOESNOT_FIT,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          400,
          "Function 'membersOf' can not generate a list of usernames for group 'blub'; the group does not exist.",
          "jqlQuery=" + JQL_IN_VALID_FITS,
          "pid=123123");
      executeIssueNavigatorSearchRequestView(
          200, "", "jqlQuery=" + JQL_VALID_DOESNOT_FIT, "pid=123123");

      Document doc = XMLUnit.buildControlDocument(tester.getDialog().getResponse().getText());
      XMLAssert.assertXpathExists("/rss/channel/item[key = 'HSP-1']", doc);

      executeIssueNavigatorSearchRequestView(
          200, "", "jqlQuery=" + JQL_VALID_AND_FITS, "pid=10001");

      doc = XMLUnit.buildControlDocument(tester.getDialog().getResponse().getText());
      XMLAssert.assertXpathExists("/rss/channel/item[key = 'HSP-1']", doc);
    } finally {
      tester.getDialog().getWebClient().setExceptionsThrownOnErrorStatus(true);
    }
  }
Ejemplo n.º 2
0
  @Test
  public void testLoanRequestUnableToHandle() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
      String response =
          httpMixIn.postString("http://localhost:8080/loanService/loanService", SOAP_REQUEST_2);
      System.out.println(response);

      org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
      java.util.HashMap<String, String> m = new java.util.HashMap<String, String>();
      // m.put("tns", "http://example.com/loan-approval/loanService/");
      NamespaceContext ctx = new SimpleNamespaceContext(m);
      XpathEngine engine = XMLUnit.newXpathEngine();
      engine.setNamespaceContext(ctx);

      NodeList l = engine.getMatchingNodes("//faultcode", d);
      assertEquals(1, l.getLength());
      assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());

      if (!l.item(0).getTextContent().endsWith(":unableToHandleRequest")) {
        fail("Expecting 'unableToHandleRequest' fault code");
      }
    } finally {
      httpMixIn.uninitialize();
    }
  }
  @Override
  @Test
  public void testDeployment() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
      String response =
          httpMixIn.postString(
              "http://localhost:" + getSoapClientPort() + "/SayHelloService/SayHelloService",
              SOAP_REQUEST);

      org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
      java.util.HashMap<String, String> m = new java.util.HashMap<String, String>();
      m.put("tns", "http://www.jboss.org/bpel/examples");
      NamespaceContext ctx = new SimpleNamespaceContext(m);
      XpathEngine engine = XMLUnit.newXpathEngine();
      engine.setNamespaceContext(ctx);

      NodeList l = engine.getMatchingNodes("//tns:result", d);
      assertEquals(1, l.getLength());
      assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());

      if (!l.item(0).getTextContent().equals("Hello Fred")) {
        fail("Expecting 'Hello Fred'");
      }
    } finally {
      httpMixIn.uninitialize();
    }
  }