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. > > > > > >> 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.