Refine search
@Test public void testWmsStorePasswordEncryption() throws Exception { WMSStoreInfo wms = buildWmsStore(); ByteArrayOutputStream out = new ByteArrayOutputStream(); persister.save(wms, out); Document dom = dom(new ByteArrayInputStream(out.toByteArray())); // print(dom); // check password has been encrypted XMLAssert.assertXpathExists("/wmsStore/password", dom); XMLAssert.assertXpathNotExists("/wmsStore[password = 'password']", dom); XMLAssert.assertXpathExists("/wmsStore[starts-with(password, 'crypt1:')]", dom); WMSStoreInfo loaded = persister.load(new ByteArrayInputStream(out.toByteArray()), WMSStoreInfo.class); assertEquals("password", loaded.getPassword()); }
@Test public void readSettingsMetadataInvalidEntry() throws Exception { String xml = XMLAssert.assertXpathExists("//settings/metadata/map", doc); XMLAssert.assertXpathEvaluatesTo("2", "count(//settings/metadata/map/entry)", doc); XMLAssert.assertXpathEvaluatesTo("key1", "//settings/metadata/map/entry[1]/string[1]", doc); XMLAssert.assertXpathEvaluatesTo( "value1", "//settings/metadata/map/entry[1]/string[2]", doc); XMLAssert.assertXpathEvaluatesTo("key2", "//settings/metadata/map/entry[2]/string[1]", doc);
void assertSchema(Document doc, QName... types) throws Exception { assertEquals("xsd:schema", doc.getDocumentElement().getNodeName()); XMLAssert.assertXpathExists("//xsd:import[@namespace='" + GML.NAMESPACE + "']", doc); for (QName type : types) { String eName = type.getLocalPart(); String tName = eName + "Type"; XMLAssert.assertXpathEvaluatesTo( "1", "count(//xsd:complexType[@name='" + tName + "'])", doc); XMLAssert.assertXpathEvaluatesTo( "1", "count(//xsd:element[@name='" + eName + "'])", doc); } }
@Test public void testModifyDataStore() throws Exception { testAddDataStore(); DataStoreInfo ds = catalog.getDataStoreByName("acme", "foostore"); assertTrue(ds.getConnectionParameters().isEmpty()); ds.getConnectionParameters().put("foo", "bar"); catalog.save(ds); File f = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore/datastore.xml"); Document dom = dom(f); assertXpathExists("/dataStore/connectionParameters/entry[@key='foo']", dom); }
@Test public void testGetObjectXML() throws Exception { // test getting xml for object demo:5 System.out.println("Running TestAPIM.testGetObjectXML..."); byte[] objectXML = TypeUtility.convertDataHandlerToBytes(apim .getObjectXML("demo:5")); assertTrue(objectXML.length > 0); String xmlIn = new String(objectXML, "UTF-8"); //System.out.println("***** Testcase: TestAPIM.testGetObjectXML demo:5\n"+xmlIn); assertXpathExists("foxml:digitalObject[@PID='demo:5']", xmlIn); assertXpathExists("//foxml:objectProperties/foxml:property[@NAME='info:fedora/fedora-system:def/model#state' and @VALUE='Active']", xmlIn); assertXpathExists("//foxml:objectProperties/foxml:property[@NAME='info:fedora/fedora-system:def/model#label' and @VALUE='Data Object (Coliseum) for Local Simple Image Demo']", xmlIn); assertXpathEvaluatesTo("6", "count(//foxml:datastream[@ID!='AUDIT'])", xmlIn); }
private void assertProgress(String statusLocation, String progress) throws Exception { Document dom = getAsDOM(statusLocation); // print(dom); assertXpathExists("//wps:ProcessStarted", dom); assertXpathEvaluatesTo(progress, "//wps:ProcessStarted/@percentCompleted", dom); }
@Test public void testWmsStoreBackwardsCompatibility() throws Exception { WMSStoreInfo wms = buildWmsStore(); ByteArrayOutputStream out = new ByteArrayOutputStream(); // save with no encryption persister.setEncryptPasswordFields(false); persister.save(wms, out); Document dom = dom(new ByteArrayInputStream(out.toByteArray())); print(dom); // check password has not been encrypted XMLAssert.assertXpathExists("/wmsStore/password", dom); XMLAssert.assertXpathExists("/wmsStore[password = 'password']", dom); // load back with a password encrypting persister, should fall back reading plain text // password persister.setEncryptPasswordFields(true); WMSStoreInfo loaded = persister.load(new ByteArrayInputStream(out.toByteArray()), WMSStoreInfo.class); assertEquals("password", loaded.getPassword()); // just to be thorough test also loading with no password encryption persister.setEncryptPasswordFields(false); WMSStoreInfo loaded2 = persister.load(new ByteArrayInputStream(out.toByteArray()), WMSStoreInfo.class); assertEquals("password", loaded2.getPassword()); }
@Test public void testBasicGetLocalSchemaMetaData() throws Exception { Document dom = getAsDOM("csw?service=CSW&version=2.0.2&request=DescribeRecord&typeName=gmd:MD_Metadata"); checkValidationErrors(dom); //print(dom); assertXpathEvaluatesTo("2", "count(//csw:SchemaComponent)", dom); assertXpathExists("//csw:SchemaComponent/xsd:schema[@targetNamespace='http://www.isotc211.org/2005/gmd']", dom); assertXpathExists("//csw:SchemaComponent/xsd:schema[@targetNamespace='http://www.isotc211.org/2005/srv']", dom); assertXpathExists("//xs:element[@name='AbstractMD_Identification']", dom); assertXpathExists("//xs:element[@name='MD_Keywords']", dom); }
public void testStoredWithStatus() throws Exception { // submit asynch request with no updates String statusLocation = submitMonkey("x3"); // we move the clock forward, but we asked no status, nothing should change MonkeyProcess.progress("x3", 0.1f, true); Document dom = getAsDOM(statusLocation); print(dom); assertXpathExists("//wps:ProcessStarted", dom); assertXpathEvaluatesTo("" + Math.round(0.66 * 10), "//wps:ProcessStarted/@percentCompleted", dom); // we move the clock forward, but we asked no status, nothing should change MonkeyProcess.progress("x3", 0.5f, true); dom = getAsDOM(statusLocation); // print(dom); assertXpathExists("//wps:ProcessStarted", dom); assertXpathEvaluatesTo("" + Math.round(0.66 * 50), "//wps:ProcessStarted/@percentCompleted", dom); // now schedule the exit and wait for it to exit MonkeyProcess.exit("x3", collectionOfThings(), true); dom = waitForProcessEnd(statusLocation, 60); // print(dom); assertXpathExists("//wps:ProcessSucceeded", dom); }
@Test public void testObjectHistory() throws Exception { Document result; result = getXMLQueryResult(s_client, "/getObjectHistory/demo:5?xml=true"); assertXpathExists(String.format("/%s:fedoraObjectHistory/%s:objectChangeDate", ACCESS.prefix, ACCESS.prefix), result); }
@Test public void testSpatialJoinGET() throws Exception { Document dom = getAsDOM( "wfs?service=WFS&version=2.0.0&request=getFeature&typenames=gs:Forests,gs:Lakes&aliases=a,b&filter=%3CFilter%3E%3CIntersects%3E%3CValueReference%3Ea%2Fthe_geom%3C%2FValueReference%3E%3CValueReference%3Eb%2Fthe_geom%3C%2FValueReference%3E%3C%2FIntersects%3E%3C%2FFilter%3E"); XMLAssert.assertXpathEvaluatesTo("2", "count(//wfs:Tuple)", dom); XMLAssert.assertXpathExists( "//wfs:Tuple[position() = 1]/wfs:member/gs:Forests/gs:NAME[text() = 'Green Forest']", dom); XMLAssert.assertXpathExists( "//wfs:Tuple[position() = 1]/wfs:member/gs:Lakes/gs:NAME[text() = 'Blue Lake']", dom); XMLAssert.assertXpathExists( "wfs:FeatureCollection/wfs:member[position()=2]/wfs:Tuple//gs:Forests/gs:NAME[text() = 'Foo Forest']", dom); XMLAssert.assertXpathExists( "wfs:FeatureCollection/wfs:member[position()=2]/wfs:Tuple//gs:Lakes/gs:NAME[text() = 'Green Lake']", dom); }
public void testProcessFailure() throws Exception { // have the monkey throw an exception MonkeyProcess.exception("x1", new ProcessException("Sorry dude, things went pear shaped..."), false); String request = "wps?service=WPS&version=1.0.0&request=Execute&Identifier=gs:Monkey&DataInputs=" + urlEncode("id=x1"); Document dom = getAsDOM(request); checkValidationErrors(dom); assertXpathExists("//wps:ProcessFailed", dom); assertXpathEvaluatesTo("Process failed during execution\nSorry dude, things went pear shaped...", "//wps:ProcessFailed/ows:ExceptionReport/ows:Exception/ows:ExceptionText", dom); }
@Test public void testDescribeRepository() throws Exception { Document result; result = getXMLQueryResult(s_client, "/describe?xml=true"); assertXpathExists(String.format("/%s:fedoraRepository/%s:repositoryName", ACCESS.prefix, ACCESS.prefix), result); }
@Test public void testTitleFilterCSWRecord() throws Exception { String request = "csw?service=CSW&version=2.0.2&request=GetRecords&typeNames=csw:Record&resultType=results&elementSetName=brief&outputSchema=http://www.isotc211.org/2005/gmd&constraint=dc:title like 'S%25'"; Document d = getAsDOM(request); //print(d); //validateSchema(d.getElementsByTagName("//gmd:MD_MetaData")); assertXpathEvaluatesTo("2", "//csw:SearchResults/@numberOfRecordsMatched", d); assertXpathEvaluatesTo("2", "//csw:SearchResults/@numberOfRecordsReturned", d); assertXpathEvaluatesTo("2", "count(//csw:SearchResults/*)", d); assertXpathExists("//gmd:MD_Metadata[gmd:identificationInfo/gmd:AbstractMD_Identification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString='Streams']", d); assertXpathExists("//gmd:MD_Metadata[gmd:identificationInfo/gmd:AbstractMD_Identification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString='Seven']", d); }
public void testGetLayer() throws Exception { final String layerName = getLayerId(MockData.BASIC_POLYGONS); final String url = "gwc/rest/layers/" + layerName + ".xml"; final String id = getCatalog().getLayerByName(layerName).getId(); MockHttpServletResponse sr = getAsServletResponse(url); assertEquals(200, sr.getErrorCode()); assertTrue(sr.getContentType(), sr.getContentType().startsWith("text/xml")); Document dom = getAsDOM(url); print(dom); assertXpathExists("/GeoServerLayer", dom); assertXpathEvaluatesTo(id, "/GeoServerLayer/id", dom); assertXpathEvaluatesTo(layerName, "/GeoServerLayer/name", dom); assertXpathEvaluatesTo("true", "/GeoServerLayer/enabled", dom); assertXpathEvaluatesTo("image/png", "/GeoServerLayer/mimeFormats/string[1]", dom); assertXpathEvaluatesTo("image/jpeg", "/GeoServerLayer/mimeFormats/string[2]", dom); assertXpathEvaluatesTo("EPSG:900913", "/GeoServerLayer/gridSubsets/gridSubset[1]/gridSetName", dom); }
@Test public void testStyleElementsValidity() throws Exception { Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.1.1", true); assertXpathExists("//Layer[Name='cite:Lakes']/Style[1]/Name", doc); assertXpathExists("//Layer[Name='cite:Lakes']/Style[1]/Title", doc); assertXpathExists("//Layer[Name='cite:Lakes']/Style[1]/LegendURL", doc); assertXpathExists("//Layer[Name='cite:Lakes']/Style[2]/Name", doc); assertXpathExists("//Layer[Name='cite:Lakes']/Style[2]/Title", doc); assertXpathExists("//Layer[Name='cite:Lakes']/Style[2]/LegendURL", doc); }
@Test public void testTitleFilter2() throws Exception { String request = "csw?service=CSW&version=2.0.2&request=GetRecords&typeNames=gmd:MD_Metadata&resultType=results&elementSetName=brief&outputSchema=http://www.isotc211.org/2005/gmd&constraint=Title like 'S%25'"; Document d = getAsDOM(request); //print(d); //validateSchema(d.getElementsByTagName("//gmd:MD_MetaData")); assertXpathEvaluatesTo("2", "//csw:SearchResults/@numberOfRecordsMatched", d); assertXpathEvaluatesTo("2", "//csw:SearchResults/@numberOfRecordsReturned", d); assertXpathEvaluatesTo("2", "count(//csw:SearchResults/*)", d); assertXpathExists("//gmd:MD_Metadata[gmd:identificationInfo/gmd:AbstractMD_Identification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString='Streams']", d); assertXpathExists("//gmd:MD_Metadata[gmd:identificationInfo/gmd:AbstractMD_Identification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString='Seven']", d); }
@Test public void testLayerGroupTitleInCapabilities() throws Exception { Document dom = getAsDOM("wms?request=getcapabilities&version=1.3.0"); assertXpathExists( "//wms:Layer/wms:Title[text() = 'title for layer group base default']", dom); assertXpathExists("//wms:Layer/wms:Title[text() = 'title for layer group sf base']", dom); assertXpathExists("//wms:Layer/wms:Title[text() = 'title for layer group cite base']", dom); }
@Test public void testBasicGetLocalSchemaAll() throws Exception { Document dom = getAsDOM("csw?service=CSW&version=2.0.2&request=DescribeRecord"); checkValidationErrors(dom); //print(dom); assertXpathEvaluatesTo("3", "count(//csw:SchemaComponent)", dom); assertXpathExists("//csw:SchemaComponent/xsd:schema[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2']", dom); assertXpathExists("//csw:SchemaComponent/xsd:schema[@targetNamespace='http://www.isotc211.org/2005/gmd']", dom); assertXpathExists("//csw:SchemaComponent/xsd:schema[@targetNamespace='http://www.isotc211.org/2005/srv']", dom); }
@Test public void testLayerGroupAbstractInCapabilities() throws Exception { Document dom = getAsDOM("wms?request=getcapabilities&version=1.1.1"); assertXpathExists( "//Layer/Abstract[text() = 'abstract for layer group base default']", dom); assertXpathExists("//Layer/Abstract[text() = 'abstract for layer group sf base']", dom); assertXpathExists("//Layer/Abstract[text() = 'abstract for layer group cite base']", dom); }