1
Один из моих классов GAE создает [датастор Entity] [1] из HTML файла:GAE: Создание объекта Entity из теста JUnit
Key parent = KeyFactory.createKey("movies", "movies");
Entity movie = new Entity("movie",System.currentTimeMillis(), parent);
setIfNotEmpty(movie, "director", Jsoup.parse(Html).select("td#f3").text());
setIfNotEmpty(movie, "year", Jsoup.parse(Html).select("td#f17").text());
....
Когда я пытаюсь вызвать этот метод в тест JUnit, следующее исключение:
java.lang.NullPointerException: No API environment is registered for this thread.
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:80)
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace(DatastoreApiHelper.java:90)
at com.google.appengine.api.datastore.Key.<init>(Key.java:97)
at com.google.appengine.api.datastore.Key.<init>(Key.java:87)
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:85)
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:78)
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:66)
at cinemasderot.Movie.parseMovieHtml(Movie.java:21)
at tests.TestParsing.testAddition(TestParsing.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
.....
проблема, как представляется, создание ключа в первой строке моего образца кода.
Как создать объект с родительским ключом из теста Junit?
Спасибо, что сделал трюк. Однако метод 'tearDown()' вызывает другое исключение. Я думаю, что я должен перестроить проект, используя Maven. –