[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Well, with your location = new File(war/WEB-INF/appengine-generated/ local_db.bin) test setup, running the test does update that local_db.bin. But it's the only data file modified today in the entire project directory. Ideas? On Nov 20, 9:20 am, Starman r...@arrova.ca wrote: In that case, your ds files must be written somewhere else when you run unit tests. On Nov 19, 9:28 pm, Jerry jerry.morri...@gmail.com wrote: Thanks for the hypotheses! I do have datastore-indexes autoGenerate=true in war/WEB-INF/datastore-indexes.xml. I tried not tearing down the helper. Still, the test doesn't touch either of the files WEB-INF/appengine-generated/datastore-indexes-auto.xml war/WEB-INF/appengine-generated/datastore-indexes-auto.xml Any more ideas? Code excerpts: public class DatastoreIndexText { private final LocalServiceTestHelper helper = fileBasedDatastoreTestHelper(); private PersistenceManager pm; @Before public void setUp() throws Exception { helper.setUp(); pm = PMF.get().getPersistenceManager(); ... } @After public void tearDown() throws Exception { try { deleteScheme(schemeId); } finally { pm.close(); // helper.tearDown(); } } private static LocalServiceTestHelper fileBasedDatastoreTestHelper() { File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); // TODO: Read these elements from the File(war/WEB-INF/appengine- web.xml). String appId = ... String appVersionId = 1; LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig() .setBackingStoreLocation(location.getAbsolutePath()) .setNoStorage(false); System.out.println(dsConfig.getBackingStoreLocation()); return new LocalServiceTestHelper( new LocalUserServiceTestConfig(), dsConfig) .setEnvIsAdmin(false) .setEnvIsLoggedIn(true) .setEnvEmail(AUTHOR_EMAIL) .setEnvAuthDomain(AUTH_DOMAIN) .setEnvAppId(appId) .setEnvVersionId(appVersionId); } On Nov 19, 12:58 am, Cyrille Vincey crll...@gmail.com wrote: Check your war WEB-INF datastore-indexes.xml (NOT the war WEB-INF appengine-generated datastore-indexes-auto.xml) You might read: datastore-indexes autoGenerate=false Try to replace with : datastore-indexes autoGenerate=true On 19/11/10 01:39, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Wow. It turns out that this test will erase everything from the local dev server's datastore! Not calling the helper's tearDown() fixes that, but I hadn't checked in that change since the test still doesn't succeed in getting App Engine to update datastore-indexes-auto.xml. Now it no longer calls tearDown(), and it configures the LocalDatastoreServiceTestConfig to use the location WEB-INF/appengine- generated/DatastoreIndexTest_local_db.bin, and the test has @Ignore since it doesn't work anyway. On Nov 22, 1:55 pm, Jerry jerry.morri...@gmail.com wrote: Well, with your location = new File(war/WEB-INF/appengine-generated/ local_db.bin) test setup, running the test does update that local_db.bin. But it's the only data file modified today in the entire project directory. Ideas? On Nov 20, 9:20 am, Starman r...@arrova.ca wrote: In that case, your ds files must be written somewhere else when you run unit tests. On Nov 19, 9:28 pm, Jerry jerry.morri...@gmail.com wrote: Thanks for the hypotheses! I do have datastore-indexes autoGenerate=true in war/WEB-INF/datastore-indexes.xml. I tried not tearing down the helper. Still, the test doesn't touch either of the files WEB-INF/appengine-generated/datastore-indexes-auto.xml war/WEB-INF/appengine-generated/datastore-indexes-auto.xml Any more ideas? Code excerpts: public class DatastoreIndexText { private final LocalServiceTestHelper helper = fileBasedDatastoreTestHelper(); private PersistenceManager pm; @Before public void setUp() throws Exception { helper.setUp(); pm = PMF.get().getPersistenceManager(); ... } @After public void tearDown() throws Exception { try { deleteScheme(schemeId); } finally { pm.close(); // helper.tearDown(); } } private static LocalServiceTestHelper fileBasedDatastoreTestHelper() { File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); // TODO: Read these elements from the File(war/WEB-INF/appengine- web.xml). String appId = ... String appVersionId = 1; LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig() .setBackingStoreLocation(location.getAbsolutePath()) .setNoStorage(false); System.out.println(dsConfig.getBackingStoreLocation()); return new LocalServiceTestHelper( new LocalUserServiceTestConfig(), dsConfig) .setEnvIsAdmin(false) .setEnvIsLoggedIn(true) .setEnvEmail(AUTHOR_EMAIL) .setEnvAuthDomain(AUTH_DOMAIN) .setEnvAppId(appId) .setEnvVersionId(appVersionId); } On Nov 19, 12:58 am, Cyrille Vincey crll...@gmail.com wrote: Check your war WEB-INF datastore-indexes.xml (NOT the war WEB-INF appengine-generated datastore-indexes-auto.xml) You might read: datastore-indexes autoGenerate=false Try to replace with : datastore-indexes autoGenerate=true On 19/11/10 01:39, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
In that case, your ds files must be written somewhere else when you run unit tests. On Nov 19, 9:28 pm, Jerry jerry.morri...@gmail.com wrote: Thanks for the hypotheses! I do have datastore-indexes autoGenerate=true in war/WEB-INF/datastore-indexes.xml. I tried not tearing down the helper. Still, the test doesn't touch either of the files WEB-INF/appengine-generated/datastore-indexes-auto.xml war/WEB-INF/appengine-generated/datastore-indexes-auto.xml Any more ideas? Code excerpts: public class DatastoreIndexText { private final LocalServiceTestHelper helper = fileBasedDatastoreTestHelper(); private PersistenceManager pm; @Before public void setUp() throws Exception { helper.setUp(); pm = PMF.get().getPersistenceManager(); ... } @After public void tearDown() throws Exception { try { deleteScheme(schemeId); } finally { pm.close(); // helper.tearDown(); } } private static LocalServiceTestHelper fileBasedDatastoreTestHelper() { File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); // TODO: Read these elements from the File(war/WEB-INF/appengine- web.xml). String appId = ... String appVersionId = 1; LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig() .setBackingStoreLocation(location.getAbsolutePath()) .setNoStorage(false); System.out.println(dsConfig.getBackingStoreLocation()); return new LocalServiceTestHelper( new LocalUserServiceTestConfig(), dsConfig) .setEnvIsAdmin(false) .setEnvIsLoggedIn(true) .setEnvEmail(AUTHOR_EMAIL) .setEnvAuthDomain(AUTH_DOMAIN) .setEnvAppId(appId) .setEnvVersionId(appVersionId); } On Nov 19, 12:58 am, Cyrille Vincey crll...@gmail.com wrote: Check your war WEB-INF datastore-indexes.xml (NOT the war WEB-INF appengine-generated datastore-indexes-auto.xml) You might read: datastore-indexes autoGenerate=false Try to replace with : datastore-indexes autoGenerate=true On 19/11/10 01:39, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to
Re: [appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Check your war WEB-INF datastore-indexes.xml (NOT the war WEB-INF appengine-generated datastore-indexes-auto.xml) You might read: datastore-indexes autoGenerate=false Try to replace with : datastore-indexes autoGenerate=true On 19/11/10 01:39, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Thanks for the hypotheses! I do have datastore-indexes autoGenerate=true in war/WEB-INF/datastore-indexes.xml. I tried not tearing down the helper. Still, the test doesn't touch either of the files WEB-INF/appengine-generated/datastore-indexes-auto.xml war/WEB-INF/appengine-generated/datastore-indexes-auto.xml Any more ideas? Code excerpts: public class DatastoreIndexText { private final LocalServiceTestHelper helper = fileBasedDatastoreTestHelper(); private PersistenceManager pm; @Before public void setUp() throws Exception { helper.setUp(); pm = PMF.get().getPersistenceManager(); ... } @After public void tearDown() throws Exception { try { deleteScheme(schemeId); } finally { pm.close(); // helper.tearDown(); } } private static LocalServiceTestHelper fileBasedDatastoreTestHelper() { File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); // TODO: Read these elements from the File(war/WEB-INF/appengine- web.xml). String appId = ... String appVersionId = 1; LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig() .setBackingStoreLocation(location.getAbsolutePath()) .setNoStorage(false); System.out.println(dsConfig.getBackingStoreLocation()); return new LocalServiceTestHelper( new LocalUserServiceTestConfig(), dsConfig) .setEnvIsAdmin(false) .setEnvIsLoggedIn(true) .setEnvEmail(AUTHOR_EMAIL) .setEnvAuthDomain(AUTH_DOMAIN) .setEnvAppId(appId) .setEnvVersionId(appVersionId); } On Nov 19, 12:58 am, Cyrille Vincey crll...@gmail.com wrote: Check your war WEB-INF datastore-indexes.xml (NOT the war WEB-INF appengine-generated datastore-indexes-auto.xml) You might read: datastore-indexes autoGenerate=false Try to replace with : datastore-indexes autoGenerate=true On 19/11/10 01:39, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Humm... I get a nice appengine-indexes-auto.xml after my runs. Ah yes, don t call tear down on the helper... I don t exactly remember but, this was clearing the local_db.bin file and maybe the indexes auto also. R. On Nov 18, 7:39 pm, Jerry jerry.morri...@gmail.com wrote: Great tip but it's not working. Running the test updates the mod date of local_db.bin but not datastore-indexes-auto.xml. I'm also configuring a LocalUserServiceTestConfig for a logged in user, but that doesn't seem to affect it. Is another setup step needed? I'd like a unit test to trigger all auto-index because my app has many possible combinations of query filters. Thanks! On Nov 11, 11:24 am, Starman r...@arrova.ca wrote: Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Hi Didier, thanks for your reply. Those instructions are for generating an index file while running the dev server and hitting it locally with your browser. What I am talking about is during running JUnit test cases using the LocalServiceTestHelper. That helper lets you write unit tests against the datastore and seems ideal to be able to generate indexes from since your unit tests should hit every kind of query you have. G On Nov 10, 11:03 pm, Didier Durand durand.did...@gmail.com wrote: Hi George, Did you follow the instructions ofhttp://code.google.com/appengine/docs/java/config/indexconfig.html#Us... ? That should be the answer to your question regards didier On Nov 10, 8:26 pm, gholler georgehol...@gmail.com wrote: Is it possible to auto-generate the datastore-indexes.xml while running JUnit tests that use the LocalServiceTestHelper (with LocalDatastoreServiceTestConfig)? It seems like it would be great to have the file automatically generated and then deployed with maven. Unfortunately I don't see the file being generated. Thanks, George -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Hi Didier, thanks for your reply. Those instructions are for generating an index file while running the dev server and hitting it locally with your browser. What I am talking about is during running JUnit test cases using the LocalServiceTestHelper. That helper lets you write unit tests against the datastore and seems ideal to be able to generate indexes from since your unit tests should hit every kind of query you have. G On Nov 10, 11:03 pm, Didier Durand durand.did...@gmail.com wrote: Hi George, Did you follow the instructions ofhttp://code.google.com/appengine/docs/java/config/indexconfig.html#Us... ? That should be the answer to your question regards didier On Nov 10, 8:26 pm, gholler georgehol...@gmail.com wrote: Is it possible to auto-generate the datastore-indexes.xml while running JUnit tests that use the LocalServiceTestHelper (with LocalDatastoreServiceTestConfig)? It seems like it would be great to have the file automatically generated and then deployed with maven. Unfortunately I don't see the file being generated. Thanks, George -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Something like the following will setup the datastore helper and create the datastore-indexes-auto.xml: LocalDatastoreServiceTestConfig dsConfig = new LocalDatastoreServiceTestConfig(); File location = new File(war/WEB-INF/appengine-generated/ local_db.bin); dsConfig.setBackingStoreLocation(location.getAbsolutePath()); // And it seems that for the local ds service to be able to load the local_db.bin file, the local // environment must match the app id and version as stored in the file. String xml; try { xml = FileUtils.readFileToString(new File(war/WEB-INF/ appengine-web.xml)); } catch (IOException e) { throw new RuntimeException(e); } String application = StringUtils.substringBetween(xml, application, /application); String version = StringUtils.substringBetween(xml, version, /version); // Default behavior is to keep everything in RAM. Tell the local services to use the file system dsConfig.setNoStorage(false); // Create the local services. gaeDatastoreHelper = new LocalServiceTestHelper(dsConfig); gaeDatastoreHelper.setEnvAppId(application); gaeDatastoreHelper.setEnvVersionId(version); // Calling setUp() will start the local ds service and load the local_db.bin file. gaeDatastoreHelper.setUp(); This way, you can even write tests against a previously generated local_db.bin if you want. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Auto generating datastore-indexes.xml during unit tests
Hi George, Did you follow the instructions of http://code.google.com/appengine/docs/java/config/indexconfig.html#Using_Automatic_Index_Configuration ? That should be the answer to your question regards didier On Nov 10, 8:26 pm, gholler georgehol...@gmail.com wrote: Is it possible to auto-generate the datastore-indexes.xml while running JUnit tests that use the LocalServiceTestHelper (with LocalDatastoreServiceTestConfig)? It seems like it would be great to have the file automatically generated and then deployed with maven. Unfortunately I don't see the file being generated. Thanks, George -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.