commit after merge from trunc
[cdmlib.git] / cdmlib-ext / src / test / java / eu / etaxonomy / cdm / ext / geo / EditGeoServiceTest.java
index 9b4515f9d4f9b1f02d8922c2ca7424cb0fed6d5e..8901bbbb06ea57a6159670f8b7d2d04464242837 100644 (file)
@@ -30,8 +30,6 @@ import java.util.UUID;
 \r
 import org.apache.http.client.ClientProtocolException;\r
 import org.apache.log4j.Logger;\r
-import org.junit.After;\r
-import org.junit.AfterClass;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.unitils.spring.annotation.SpringBeanByType;\r
@@ -61,12 +59,12 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
     @SuppressWarnings("unused")\r
     private static final Logger logger = Logger.getLogger(EditGeoServiceTest.class);\r
 \r
-    private static final String EDIT_MAPSERVICE_URI_STING = "http://edit.br.fgov.be/edit_wp5/v1/areas.php";\r
+    private static final String EDIT_MAPSERVICE_URI_STING = "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php";\r
     private static URI editMapServiceUri;\r
 \r
     //@SpringBeanByType\r
     private IDefinedTermDao termDao;\r
-    \r
+\r
     @SpringBeanByType\r
     private ITermService termService;\r
 \r
@@ -120,14 +118,15 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
         //TODO Set semantics is not determined\r
         //String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";\r
         System.out.println(result);\r
-        assertTrue(result.matches(".*l=earth.*"));\r
+//        assertTrue(result.matches(".*l=earth.*"));\r
         assertTrue(result.matches(".*ms=600,300.*"));\r
         assertTrue(result.matches(".*ad=tdwg[1-4].*"));\r
         assertTrue(result.matches(".*tdwg2:[a-d]:14[\\|&].*") );\r
         assertTrue(result.matches(".*[a-d]:FRA,BGM[\\|&].*") || result.matches(".*[a-d]:BGM,FRA[\\|&].*") );\r
         assertTrue(result.matches(".*[a-d]:GER[\\|&].*") );\r
         assertTrue(result.matches(".*[a-d]:SPA[\\|&].*") );\r
-        assertTrue(result.matches(".*tdwg4:[a-d]:INDAP[\\|&].*") );\r
+//        assertTrue(result.matches(".*tdwg4:[a-d]:INDAP[\\|&].*") );\r
+        assertTrue(result.matches(".*tdwg4:[a-h]:INDAP[\\|&].*") );\r
         //assertTrue(result.matches("0000ff"));\r
         //TODO continue\r
 \r
@@ -159,7 +158,7 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
         String result = EditGeoServiceUtilities.getDistributionServiceRequestParameterString(distributions, mapping, presenceAbsenceColorMap, 600, 300, bbox,backLayer, null, languages );\r
         //TODO Set semantics is not determined\r
         //String expected = "http://www.test.de/webservice?l=tdwg3&ad=tdwg3:a:GER|b:OKL|c:BGM|b:SPA|d:FRA&as=a:005500|b:00FF00|c:FFFFFF|d:001100&bbox=-20,40,40,40&ms=400x300";\r
-        assertTrue(result.matches(".*l=earth.*"));\r
+//        assertTrue(result.matches(".*l=earth.*"));\r
         assertTrue(result.matches(".*ms=600,300.*"));\r
         assertTrue(result.matches(".*ad=cyprusdivs%3Abdcode:.*"));\r
         assertTrue(result.matches(".*[a-d]:5,4[\\|&].*") || result.matches(".*[a-d]:4,5[\\|&].*") );\r
@@ -174,12 +173,13 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
     private void subTestWithEditMapService(String result)throws MalformedURLException, IOException {\r
         if(UriUtils.isServiceAvailable(editMapServiceUri)){\r
             URL requestUrl = new URL(editMapServiceUri.toString() + "?img=false&" + result);\r
+            logger.debug("editMapServiceUri: " + requestUrl);\r
             HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();\r
             connection.connect();\r
             assertTrue(connection.getResponseCode() == 200);\r
             InputStream contentStream = connection.getInputStream();\r
             String content = StreamUtils.readToString(contentStream);\r
-            System.out.println(content);\r
+            logger.debug("EditMapService response body:\n" + content);\r
             assertTrue(content.startsWith("[{"));\r
             assertTrue(content.endsWith("}]"));\r
             assertTrue(content.matches(".*\"bbox\":.*"));\r
@@ -191,7 +191,7 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
     }\r
 \r
     public static final UUID uuidCyprusDivisionsVocabulary = UUID.fromString("2119f610-1f93-4d87-af28-40aeefaca100");\r
-    private Map<String, NamedArea> divisions = new HashMap<String, NamedArea>();\r
+    private final Map<String, NamedArea> divisions = new HashMap<String, NamedArea>();\r
 \r
     private boolean makeCyprusAreas() {\r
         //divisions\r
@@ -205,7 +205,7 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
 \r
         for(int i = 1; i <= 8; i++){\r
             UUID divisionUuid = getNamedAreaUuid(String.valueOf(i));\r
-            NamedArea division = this.getNamedArea(divisionUuid, "Division " + i, "Cyprus: Division " + i, String.valueOf(i), areaType, areaLevel, areaVocabulary);\r
+            NamedArea division = this.newNamedArea(divisionUuid, "Division " + i, "Cyprus: Division " + i, String.valueOf(i), areaType, areaLevel, areaVocabulary);\r
             divisions.put(String.valueOf(i), division);\r
         }\r
 \r
@@ -245,12 +245,13 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
         }\r
     }\r
 \r
-    protected NamedArea getNamedArea(UUID uuid, String label, String text, String labelAbbrev, NamedAreaType areaType, NamedAreaLevel level, TermVocabulary voc){\r
-        NamedArea namedArea = NamedArea.NewInstance(text, label, labelAbbrev);\r
+    protected NamedArea newNamedArea(UUID uuid, String label, String text, String IdInVocabulary, NamedAreaType areaType, NamedAreaLevel level, TermVocabulary voc){\r
+        NamedArea namedArea = NamedArea.NewInstance(text, label, null);\r
         voc.addTerm(namedArea);\r
         namedArea.setType(areaType);\r
         namedArea.setLevel(level);\r
         namedArea.setUuid(uuid);\r
+        namedArea.setIdInVocabulary(IdInVocabulary);\r
         return namedArea;\r
     }\r
 \r
@@ -285,7 +286,7 @@ public class EditGeoServiceTest extends CdmIntegrationTest {
 \r
         System.out.println(result);\r
 \r
-        assertTrue(result.matches(".*l=earth.*"));\r
+//        assertTrue(result.matches(".*l=earth.*"));\r
         assertTrue(result.matches(".*ms=600,300.*"));\r
         assertTrue(result.matches(".*ad=vmap0_as_bnd_political_boundary_a%3Anam:.*"));\r
         assertTrue(result.matches(".*(PULAU\\+BANGKA%23SUMATERA\\+SELATAN).*") );\r