private void assertXMLFilesMatch(String label, IFile testFile, String expectedFileLocation)
     throws Exception {
   Reader testReader = null;
   Reader expectedReader = null;
   try {
     testReader = new InputStreamReader(testFile.getContents());
     expectedReader =
         new InputStreamReader(
             CreateSwitchYardProjectTest.class
                 .getClassLoader()
                 .getResourceAsStream(expectedFileLocation));
     Diff diff = XMLUnit.compareXML(testReader, expectedReader);
     assertTrue(label + ": " + diff.toString(), diff.identical());
   } finally {
     if (testReader != null) {
       try {
         testReader.close();
       } catch (Exception e) {
         // for codestyle check
         e.fillInStackTrace();
       }
       testReader = null;
     }
     if (expectedReader != null) {
       try {
         expectedReader.close();
       } catch (Exception e) {
         // for codestyle check
         e.fillInStackTrace();
       }
       expectedReader = null;
     }
   }
 }
  @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();
    }
  }
  public GetCapabilitiesScaleHintTest() {

    Map<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("xlink", "http://www.w3.org/1999/xlink");
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
    xpath = XMLUnit.newXpathEngine();
  }
  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);
    }
  }
  /**
   * Sets the up.
   *
   * @throws Exception the exception
   */
  @Before
  public void setUp() throws Exception {
    fileAnticipator = new FileAnticipator();
    context = JAXBContext.newInstance(TcaDataCollectionConfig.class);
    marshaller = context.createMarshaller();
    unmarshaller = context.createUnmarshaller();

    TcaRrd rrd = new TcaRrd();
    rrd.addRra("RRA:AVERAGE:0.5:1:3600");
    rrd.addRra("RRA:AVERAGE:0.5:300:288");
    rrd.addRra("RRA:MIN:0.5:300:288");
    rrd.addRra("RRA:MAX:0.5:300:288");
    rrd.addRra("RRA:AVERAGE:0.5:900:2880");
    rrd.addRra("RRA:MIN:0.5:900:2880");
    rrd.addRra("RRA:MAX:0.5:900:2880");
    rrd.addRra("RRA:AVERAGE:0.5:3600:4300");
    rrd.addRra("RRA:MIN:0.5:3600:4300");
    rrd.addRra("RRA:MAX:0.5:3600:4300");

    TcaDataCollection tcadc = new TcaDataCollection();
    tcadc.setName("default");
    tcadc.setRrd(rrd);
    tcadcc = new TcaDataCollectionConfig();
    tcadcc.addDataCollection(tcadc);
    tcadcc.setRrdRepository("target/snmp/");

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setNormalize(true);
  }
  private boolean isdifferent(Document testDoc, Document controlDoc) {
    boolean isdifferent = false;

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setNormalize(true);

    Diff myDiff = new Diff(controlDoc, testDoc);
    DetailedDiff myComparisonController = new DetailedDiff(myDiff);
    DifferenceEngine engine = new DifferenceEngine(myComparisonController);
    XmlDifferenceListener listener = new XmlDifferenceListener();
    ElementNameAndAttributeQualifier myElementQualifier = new ElementNameAndAttributeQualifier();
    try { // debug
      engine.compare(
          controlDoc.getDocumentElement(),
          testDoc.getDocumentElement(),
          listener,
          myElementQualifier);
    } catch (NullPointerException ne) {
      LOG.error("NPE: " + ne.getMessage(), ne);
    }

    isdifferent = listener.called();
    return isdifferent;
  }
示例#7
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();
    }
  }
示例#8
0
  @Before
  public void setup() {

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setXSLTVersion("2.0");
  }
 @Before
 public void setUp() throws Exception {
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setNormalizeWhitespace(true);
   XMLUnit.setNormalize(true);
 }
 @BeforeClass
 public static void setUp() {
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setNormalizeWhitespace(true);
   XMLUnit.setCompareUnmatched(false);
 }
示例#11
0
 @Test
 public void testWriteComplete() throws Exception {
   String old_xml = new StringPuller().pull(COMPLETE_XML, getClass());
   SwitchYardModel switchyard = _puller.pull(new StringReader(old_xml));
   String new_xml = switchyard.toString();
   XMLUnit.setIgnoreWhitespace(true);
   Diff diff = XMLUnit.compareXML(old_xml, new_xml);
   Assert.assertTrue(diff.toString(), diff.identical());
 }
示例#12
0
 @Before
 public void setUp() {
   MockLogAppender.setupLogging(true);
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreComments(true);
   XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
   XMLUnit.setNormalize(true);
 }
  @Test
  public void testAudioMD_noMD5() throws Exception {

    Fits fits = new Fits();

    // First generate the FITS output
    File input = new File("testfiles/test.wav");
    FitsOutput fitsOut = fits.examine(input);

    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    String actualXmlStr = serializer.outputString(fitsOut.getFitsXml());

    // Read in the expected XML file
    Scanner scan = new Scanner(new File("testfiles/output/FITS_test_wav_NO_MD5.xml"));
    String expectedXmlStr = scan.useDelimiter("\\Z").next();
    scan.close();

    // Set up XMLUnit
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setNormalizeWhitespace(true);

    Diff diff = new Diff(expectedXmlStr, actualXmlStr);

    // Initialize attributes or elements to ignore for difference checking
    diff.overrideDifferenceListener(
        new IgnoreNamedElementsDifferenceListener(
            "version",
            "toolversion",
            "dateModified",
            "fslastmodified",
            "lastmodified",
            "startDate",
            "startTime",
            "timestamp",
            "fitsExecutionTime",
            "executionTime",
            "filepath",
            "location"));

    DetailedDiff detailedDiff = new DetailedDiff(diff);

    // Display any Differences
    List<Difference> diffs = detailedDiff.getAllDifferences();
    if (!diff.identical()) {
      StringBuffer differenceDescription = new StringBuffer();
      differenceDescription.append(diffs.size()).append(" differences");

      System.out.println(differenceDescription.toString());
      for (Difference difference : diffs) {
        System.out.println(difference.toString());
      }
    }

    assertTrue("Differences in XML", diff.identical());
  }
 protected boolean checkDocs(Document doc1, Document doc2) {
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreWhitespace(true);
   DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(doc1, doc2));
   boolean result = diff.similar();
   if (!result) {
     for (Difference d : (List<Difference>) diff.getAllDifferences()) {
       System.out.println(d);
     }
   }
   return result;
 }
 public static void assertSimilarXml(String expectedXml, String xml) {
   XMLUnit.setIgnoreWhitespace(true);
   Diff diff;
   try {
     diff = XMLUnit.compareXML(xml, expectedXml);
   } catch (SAXException e) {
     throw new IllegalArgumentException("Could not run XML comparison", e);
   } catch (IOException e) {
     throw new IllegalArgumentException("Could not run XML comparison", e);
   }
   String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml;
   assertTrue(message, diff.similar());
 }
 @BeforeDeploy
 public void setProperties() {
   // Carga un puerto libre para levantar el servidor jetty embebido
   if (null != System.getProperty("jettyPortSwitchyard")) {
     propMixIn.set("jettyPort", System.getProperty("jettyPortSwitchyard"));
   } else {
     propMixIn.set("jettyPort", JETTY_SWITCHYARD_DEFAULT_PORT);
   }
   // Configuro XMLUnit
   XMLUnit.setIgnoreWhitespace(true);
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreComments(true);
 }
示例#17
0
  @Test
  public void test() throws IOException, SAXException {
    XMLBinding xmlBinding =
        new XMLBinding().add(getClass().getResourceAsStream("POType-binding.xml")).intiailize();

    String poXML = StreamUtils.readStreamAsString(getClass().getResourceAsStream("po.xml"));
    POType po = xmlBinding.fromXML(new StringSource(poXML), POType.class);

    StringWriter writer = new StringWriter();
    xmlBinding.toXML(po, writer);

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.compareXML(poXML, writer.toString());
  }
示例#18
0
  public void testMultiLayer() throws Exception {
    Document doc =
        getAsDOM(
            "/wfs?request=GetFeature&typename="
                + getLayerId(MockData.BASIC_POLYGONS)
                + ","
                + getLayerId(MockData.BRIDGES)
                + "&version=1.0.0&service=wfs");
    // print(doc);

    XpathEngine engine = XMLUnit.newXpathEngine();
    String schemaLocation = engine.evaluate("wfs:FeatureCollection/@xsi:schemaLocation", doc);
    assertNotNull(schemaLocation);
    String[] parsedLocations = schemaLocation.split("\\s+");
    // System.out.println(Arrays.toString(parsedLocations));
    int i = 0;
    for (; i < parsedLocations.length; i += 2) {
      if (parsedLocations[i].equals("http://www.opengis.net/cite")) {
        assertEquals(
            "http://localhost:8080/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=cite%3ABasicPolygons,cite%3ABridges",
            parsedLocations[i + 1]);
        break;
      }
    }
    if (i >= parsedLocations.length) {
      fail("Could not find the http://www.opengis.net/cite schema location!");
    }
  }
示例#19
0
  @Test
  public void testLegend() throws Exception {
    String layerId = getLayerId(MockData.BASIC_POLYGONS);
    final String requestUrl =
        "wms/kml?layers="
            + layerId
            + "&styles=polygon&mode=download&format_options=legend:true" //
            + "&legend_options=fontStyle:bold;fontColor:ff0000;fontSize:18";
    Document doc = getAsDOM(requestUrl);
    // print(doc);

    assertEquals("kml", doc.getDocumentElement().getNodeName());

    // the icon itself
    XpathEngine xpath = XMLUnit.newXpathEngine();
    String href = xpath.evaluate("//kml:ScreenOverlay/kml:Icon/kml:href", doc);
    assertTrue(href.contains("request=GetLegendGraphic"));
    assertTrue(href.contains("layer=cite%3ABasicPolygons"));
    assertTrue(href.contains("style=polygon"));
    assertTrue(
        href.contains("LEGEND_OPTIONS=fontStyle%3Abold%3BfontColor%3Aff0000%3BfontSize%3A18"));

    // overlay location
    XMLAssert.assertXpathEvaluatesTo("0.0", "//kml:ScreenOverlay/kml:overlayXY/@x", doc);
    XMLAssert.assertXpathEvaluatesTo("0.0", "//kml:ScreenOverlay/kml:overlayXY/@y", doc);
    XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:overlayXY/@xunits", doc);
    XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:overlayXY/@yunits", doc);
    XMLAssert.assertXpathEvaluatesTo("10.0", "//kml:ScreenOverlay/kml:screenXY/@x", doc);
    XMLAssert.assertXpathEvaluatesTo("20.0", "//kml:ScreenOverlay/kml:screenXY/@y", doc);
    XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:screenXY/@xunits", doc);
    XMLAssert.assertXpathEvaluatesTo("pixels", "//kml:ScreenOverlay/kml:screenXY/@yunits", doc);
  }
  private boolean updateExistingItem(AbstractItem item, String config) {
    boolean created;

    // Leverage XMLUnit to perform diffs
    Diff diff;
    try {
      String oldJob = item.getConfigFile().asString();
      diff = XMLUnit.compareXML(oldJob, config);
      if (diff.similar()) {
        LOGGER.log(Level.FINE, format("Item %s is identical", item.getName()));
        return false;
      }
    } catch (Exception e) {
      // It's not a big deal if we can't diff, we'll just move on
      LOGGER.warning(e.getMessage());
    }

    LOGGER.log(Level.FINE, format("Updating item %s as %s", item.getName(), config));
    Source streamSource = new StreamSource(new StringReader(config));
    try {
      item.updateByXml(streamSource);
      created = true;
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, format("Error writing updated item to file."), e);
      created = false;
    }
    return created;
  }
  @Test
  public void verifyExtractionTempGenNoRequired()
      throws TestEvalException, SAXException, IOException, TransformerException {

    String entityType = "no-primary-required.json";
    DOMHandle res = new DOMHandle();
    logger.info("Validating extraction template for:" + entityType);
    try {
      res = evalOneResult("fn:doc( '" + entityType + "')=>es:extraction-template-generate()", res);
    } catch (TestEvalException e) {
      throw new RuntimeException(e);
    }
    // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new
    // StringHandle()).get());
    // DOMHandle handle = docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new
    // DOMHandle());
    Document template = res.get();

    InputStream is =
        this.getClass()
            .getResourceAsStream(
                "/test-extraction-template/" + entityType.replace(".json", ".xml"));
    Document filesystemXML = builder.parse(is);

    // debugOutput(template);

    XMLUnit.setIgnoreWhitespace(true);
    XMLAssert.assertXMLEqual(
        "Must be no validation errors for schema " + entityType + ".", filesystemXML, template);
  }
  @Test
  public void verifyExtractionTemplateGenerate()
      throws TestEvalException, SAXException, IOException, TransformerException {

    for (String entityType : entityTypes) {
      if (entityType.contains(".json")
          || entityType.contains(".jpg")
          || entityType.contains("primary-key-as-a-ref")) {
        continue;
      }

      logger.info("Validating extraction template for:" + entityType);
      // logger.info(docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new
      // StringHandle()).get());
      DOMHandle handle =
          docMgr.read(entityType.replaceAll("\\.(xml|json)", ".tdex"), new DOMHandle());
      Document template = handle.get();

      InputStream is =
          this.getClass().getResourceAsStream("/test-extraction-template/" + entityType);
      Document filesystemXML = builder.parse(is);

      // debugOutput(template);

      XMLUnit.setIgnoreWhitespace(true);
      XMLAssert.assertXMLEqual(
          "Must be no validation errors for schema " + entityType + ".", filesystemXML, template);
    }
  }
示例#23
0
  @Test
  public void testMergeMap() throws Exception {
    final File filename = new File(srcDir, "merged.xml");

    final KeyrefReader keyrefreader = new KeyrefReader();
    keyrefreader.read(filename.toURI(), readMap(filename));
    final KeyScope act = keyrefreader.getKeyDefinition();

    final Map<String, String> exp = new HashMap<String, String>();
    exp.put(
        "toner-specs",
        "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-specs\" href=\"toner-type-a-specs.dita\"/>");
    exp.put(
        "toner-handling",
        "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-handling\" href=\"toner-type-b-handling.dita\"/>");
    exp.put(
        "toner-disposal",
        "<keydef class=\"+ map/topicref mapgropup-d/keydef \" keys=\"toner-disposal\" href=\"toner-type-c-disposal.dita\"/>");

    TestUtils.resetXMLUnit();
    XMLUnit.setIgnoreWhitespace(true);
    assertEquals(exp.keySet(), act.keySet());
    for (Map.Entry<String, String> e : exp.entrySet()) {
      final Document ev = keyDefToDoc(e.getValue());
      final Document av = act.get(e.getKey()).element.getOwnerDocument();
      assertXMLEqual(ev, av);
    }
  }
示例#24
0
  @Test
  public void testNamespaceFilter() throws Exception {
    // try to filter on an existing namespace
    Document dom =
        getAsDOM(
            BASEPATH + "?request=GetCapabilities&service=WCS&acceptversions=1.1.1&namespace=wcs");
    Element e = dom.getDocumentElement();
    assertEquals("Capabilities", e.getLocalName());
    XpathEngine xpath = XMLUnit.newXpathEngine();
    assertTrue(
        xpath
                .getMatchingNodes("//wcs:CoverageSummary/ows:Title[starts-with(., wcs)]", dom)
                .getLength()
            > 0);
    assertEquals(
        0,
        xpath
            .getMatchingNodes("//wcs:CoverageSummary/ows:Title[not(starts-with(., wcs))]", dom)
            .getLength());

    // now filter on a missing one
    dom =
        getAsDOM(
            BASEPATH
                + "?request=GetCapabilities&service=WCS&acceptversions=1.1.1&namespace=NoThere");
    e = dom.getDocumentElement();
    assertEquals("Capabilities", e.getLocalName());
    assertEquals(0, xpath.getMatchingNodes("//wcs:CoverageSummary", dom).getLength());
  }
示例#25
0
  /** @see {@link KMLReflector#organizeFormatOptionsParams(Map, Map)} */
  @Test
  public void testKmlFormatOptionsAsKVP() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    final String baseUrl = "wms/kml?layers=" + layerName + "&styles=&mode=superoverlay";
    final String requestUrl =
        baseUrl + "&kmltitle=myCustomLayerTitle&kmscore=10&legend=true&kmattr=true";
    Document dom = getAsDOM(requestUrl);
    XpathEngine xpath = XMLUnit.newXpathEngine();

    // print(dom);
    // all the kvp parameters (which should be set as format_options now are correctly parsed)
    String result = xpath.evaluate("//kml:NetworkLink/kml:Link/kml:href", dom);
    Map<String, Object> kvp = KvpUtils.parseQueryString(result);
    List<String> formatOptions = Arrays.asList(((String) kvp.get("format_options")).split(";"));
    assertEquals(9, formatOptions.size());
    assertTrue(formatOptions.contains("LEGEND:true"));
    assertTrue(formatOptions.contains("SUPEROVERLAY:true"));
    assertTrue(formatOptions.contains("AUTOFIT:true"));
    assertTrue(formatOptions.contains("KMPLACEMARK:false"));
    assertTrue(formatOptions.contains("OVERLAYMODE:auto"));
    assertTrue(formatOptions.contains("KMSCORE:10"));
    assertTrue(formatOptions.contains("MODE:superoverlay"));
    assertTrue(formatOptions.contains("KMATTR:true"));
    assertTrue(formatOptions.contains("KMLTITLE:myCustomLayerTitle"));
  }
  private boolean updateExistingJob(AbstractProject<?, ?> project, String config) {
    boolean created;

    // Leverage XMLUnit to perform diffs
    Diff diff;
    try {
      String oldJob = project.getConfigFile().asString();
      diff = XMLUnit.compareXML(oldJob, config);
      if (diff.similar()) {
        LOGGER.log(Level.FINE, String.format("Project %s is identical", project.getName()));
        return false;
      }
    } catch (Exception e) {
      // It's not a big deal if we can't diff, we'll just move on
      LOGGER.warning(e.getMessage());
    }

    // TODO Perform comparison between old and new, and print to console
    // TODO Print out, for posterity, what the user might have changed, in the format of the DSL

    LOGGER.log(Level.FINE, String.format("Updating project %s as %s", project.getName(), config));
    StreamSource streamSource =
        new StreamSource(new StringReader(config)); // TODO use real xmlReader
    try {
      project.updateByXml(streamSource);
      created = true;
    } catch (IOException ioex) {
      LOGGER.log(Level.WARNING, String.format("Error writing updated project to file."), ioex);
      created = false;
    }
    return created;
  }
示例#27
0
  /**
   * Verify that NetworkLink's generated by the reflector do not include a BBOX parameter, since
   * that would override the BBOX provided by Google Earth.
   *
   * @see <a href="https://osgeo-org.atlassian.net/browse/GEOS-2185">GEOS-2185</a>
   */
  @Test
  public void testNoBBOXInHREF() throws Exception {
    final String layerName = MockData.BASIC_POLYGONS.getLocalPart();
    final XpathEngine xpath = XMLUnit.newXpathEngine();
    String requestURL = "wms/kml?mode=refresh&layers=" + layerName;
    Document dom = getAsDOM(requestURL);
    print(dom);
    assertXpathEvaluatesTo("1", "count(kml:kml/kml:Document)", dom);
    assertXpathEvaluatesTo("1", "count(kml:kml/kml:Document/kml:NetworkLink)", dom);
    assertXpathEvaluatesTo("1", "count(kml:kml/kml:Document/kml:LookAt)", dom);

    assertXpathEvaluatesTo(layerName, "kml:kml/kml:Document/kml:NetworkLink[1]/kml:name", dom);
    assertXpathEvaluatesTo("1", "kml:kml/kml:Document/kml:NetworkLink[1]/kml:open", dom);
    assertXpathEvaluatesTo("1", "kml:kml/kml:Document/kml:NetworkLink[1]/kml:visibility", dom);

    assertXpathEvaluatesTo(
        "onStop", "kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:viewRefreshMode", dom);
    assertXpathEvaluatesTo(
        "1.0", "kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:viewRefreshTime", dom);
    assertXpathEvaluatesTo(
        "1.0", "kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:viewBoundScale", dom);
    Map<String, Object> expectedKVP =
        KvpUtils.parseQueryString(
            "http://localhost:80/geoserver/wms?format_options=MODE%3Arefresh%3Bautofit%3Atrue%3BKMPLACEMARK%3Afalse%3BKMATTR%3Atrue%3BKMSCORE%3A40%3BSUPEROVERLAY%3Afalse&service=wms&srs=EPSG%3A4326&width=2048&styles=BasicPolygons&height=2048&transparent=false&request=GetMap&layers=cite%3ABasicPolygons&format=application%2Fvnd.google-earth.kml+xml&version=1.1.1");
    Map<String, Object> resultedKVP =
        KvpUtils.parseQueryString(
            xpath.evaluate("kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:href", dom));

    assertMapsEqual(expectedKVP, resultedKVP);

    String href = xpath.evaluate("kml:kml/kml:Document/kml:NetworkLink/kml:Link/kml:href", dom);
    Pattern badPattern = Pattern.compile("&bbox=", Pattern.CASE_INSENSITIVE);
    assertFalse(badPattern.matcher(href).matches());
  }
示例#28
0
 public void testNSStack2() throws Exception {
   String msg = prefix + m2 + suffix;
   StringReader strReader = new StringReader(msg);
   DeserializationContext dser =
       new DeserializationContext(
           new InputSource(strReader), null, org.apache.axis.Message.REQUEST);
   dser.parse();
   org.apache.axis.message.SOAPEnvelope env = dser.getEnvelope();
   String xml = env.toString();
   boolean oldIgnore = XMLUnit.getIgnoreWhitespace();
   XMLUnit.setIgnoreWhitespace(true);
   try {
     assertXMLIdentical("NSStack invalidated XML canonicalization", new Diff(msg, xml), true);
   } finally {
     XMLUnit.setIgnoreWhitespace(oldIgnore);
   }
 }
示例#29
0
 public void setUp() throws Exception {
   XMLUnit.setIgnoreWhitespace(true);
   final Document assertionDoc =
       DocumentUtil.getDocument(getClass().getResourceAsStream("/wstrust/assertion.xml"));
   assertionElement = (Element) assertionDoc.getFirstChild();
   expectedAssertion =
       new InputSource(getClass().getResourceAsStream("/wstrust/assertion-expected.xml"));
 }
 @After
 public void tearDown() throws Exception {
   apim.purgeObject("demo:777", "", false);
   apim.purgeObject("demo:888", "", false);
   apim.purgeObject("demo:777m", "", false);
   apim.purgeObject("demo:888m", "", false);
   XMLUnit.setXpathNamespaceContext(SimpleNamespaceContext.EMPTY_CONTEXT);
 }