Browse files

updated getrecords tests for geocat

  • Loading branch information...
1 parent 3209da1 commit 806da96b320f965fc816d55f7ab0bb1c2d945a84 @jesseeichar jesseeichar committed Jul 2, 2012
View
10 geonetwork/geocat/src/test/scala/c2c/webspecs/geonetwork/geocat/OutputSchemas.scala
@@ -0,0 +1,10 @@
+package c2c.webspecs.geonetwork
+package geocat
+import csw.OutputSchemas.OutputSchema
+
+object OutputSchemas {
+ case object CheIsoRecord extends OutputSchema("http://www.geocat.ch/2008/che")
+ case object GM03UrlRecord extends OutputSchema("http://www.isotc211.org/2008/gm03_2")
+ case object GM03_2Record extends OutputSchema("GM03_2Record")
+ case object OwnRecord extends OutputSchema("own")
+}
View
4 ...geocat/src/test/scala/c2c/webspecs/geonetwork/geocat/spec/WP1/ImportCheMetadataSpec.scala
@@ -50,15 +50,15 @@ println(metadataXml)
def cswGetInsertedMd = {
val fileId = (metadataXml \\ "fileIdentifier" text).trim()
- val response = CswGetRecordById(fileId, OutputSchemas.CheIsoRecord).execute()
+ val response = CswGetRecordById(fileId, geocat.OutputSchemas.CheIsoRecord).execute()
(response must haveA200ResponseCode) and
(response.value.getXml \\ "CHE_MD_Metadata" must not beEmpty)
}
def cswGetInsertedMdByCswGetRecords = {
val fileId = (metadataXml \\ "fileIdentifier" text).trim()
val filter = PropertyIsEqualTo("Identifier", fileId).xml
- val response = CswGetRecordsRequest(filter, outputSchema = OutputSchemas.CheIsoRecord, resultType = ResultTypes.results).execute()
+ val response = CswGetRecordsRequest(filter, outputSchema = geocat.OutputSchemas.CheIsoRecord, resultType = ResultTypes.results).execute()
val xml = response.value.getXml
(response must haveA200ResponseCode) and
((xml \\ "SearchResults" \@ "numberOfRecordsReturned").head.trim.toInt must be_>=(1)) and
View
83 ...k/geocat/src/test/scala/c2c/webspecs/geonetwork/geocat/spec/WP6/CswOutputSchemaSpec.scala
@@ -12,64 +12,45 @@ import scala.xml.NodeSeq
import OutputSchemas._
import c2c.webspecs.geonetwork.csw.CswGetCapabilities
import c2c.webspecs.GetRequest
+import org.specs2.execute.Result
+@RunWith(classOf[JUnitRunner])
+class CswOutputSchemaSpec extends geonetwork.spec.csw.CswOutputSchemaSpec {
-@RunWith(classOf[JUnitRunner])
-class CswOutputSchemaSpec extends GeocatSpecification(UserProfiles.Editor) { def is =
- "CSW output schemas".title ^ Step(setup) ^
- "This specification tests the usage of different output schemas through CSW" ^
- "Test the CSW server via GetCapabilities request" ^ testGetCapabilities.toGiven ^
- "must have ${http://www.opengis.net/cat/csw/2.0.2} as an outputSchema" ^ outputSchema.toThen ^
- "must have ${http://www.isotc211.org/2005/gmd} as an outputSchema" ^ outputSchema.toThen ^
- "must have ${http://www.geocat.ch/2008/che} as an outputSchema" ^ outputSchema.toThen ^
- "must have ${http://www.isotc211.org/2008/gm03_2} as an outputSchema" ^ outputSchema.toThen ^
- endp ^
- "Import a metadata" ^ Step(importMetadataId) ^
- "Getting the metadata previously inserted in dublin-core output" ! testDublinCore ^
- "Getting the metadata previously inserted in iso19139 output" ! testiso19139 ^
- "Getting the metadata previously inserted in iso19139.che output" ! testiso19139che ^
-// "Getting the metadata previously inserted in GM03 output" ! testGM03 ^
-// "Getting the metadata previously inserted in its own format" ! testDublinCore ^
- "Delete the inserted metadata" ^ Step(deleteMetadata) ^
- end ^ Step(tearDown)
-
-
- val testGetCapabilities = () => CswGetCapabilities().execute().value.getXml
-
- val outputSchema = (capabilities : NodeSeq, descriptor : String) => {
- val schema = extract1(descriptor)
- val getRecordsOperations = capabilities \\ "Operation" filter { _ @@ "name" == List("GetRecords") }
- val getOutputSchemas = (getRecordsOperations \\ "Parameter" filter { _ @@ "name" == List("outputSchema") }) \\ "Value"
+ override def testCapabilitliesHasCustomOutputSchema =
+ "must have ${http://www.isotc211.org/2008/gm03_2} as an outputSchema" ! outputSchema ^
+ "must have ${GM03_2Record} as an outputSchema" ! outputSchema ^
+ "must have ${own} as an outputSchema" ! outputSchema
- getOutputSchemas.map{_.text} must contain(schema)
- }
- def testDublinCore = {
- // how to get the fileId of the inserted MD ?
- val getRecordResult = CswGetRecordById(importMetadataId, new OutputSchema("http://www.opengis.net/cat/csw/2.0.2"){}).execute()
- (getRecordResult.value.getXml \\ "title").head.prefix must_== "dc"
- }
- def testiso19139 = {
- val getRecordResult = CswGetRecordById(importMetadataId, new OutputSchema("http://www.isotc211.org/2005/gmd"){}).execute()
- (getRecordResult.value.getXml \\ "MD_Metadata").head.prefix must_== "gmd"
+ override def testCustomOutputSchemas =
+ "Getting the metadata previously inserted in iso19139.che output" ! testiso19139che ^
+ "Getting the metadata previously inserted in its own format" ! testOwn ^
+ "Getting the metadata previously inserted in http://www.isotc211.org/2008/gm03_2 output" ! testGM03Url ^
+ "Getting the metadata previously inserted in GM03_2Record output" ! testGM03_2
- }
def testiso19139che = {
- val getRecordResult = CswGetRecordById(importMetadataId, OutputSchemas.CheIsoRecord).execute()
- (getRecordResult.value.getXml \\ "CHE_MD_Metadata").head.prefix must_== "che"
+ val getRecordResult = CswGetRecordById(importMetadataId, geocat.OutputSchemas.CheIsoRecord).execute()
+ (getRecordResult.value.getXml \\ "CHE_MD_Metadata").head.prefix must_== "che"
+ }
+ def testOwn = {
+ val getRecordResult = CswGetRecordById(importMetadataId, geocat.OutputSchemas.OwnRecord).execute()
+ (getRecordResult.value.getXml \\ "CHE_MD_Metadata") must not beEmpty
}
- def testGM03 = {
- val getRecordResult = CswGetRecordById(importMetadataId, OutputSchemas.GM03Record).execute()
- (getRecordResult.value.getXml \\ "GM03_2Comprehensive.Comprehensive") must not beEmpty
+ def testGM03Url = {
+ val getRecordResult = CswGetRecordById(importMetadataId, geocat.OutputSchemas.GM03UrlRecord).execute()
+ (getRecordResult.value.getXml \\ "GM03_2Comprehensive.Comprehensive") must not beEmpty
+ }
+ def testGM03_2 = {
+ val getRecordResult = CswGetRecordById(importMetadataId, geocat.OutputSchemas.GM03_2Record).execute()
+ (getRecordResult.value.getXml \\ "GM03_2Comprehensive.Comprehensive") must not beEmpty
}
- lazy val importMetadataId = {
- val (_,importMd) = ImportMetadata.defaults(uuid, "/geocat/data/metadata.iso19139.che.xml",false, getClass)
-
- val md = (importMd then GetRawMetadataXml).execute(ImportStyleSheets.NONE).value.getXml
- val response = (md \\ "fileIdentifier").text.trim
- response
+ override lazy val importMetadataId = {
+ val mdId = importMd(1, "/geocat/data/metadata.iso19139.che.xml", uuid.toString).head
+
+ val md = GetRawMetadataXml.execute(mdId).value.getXml
+ val fileId = (md \\ "fileIdentifier").text.trim
+ fileId
}
- def deleteMetadata = {
- GetRequest("metadata.delete", ("uuid" -> importMetadataId)).execute()
- }
+
}
View
2 geonetwork/standard/src/test/scala/c2c/webspecs/geonetwork/csw/OutputSchemas.scala
@@ -9,8 +9,6 @@ object OutputSchemas {
case object Record extends OutputSchema("csw:Record")
case object IsoRecord extends OutputSchema("csw:IsoRecord")
case object GmdNamespace extends OutputSchema("http://www.isotc211.org/2005/gmd")
- case object CheIsoRecord extends OutputSchema("http://www.geocat.ch/2008/che")
- case object GM03Record extends OutputSchema("http://www.isotc211.org/2008/gm03_2")
val DublinCore = Record
}
View
13 ...etwork/standard/src/test/scala/c2c/webspecs/geonetwork/spec/csw/CswOutputSchemaSpec.scala
@@ -9,6 +9,10 @@ import org.specs2.runner.JUnitRunner
import csw._
import OutputSchemas._
import c2c.webspecs.geonetwork.csw.CswGetCapabilities
+import org.specs2.matcher.MatchResult
+import org.specs2.execute.Result
+import org.specs2.specification.Fragment
+import org.specs2.specification.Fragments
@RunWith(classOf[JUnitRunner])
@@ -17,11 +21,12 @@ class CswOutputSchemaSpec extends GeonetworkSpecification {
"CSW output schemas".title ^ Step(setup) ^
"This specification tests the usage of different output schemas through CSW" ^
"must have ${http://www.opengis.net/cat/csw/2.0.2} as an outputSchema" ! outputSchema ^
- "must have ${http://www.isotc211.org/2005/gmd} as an outputSchema" ! outputSchema ^
+ "must have ${http://www.isotc211.org/2005/gmd} as an outputSchema" ! outputSchema ^
+ testCapabilitliesHasCustomOutputSchema ^ p ^
"Import a metadata" ^ Step(importMetadataId) ^
"Getting the metadata previously inserted in dublin-core output" ! testDublinCore ^
"Getting the metadata previously inserted in iso19139 output" ! testiso19139 ^
- // "Getting the metadata previously inserted in its own format" ! testDublinCore ^
+ testCustomOutputSchemas ^
end ^ Step(tearDown)
@@ -41,6 +46,8 @@ class CswOutputSchemaSpec extends GeonetworkSpecification {
} must contain(schema)
}
+ def testCapabilitliesHasCustomOutputSchema:Fragments = success
+
def testDublinCore = {
// how to get the fileId of the inserted MD ?
val getRecordResult = CswGetRecordById(importMetadataId, new OutputSchema("http://www.opengis.net/cat/csw/2.0.2") {}).execute()
@@ -53,6 +60,8 @@ class CswOutputSchemaSpec extends GeonetworkSpecification {
}
+ def testCustomOutputSchemas:Fragments = success
+
lazy val importMetadataId = {
val mdId = importMd(1, "/geonetwork/data/valid-metadata.iso19139.xml", uuid.toString).head

0 comments on commit 806da96

Please sign in to comment.