# HG changeset patch # User ymh # Date 1269366318 -3600 # Node ID 52964a651638edba514407b1690d173553f39d64 # Parent 4a089c49eb448915a71d4bbe97937c7acb6ee950 debug tests diff -r 4a089c49eb44 -r 52964a651638 src/fr/iri/thd/sonyengine/test/TestEngine.java --- a/src/fr/iri/thd/sonyengine/test/TestEngine.java Tue Mar 23 12:31:57 2010 +0100 +++ b/src/fr/iri/thd/sonyengine/test/TestEngine.java Tue Mar 23 18:45:18 2010 +0100 @@ -9,9 +9,9 @@ import org.junit.Before; import org.junit.Test; +import com.sleepycat.persist.EntityCursor; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer; import fr.iri.thd.sonyengine.core.DataAccessor; import fr.iri.thd.sonyengine.core.DbEnv; @@ -187,7 +187,7 @@ public class TestEngine { public static final String BASE_URL = "http://localhost:8080/mosatags.sonyengine/"; - public static final String DATABASE_PATH = "c:/tmp/db"; + public static final String DATABASE_PATH = "/Users/ymh/dev/tmp/db"; private DbEnv dbenv = null; @@ -195,7 +195,10 @@ @Before public void setup() { - File databasePathFile = new File(DATABASE_PATH); + String databasepath = System.getProperty("database_path"); + if(databasepath == null) + databasepath = DATABASE_PATH; + File databasePathFile = new File(databasepath); dbenv = new DbEnv(); dbenv.setup(databasePathFile, true); } @@ -209,15 +212,26 @@ public void testCreateMovieFragment() { DataAccessor da = new DataAccessor(this.dbenv.getEntityStore()); - + + String movieName = "movie" + System.currentTimeMillis(); + Client c = Client.create(); - WebResource res = c.resource(BASE_URL + "segment/create/movie1"); + WebResource res = c.resource(BASE_URL + "segment/create/" + movieName); String response = res.accept(MediaType.TEXT_PLAIN_TYPE).post(String.class); Assert.assertNotNull(response); - Assert.assertTrue(da.movieFragmentById.contains("movie1")); + EntityCursor cursor = da.movieFragmentById.keys(); + + for (String key : cursor) { + Assert.assertNotNull(key); + } + + cursor.close(); + + Assert.assertTrue(da.movieFragmentById.contains(movieName)); + } diff -r 4a089c49eb44 -r 52964a651638 src/fr/iri/thd/sonyengine/web/EngineResource.java --- a/src/fr/iri/thd/sonyengine/web/EngineResource.java Tue Mar 23 12:31:57 2010 +0100 +++ b/src/fr/iri/thd/sonyengine/web/EngineResource.java Tue Mar 23 18:45:18 2010 +0100 @@ -120,6 +120,8 @@ trans.commit(); + dbenv.getEntityStore().sync(); + return "ok"; } diff -r 4a089c49eb44 -r 52964a651638 src/fr/iri/thd/sonyengine/web/MovieFragmentResource.java --- a/src/fr/iri/thd/sonyengine/web/MovieFragmentResource.java Tue Mar 23 12:31:57 2010 +0100 +++ b/src/fr/iri/thd/sonyengine/web/MovieFragmentResource.java Tue Mar 23 18:45:18 2010 +0100 @@ -27,6 +27,8 @@ MovieFragment fragment = new MovieFragment(id); da.movieFragmentById.put(fragment); + dbenv.getEntityStore().sync(); + ThdEngine.getEngine().reTrain(); diff -r 4a089c49eb44 -r 52964a651638 src/fr/iri/thd/sonyengine/web/TagResource.java --- a/src/fr/iri/thd/sonyengine/web/TagResource.java Tue Mar 23 12:31:57 2010 +0100 +++ b/src/fr/iri/thd/sonyengine/web/TagResource.java Tue Mar 23 18:45:18 2010 +0100 @@ -40,6 +40,8 @@ Tag tag = new Tag(tagName, movieSegmentRef); da.tagById.put(tag); + dbenv.getEntityStore().sync(); + ThdEngine.getEngine().reTrain(); @@ -78,6 +80,8 @@ da.tagById.put(tag); } + dbenv.getEntityStore().sync(); + ThdEngine.getEngine().reTrain(); return "ok";