play-neo4jplugin
                                
                                 play-neo4jplugin copied to clipboard
                                
                                    play-neo4jplugin copied to clipboard
                            
                            
                            
                        Add a sample test case
Hello guys,
thanks a lot for providing this neo4j plugin. It saves a lot of time configuring play correctly.
One thing I am missing is a sample test case. Could you provide a sample test case for the Galaxy example? Something simple that checks Neo4JServiceProvider.get() actually returns a non-null Neo4jServiceProvider, e.g. a non-null galaxyService?
This worked for me using your plugin: @Test public void serviceIsCorrectlyRegistered() { running(fakeApplication(), new Runnable() { public void run() { Neo4JServiceProvider nsp = Neo4JServiceProvider.get(); assertNotNull("Neo4jService is not correctly wired by Spring", nsp); GalaxyService ms = nsp.galaxyService; assertNotNull("GalaxyService is not correctly wired by Spring", ms); } }); }
Thanks Patrick
Hi @Brazo,
thanks for the feedback. I will write some test cases
Ups wrong button :) Coffee is still not working.
Thanks for providing this plugin. When using the same test provided by @Brazo,i am getting a nullexception below. Anyideas on what could be wrong?
java.lang.NullPointerException at neo4jplugin.Neo4JPlugin.get(Neo4JPlugin.java:105)
Code: running(fakeApplication(), new Runnable() { public void run() { Neo4JServiceProvider nsp = Neo4JServiceProvider.get(); assertNotNull("Neo4jService is not correctly wired by Spring", nsp); } });
Update: Hi Sepp, The tests provided by @Brazo are working when run from prompt with "play test" ,there is no issue now . Earlier i was trying to run from eclipse ,where it was failing with the NullPointer exception.
Thanks, Kishore
Ups okay i will try to check this at the weekend
I found a simple solution to enable us to write unit test. The test will take long tho because it require starting the application. It is not a perfect solution because the test will break if simply the application break(because it need to start the app to enable us to use the plugin), which make the test not isolated.
So basically the test class need to extends play.test.WithApplication And we add Service as a field, then add a setUp method to start the application, get the service before we start the testing. After that we will be able to use the Service object.
@Before
public void setUp() throws Exception {
    this.startPlay();
    this.citationService = Neo4JServiceProvider.get().citationService;
}
Woaaah cool one @mirahmz thx a lot :)