Package org.custommonkey.xmlunit

Examples of org.custommonkey.xmlunit.XpathEngine


    @Test
    public void testGet() throws Exception {
        Document doc = getAsDOM("wfs?service=WFS&version=1.0.0&request=getCapabilities");
        assertEquals("WFS_Capabilities", doc.getDocumentElement()
                .getNodeName());
        XpathEngine xpath =  XMLUnit.newXpathEngine();
        assertTrue(xpath.getMatchingNodes("//wfs:FeatureType", doc).getLength() > 0);
    }
View Full Code Here


    public void testNamespaceFilter() throws Exception {
        // filter on an existing namespace
        Document doc = getAsDOM("wfs?service=WFS&version=1.0.0&request=getCapabilities&namespace=sf");
        Element e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());
        XpathEngine xpath =  XMLUnit.newXpathEngine();
        assertTrue(xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[starts-with(., sf)]", doc).getLength() > 0);
        assertEquals(0, xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[not(starts-with(., sf))]", doc).getLength());
       
        // try again with a missing one
        doc = getAsDOM("wfs?service=WFS&version=1.0.0&request=getCapabilities&namespace=NotThere");
        e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());
        assertEquals(0, xpath.getMatchingNodes("//wfs:FeatureType", doc).getLength());
    }
View Full Code Here

        // filter on an existing namespace
        Document doc = getAsDOM("wfs?service=WFS&version=1.0.0&request=getCapabilities");
        Element e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());

        XpathEngine xpath = XMLUnit.newXpathEngine();

        final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes();
        for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext();) {
            FeatureTypeInfo ft = it.next();
            if (!ft.enabled()) {
                it.remove();
            }
        }
        final int enabledCount = enabledTypes.size();

        assertEquals(enabledCount, xpath.getMatchingNodes(
                "/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType", doc).getLength());
    }
View Full Code Here

        Document doc = getAsDOM("sf/wfs?service=WFS&version=1.0.0&request=getCapabilities");
       
        Element e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());
       
        XpathEngine xpath =  XMLUnit.newXpathEngine();
        assertTrue(xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[starts-with(., sf)]", doc).getLength() > 0);
        assertEquals(0, xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[not(starts-with(., sf))]", doc).getLength());

        assertEquals(6, xpath.getMatchingNodes("//wfs:Get[contains(@onlineResource,'sf/wfs')]", doc).getLength());
        assertEquals(6, xpath.getMatchingNodes("//wfs:Post[contains(@onlineResource,'sf/wfs')]", doc).getLength());
       
        //TODO: test with a non existing workspace
    }
View Full Code Here

        Document doc = getAsDOM("sf/PrimitiveGeoFeature/wfs?service=WFS&version=1.0.0&request=getCapabilities");
       
        Element e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());
       
        XpathEngine xpath =  XMLUnit.newXpathEngine();
        assertEquals(1, xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[starts-with(., sf)]", doc).getLength());
        assertEquals(0, xpath.getMatchingNodes("//wfs:FeatureType/wfs:Name[not(starts-with(., sf))]", doc).getLength());

        assertEquals(6, xpath.getMatchingNodes("//wfs:Get[contains(@onlineResource,'sf/PrimitiveGeoFeature/wfs')]", doc).getLength());
        assertEquals(6, xpath.getMatchingNodes("//wfs:Post[contains(@onlineResource,'sf/PrimitiveGeoFeature/wfs')]", doc).getLength());
       
        //TODO: test with a non existing workspace
    }
View Full Code Here

     */
    @Test
    public void testNoBBOXInHREF() throws Exception {
        final String layerName = MockData.BASIC_POLYGONS.getPrefix() + ":"
                + 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());
    }
View Full Code Here

     *
     * @see http://jira.codehaus.org/browse/GEOS-2185
     */
    @Test
    public void testBBOXInHREF() throws Exception {
        final XpathEngine xpath = XMLUnit.newXpathEngine();
        String requestURL = "wms/kml?layers=" + getLayerId(MockData.BASIC_POLYGONS)
                + "&bbox=-1,-1,-0.5,-0.5&mode=download";
       
        Document dom = getAsDOM(requestURL);
        // print(dom);
       
        assertEquals(1, xpath.getMatchingNodes("//kml:Placemark", dom).getLength());
    }
View Full Code Here

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

        XpathEngine xpath = XMLUnit.newXpathEngine();

        String url1 = xpath.evaluate(
                "/kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:href", dom);
        String url2 = xpath.evaluate(
                "/kml:kml/kml:Document/kml:NetworkLink[2]/kml:Url/kml:href", dom);

        assertNotNull(url1);
        assertNotNull(url2);
View Full Code Here

        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"));
View Full Code Here

        // 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"));
       
View Full Code Here

TOP

Related Classes of org.custommonkey.xmlunit.XpathEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.