modify test
authorIRI
Wed, 24 Mar 2010 12:41:26 +0100
changeset 6 3a1bcc02b5a6
parent 5 4aea9df5515d
child 7 41b17723d6c8
modify test
src/fr/iri/thd/sonyengine/test/TestEngine.java
--- a/src/fr/iri/thd/sonyengine/test/TestEngine.java	Wed Mar 24 06:44:35 2010 +0100
+++ b/src/fr/iri/thd/sonyengine/test/TestEngine.java	Wed Mar 24 12:41:26 2010 +0100
@@ -197,11 +197,12 @@
 
 public class TestEngine {
 
-	public static final String BASE_URL = "http://localhost:8080/mosatags.sonyengine/";
+	public static final String BASE_URL = "http://localhost:9080/sonyengine/";
 	public static final String DATABASE_PATH = "/Users/ymh/dev/tmp/db";
 
 	private DbEnv dbenv = null;
 	private File databasePathFile = null;
+	private String baseurl = null;
 			
 	@Before
 	public void setup()
@@ -210,6 +211,10 @@
 		if(databasepath == null)
 			databasepath = DATABASE_PATH;
 		databasePathFile = new File(databasepath);
+		
+		this.baseurl = System.getProperty("baseurl");
+		if(this.baseurl == null)
+			this.baseurl = BASE_URL;
 	}
 	
 	@After
@@ -225,7 +230,7 @@
 		String movieName = "movie" + System.currentTimeMillis();
 		
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL + "segment/create/" + movieName);
+		WebResource res = c.resource(this.baseurl + "segment/create/" + movieName);
 		
 		String response = res.accept(MediaType.APPLICATION_XML_TYPE).post(String.class);
 				
@@ -260,7 +265,7 @@
 		Form form = new Form();
 		form.add("id", movieName);
 		
-		WebResource res = c.resource(BASE_URL + "segment/create");		
+		WebResource res = c.resource(this.baseurl + "segment/create");		
 
 		String response = res.type(MediaType.APPLICATION_FORM_URLENCODED).post(String.class, form);
 				
@@ -292,12 +297,12 @@
 		String tagName = "tag" + System.currentTimeMillis();;
 		
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL + "segment/create/" + movieName);
+		WebResource res = c.resource(this.baseurl + "segment/create/" + movieName);
 		String response = res.accept(MediaType.APPLICATION_JSON_TYPE).post(String.class);
 				
 		Assert.assertNotNull(response);
 		
-		res = c.resource(BASE_URL).path("tag").path("add").path(tagName).path(movieName);
+		res = c.resource(this.baseurl).path("tag").path("add").path(tagName).path(movieName);
 		response = res.accept(MediaType.APPLICATION_JSON_TYPE).post(String.class);
 
 		Assert.assertNotNull(response);
@@ -328,7 +333,7 @@
 		}
 		
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL + "segment/create/" + movieName);
+		WebResource res = c.resource(this.baseurl + "segment/create/" + movieName);
 		String response = res.accept(MediaType.APPLICATION_XML_TYPE).post(String.class);
 				
 		Assert.assertNotNull(response);
@@ -339,7 +344,7 @@
 		}
 		xml += "</tags>";
 		
-		res = c.resource(BASE_URL).path("tag").path("add");
+		res = c.resource(this.baseurl).path("tag").path("add");
 		Form form = new Form();
 		form.add("xml", xml);
 		response = res.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE).post(String.class, form);
@@ -378,7 +383,7 @@
 		xml += "</segments>";
 		
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL).path("segment").path("createall");
+		WebResource res = c.resource(this.baseurl).path("segment").path("createall");
 		Form form = new Form();
 		form.add("xml", xml);
 		String response = res.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE).post(String.class, form);
@@ -400,7 +405,7 @@
 	@Test
 	public void testReset() {
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL);
+		WebResource res = c.resource(this.baseurl);
 		String response = res.path("engine").path("reset").accept(MediaType.TEXT_PLAIN).post(String.class);
 		
 		Assert.assertEquals(response, "ok");
@@ -421,7 +426,7 @@
 	public void testTrain() {
 
 		Client c = Client.create();
-		WebResource res = c.resource(BASE_URL);
+		WebResource res = c.resource(this.baseurl);
 		String response = res.path("engine").path("reset").accept(MediaType.TEXT_PLAIN).post(String.class);
 		
 		String[] ids = new String[]{"ref1","ref2","ref3","ref4","ref5","ref6", "ref7"};
@@ -433,7 +438,7 @@
 		xmlSegment += "</segments>";
 
 		c = Client.create();
-		res = c.resource(BASE_URL).path("segment").path("createall");
+		res = c.resource(this.baseurl).path("segment").path("createall");
 		Form form = new Form();
 		form.add("xml", xmlSegment);
 		response = res.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE).post(String.class, form);
@@ -506,7 +511,7 @@
 		}
 		xmlTags += "</tags>";
 
-		res = c.resource(BASE_URL).path("tag").path("add");
+		res = c.resource(this.baseurl).path("tag").path("add");
 		form = new Form();
 		form.add("xml", xmlTags);
 		response = res.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE).post(String.class, form);
@@ -515,7 +520,7 @@
 
 		//"engine/find/{segment}/{tag}/{percent}/{more}"
 		//Neighbor neighbor = engine.findMore("ref1", "enfant", .05f, true);
-		res = c.resource(BASE_URL).path("engine").path("find").path("ref1").path("enfant").path("0.05").path("true");
+		res = c.resource(this.baseurl).path("engine").path("find").path("ref1").path("enfant").path("0.05").path("true");
 		response = res.accept(MediaType.APPLICATION_XML_TYPE).get(String.class);
 		Assert.assertNotNull(response);