fixed server plugin tests

problems were: missing <context:annotation-config/> and wrong base package for PersonRepository
This commit is contained in:
Michael Hunger
2011-10-19 10:12:03 +02:00
parent 88a2980e62
commit c10a45dd81
3 changed files with 14 additions and 18 deletions

View File

@@ -18,11 +18,9 @@ package org.springframework.data.neo4j.rest.support;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.rest.graphdb.RequestResult;
import org.springframework.data.neo4j.aspects.Person;
@@ -39,24 +37,16 @@ import static org.springframework.data.neo4j.aspects.Person.persistedPerson;
* @author mh
* @since 14.04.11
*/
@Ignore("TODO")
public class ServerPluginTest extends RestTestBase {
private Person person;
@BeforeClass
public static void init() {
new ProvidedClassPathXmlApplicationContext(neoServer.getGraphDatabase(), "Plugin-context.xml");
}
@Override
public void setUp() throws Exception {
super.setUp();
person = persistedPerson("Michael", 35);
}
@Test
public void testGetFriends() throws IOException {
Person person = persistedPerson("Michael", 35);
final RequestResult requestResult = RequestResult.extractFrom(createRequest("ext/TestServerPlugin/graphdb/person").post(ClientResponse.class, "{\"name\":\"" + person.getName() + "\"}"));
assertEquals(200, requestResult.getStatus());
final String result = requestResult.getEntity();

View File

@@ -49,12 +49,17 @@ public class TestServerPlugin extends ServerPlugin {
}
private synchronized ApplicationContext context(GraphDatabaseService graphDb) {
if (ctx==null) {
ctx = new ProvidedClassPathXmlApplicationContext(graphDb, "Plugin-context.xml");
personRepository = ctx.getBean(PersonRepository.class);
template = ctx.getBean(Neo4jTemplate.class);
try {
if (ctx == null) {
ctx = new ProvidedClassPathXmlApplicationContext(graphDb, "Plugin-context.xml");
personRepository = ctx.getBean(PersonRepository.class);
template = ctx.getBean(Neo4jTemplate.class);
}
return ctx;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return ctx;
}
@Name( "get_all_friends" )

View File

@@ -8,8 +8,9 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<neo4j:config graphDatabaseService="graphDatabaseService"/>
<context:annotation-config/>
<neo4j:config storeDirectory="target/test-db"/>
<neo4j:repositories base-package="org.springframework.data.neo4j.rest"/>
<neo4j:repositories base-package="org.springframework.data.neo4j.aspects"/>
</beans>