Upgraded Spring Data versions

This commit upgrades the Spring Data versions to the latest snapshots
This commit is contained in:
Michael Minella
2017-04-20 12:24:25 -05:00
parent 3f22b61a66
commit 6f7233222d
6 changed files with 31 additions and 227 deletions

View File

@@ -52,11 +52,11 @@ allprojects {
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
springRetryVersion = '1.2.0.RELEASE'
springAmqpVersion = '1.5.6.RELEASE'
springDataCommonsVersion = '2.0.0.M1'
springDataGemfireVersion = '2.0.0.M1'
springDataJpaVersion = '2.0.0.M1'
springDataMongodbVersion = '2.0.0.M1'
springDataNeo4jVersion = '5.0.0.M1'
springDataCommonsVersion = '2.0.0.BUILD-SNAPSHOT'
springDataGemfireVersion = '2.0.0.BUILD-SNAPSHOT'
springDataJpaVersion = '2.0.0.BUILD-SNAPSHOT'
springDataMongodbVersion = '2.0.0.BUILD-SNAPSHOT'
springDataNeo4jVersion = '5.0.0.BUILD-SNAPSHOT'
springIntegrationVersion = '5.0.0.M1'
springLdapVersion = '2.0.4.RELEASE'
@@ -264,7 +264,6 @@ project('spring-batch-core') {
dependencies {
compile project(":spring-batch-infrastructure")
compile "com.ibm.jbatch:com.ibm.jbatch-tck-spi:$jbatchTckSpi"
compile "com.fasterxml.jackson.core:jackson-databind:${jackson2Version}"
compile ("org.codehaus.jettison:jettison:$jettisonVersion") {
exclude group: 'stax', module: 'stax-api'
@@ -284,6 +283,7 @@ project('spring-batch-core') {
testCompile "commons-dbcp:commons-dbcp:$commonsDdbcpVersion"
testCompile "junit:junit:${junitVersion}"
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
optional "com.ibm.jbatch:com.ibm.jbatch-tck-spi:$jbatchTckSpi"
optional "com.thoughtworks.xstream:xstream:$xstreamVersion"
optional "org.aspectj:aspectjrt:$aspectjVersion"
optional "org.aspectj:aspectjweaver:$aspectjVersion"
@@ -297,11 +297,8 @@ project('spring-batch-core') {
project('spring-batch-infrastructure') {
description = 'Spring Batch Infrastructure'
test {
// permsize settings not passed down from GRADLE_OPTS nor JAVA_OPTS
// when running certain tests causing permgen OOM when using JDK7
// compilation is not performed with JDK6 and permgen is removed
// starting with JDK8..
if (JavaVersion.current().isJava7Compatible()) {
jvmArgs '-XX:MaxPermSize=256m'
}
@@ -493,7 +490,7 @@ project('spring-batch-test') {
dependencies {
compile project(":spring-batch-core")
compile "junit:junit:${junitVersion}"
compile "junit:junit:${junitVersion}"
compile "org.hamcrest:hamcrest-library:$hamcrestVersion"
compile "org.springframework:spring-test:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"

View File

@@ -24,7 +24,6 @@ import org.neo4j.ogm.session.SessionFactory;
import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -63,7 +62,6 @@ public abstract class AbstractNeo4jItemReader<T> extends
protected Log logger = LogFactory.getLog(getClass());
private Neo4jOperations template;
private SessionFactory sessionFactory;
private String startStatement;
@@ -153,27 +151,6 @@ public abstract class AbstractNeo4jItemReader<T> extends
this.sessionFactory = sessionFactory;
}
/**
* Used to perform operations against the Neo4J database.
*
* @param template the Neo4jOperations instance to use
* @see Neo4jOperations
* @deprecated Use {@link #setSessionFactory(SessionFactory)}
*/
@Deprecated
public void setTemplate(Neo4jOperations template) {
this.template = template;
}
/**
* @return the {@link Neo4jOperations}
* @deprecated Use {@link #getSessionFactory()}
*/
@Deprecated
protected final Neo4jOperations getTemplate() {
return this.template;
}
/**
* The object type to be returned from each call to {@link #read()}
*
@@ -214,8 +191,7 @@ public abstract class AbstractNeo4jItemReader<T> extends
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(template != null || sessionFactory != null,
"A Neo4JOperations implementation or SessionFactory is required");
Assert.state(sessionFactory != null,"A SessionFactory is required");
Assert.state(targetType != null, "The type to be returned is required");
Assert.state(StringUtils.hasText(startStatement), "A START statement is required");
Assert.state(StringUtils.hasText(returnStatement), "A RETURN statement is required");

View File

@@ -21,8 +21,6 @@ import java.util.Iterator;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
//
//import org.springframework.data.neo4j.conversion.ResultConverter;
/**
* <p>
@@ -39,18 +37,11 @@ public class Neo4jItemReader<T> extends AbstractNeo4jItemReader {
Iterable<T> queryResults;
if(factory != null) {
Session session = factory.openSession();
queryResults = session.query(getTargetType(),
generateLimitCypherQuery(),
getParameterValues());
}
else {
queryResults = getTemplate().queryForObjects(
getTargetType(), generateLimitCypherQuery(), getParameterValues());
}
if(queryResults != null) {
return queryResults.iterator();

View File

@@ -25,7 +25,6 @@ import org.neo4j.ogm.session.SessionFactory;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -49,27 +48,12 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
private boolean delete = false;
private Neo4jOperations template;
private SessionFactory sessionFactory;
private boolean useSession = false;
public void setDelete(boolean delete) {
this.delete = delete;
}
/**
* Set the {@link Neo4jOperations} to be used to save items
*
* @param template the template implementation to be used
* @deprecated Use {@link #setSessionFactory(SessionFactory)}
*/
@Deprecated
public void setTemplate(Neo4jOperations template) {
this.template = template;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@@ -81,10 +65,8 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(template != null || this.sessionFactory != null,
"A Neo4JOperations implementation or a SessionFactory is required");
this.useSession = this.sessionFactory != null;
Assert.state(this.sessionFactory != null,
"A SessionFactory is required");
}
/**
@@ -115,28 +97,18 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
}
private void delete(List<? extends T> items) {
if(this.useSession) {
Session session = this.sessionFactory.openSession();
Session session = this.sessionFactory.openSession();
items.forEach(session::delete);
}
else {
for (T item : items) {
this.template.delete(item);
}
for(T item : items) {
session.delete(item);
}
}
private void save(List<? extends T> items) {
if(this.useSession) {
Session session = this.sessionFactory.openSession();
Session session = this.sessionFactory.openSession();
items.forEach(session::save);
}
else {
for (T item : items) {
this.template.save(item);
}
for (T item : items) {
session.save(item);
}
}
}

View File

@@ -28,8 +28,6 @@ import org.mockito.MockitoAnnotations;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.data.neo4j.template.Neo4jOperations;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -40,8 +38,6 @@ import static org.mockito.Mockito.when;
public class Neo4jItemReaderTests {
@Mock
private Neo4jOperations template;
@Mock
private Iterable<String> result;
@Mock
@@ -54,20 +50,6 @@ public class Neo4jItemReaderTests {
MockitoAnnotations.initMocks(this);
}
private Neo4jItemReader<String> buildTemplateBasedReader() throws Exception {
Neo4jItemReader<String> reader = new Neo4jItemReader<>();
reader.setTemplate(template);
reader.setTargetType(String.class);
reader.setStartStatement("n=node(*)");
reader.setReturnStatement("*");
reader.setOrderByStatement("n.age");
reader.setPageSize(50);
reader.afterPropertiesSet();
return reader;
}
private Neo4jItemReader<String> buildSessionBasedReader() throws Exception {
Neo4jItemReader<String> reader = new Neo4jItemReader<>();
@@ -84,22 +66,23 @@ public class Neo4jItemReaderTests {
@Test
public void testAfterPropertiesSet() throws Exception {
Neo4jItemReader<String> reader = new Neo4jItemReader<>();
try {
reader.afterPropertiesSet();
fail("Template was not set but exception was not thrown.");
fail("SessionFactory was not set but exception was not thrown.");
} catch (IllegalStateException iae) {
assertEquals("A Neo4JOperations implementation or SessionFactory is required", iae.getMessage());
assertEquals("A SessionFactory is required", iae.getMessage());
} catch (Throwable t) {
fail("Wrong exception was thrown:" + t);
}
reader.setTemplate(template);
reader.setSessionFactory(this.sessionFactory);
try {
reader.afterPropertiesSet();
fail("type was not set but exception was not thrown.");
fail("Target Type was not set but exception was not thrown.");
} catch (IllegalStateException iae) {
assertEquals("The type to be returned is required", iae.getMessage());
} catch (Throwable t) {
@@ -153,22 +136,10 @@ public class Neo4jItemReaderTests {
reader.afterPropertiesSet();
}
@SuppressWarnings("unchecked")
@Test
public void testNullResults() throws Exception {
Neo4jItemReader<String> itemReader = buildTemplateBasedReader();
ArgumentCaptor<String> query = ArgumentCaptor.forClass(String.class);
when(template.queryForObjects(eq(String.class), query.capture(), isNull())).thenReturn(null);
assertFalse(itemReader.doPageRead().hasNext());
assertEquals("START n=node(*) RETURN * ORDER BY n.age SKIP 0 LIMIT 50", query.getValue());
}
@SuppressWarnings("unchecked")
@Test
public void testNullResultsWithSession() throws Exception {
Neo4jItemReader<String> itemReader = buildSessionBasedReader();
ArgumentCaptor<String> query = ArgumentCaptor.forClass(String.class);
@@ -180,19 +151,6 @@ public class Neo4jItemReaderTests {
assertEquals("START n=node(*) RETURN * ORDER BY n.age SKIP 0 LIMIT 50", query.getValue());
}
@SuppressWarnings("unchecked")
@Test
public void testNoResults() throws Exception {
Neo4jItemReader<String> itemReader = buildTemplateBasedReader();
ArgumentCaptor<String> query = ArgumentCaptor.forClass(String.class);
when(template.queryForObjects(eq(String.class), query.capture(), isNull())).thenReturn(result);
when(result.iterator()).thenReturn(Collections.emptyIterator());
assertFalse(itemReader.doPageRead().hasNext());
assertEquals("START n=node(*) RETURN * ORDER BY n.age SKIP 0 LIMIT 50", query.getValue());
}
@SuppressWarnings("unchecked")
@Test
public void testNoResultsWithSession() throws Exception {
@@ -207,20 +165,6 @@ public class Neo4jItemReaderTests {
assertEquals("START n=node(*) RETURN * ORDER BY n.age SKIP 0 LIMIT 50", query.getValue());
}
@SuppressWarnings("serial")
@Test
public void testResultsWithMatchAndWhere() throws Exception {
Neo4jItemReader<String> itemReader = buildTemplateBasedReader();
itemReader.setMatchStatement("n -- m");
itemReader.setWhereStatement("has(n.name)");
itemReader.setReturnStatement("m");
itemReader.afterPropertiesSet();
when(template.queryForObjects(String.class, "START n=node(*) MATCH n -- m WHERE has(n.name) RETURN m ORDER BY n.age SKIP 0 LIMIT 50", null)).thenReturn(result);
when(result.iterator()).thenReturn(Arrays.asList("foo", "bar", "baz").iterator());
assertTrue(itemReader.doPageRead().hasNext());
}
@SuppressWarnings("serial")
@Test
public void testResultsWithMatchAndWhereWithSession() throws Exception {
@@ -237,23 +181,6 @@ public class Neo4jItemReaderTests {
assertTrue(itemReader.doPageRead().hasNext());
}
@SuppressWarnings("serial")
@Test
public void testResultsWithMatchAndWhereWithParameters() throws Exception {
Neo4jItemReader<String> itemReader = buildTemplateBasedReader();
Map<String, Object> params = new HashMap<>();
params.put("foo", "bar");
itemReader.setParameterValues(params);
itemReader.setMatchStatement("n -- m");
itemReader.setWhereStatement("has(n.name)");
itemReader.setReturnStatement("m");
itemReader.afterPropertiesSet();
when(template.queryForObjects(String.class, "START n=node(*) MATCH n -- m WHERE has(n.name) RETURN m ORDER BY n.age SKIP 0 LIMIT 50", params)).thenReturn(result);
when(result.iterator()).thenReturn(Arrays.asList("foo", "bar", "baz").iterator());
assertTrue(itemReader.doPageRead().hasNext());
}
@SuppressWarnings("serial")
@Test
public void testResultsWithMatchAndWhereWithParametersWithSession() throws Exception {

View File

@@ -25,8 +25,6 @@ import org.mockito.MockitoAnnotations;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.data.neo4j.template.Neo4jOperations;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.verify;
@@ -36,8 +34,7 @@ import static org.mockito.Mockito.when;
public class Neo4jItemWriterTests {
private Neo4jItemWriter<String> writer;
@Mock
private Neo4jOperations template;
@Mock
private SessionFactory sessionFactory;
@Mock
@@ -50,18 +47,19 @@ public class Neo4jItemWriterTests {
@Test
public void testAfterPropertiesSet() throws Exception{
writer = new Neo4jItemWriter<>();
try {
writer.afterPropertiesSet();
fail("Template was not set but exception was not thrown.");
fail("SessionFactory was not set but exception was not thrown.");
} catch (IllegalStateException iae) {
assertEquals("A Neo4JOperations implementation or a SessionFactory is required", iae.getMessage());
assertEquals("A SessionFactory is required", iae.getMessage());
} catch (Throwable t) {
fail("Wrong exception was thrown.");
}
writer.setTemplate(template);
writer.setSessionFactory(this.sessionFactory);
writer.afterPropertiesSet();
@@ -73,28 +71,15 @@ public class Neo4jItemWriterTests {
}
@Test
public void testWriteNull() throws Exception {
public void testWriteNullSession() throws Exception {
writer = new Neo4jItemWriter<>();
writer.setTemplate(template);
writer.setSessionFactory(this.sessionFactory);
writer.afterPropertiesSet();
writer.write(null);
verifyZeroInteractions(template);
verifyZeroInteractions(this.session);
}
@Test
public void testWriteNoItems() throws Exception {
writer = new Neo4jItemWriter<>();
writer.setTemplate(template);
writer.afterPropertiesSet();
writer.write(new ArrayList<>());
verifyZeroInteractions(template);
verifyZeroInteractions(this.session);
}
@@ -108,7 +93,6 @@ public class Neo4jItemWriterTests {
when(this.sessionFactory.openSession()).thenReturn(this.session);
writer.write(null);
verifyZeroInteractions(template);
verifyZeroInteractions(this.session);
}
@@ -122,29 +106,9 @@ public class Neo4jItemWriterTests {
when(this.sessionFactory.openSession()).thenReturn(this.session);
writer.write(new ArrayList<>());
verifyZeroInteractions(template);
verifyZeroInteractions(this.session);
}
@Test
public void testWriteItems() throws Exception {
writer = new Neo4jItemWriter<>();
writer.setTemplate(template);
writer.afterPropertiesSet();
List<String> items = new ArrayList<>();
items.add("foo");
items.add("bar");
writer.write(items);
verify(template).save("foo");
verify(template).save("bar");
verifyZeroInteractions(this.session);
verifyZeroInteractions(this.sessionFactory);
}
@Test
public void testWriteItemsWithSession() throws Exception {
writer = new Neo4jItemWriter<>();
@@ -161,28 +125,6 @@ public class Neo4jItemWriterTests {
verify(this.session).save("foo");
verify(this.session).save("bar");
verifyZeroInteractions(template);
}
@Test
public void testDeleteItems() throws Exception {
writer = new Neo4jItemWriter<>();
writer.setTemplate(template);
writer.afterPropertiesSet();
List<String> items = new ArrayList<>();
items.add("foo");
items.add("bar");
writer.setDelete(true);
writer.write(items);
verify(template).delete("foo");
verify(template).delete("bar");
verifyZeroInteractions(this.session);
verifyZeroInteractions(this.sessionFactory);
}
@Test
@@ -203,6 +145,5 @@ public class Neo4jItemWriterTests {
verify(this.session).delete("foo");
verify(this.session).delete("bar");
verifyZeroInteractions(template);
}
}