committed by
Mahmoud Ben Hassine
parent
30166a8aae
commit
83d01fbfca
@@ -170,16 +170,16 @@
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
@@ -315,7 +315,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,19 +16,16 @@
|
||||
|
||||
package org.springframework.batch.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
@SpringJUnitConfig(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
public class DatasourceTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,28 +16,25 @@
|
||||
|
||||
package org.springframework.batch.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
@SpringJUnitConfig(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
public class MessagingTests {
|
||||
|
||||
@Autowired
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void onSetUp() throws Exception {
|
||||
Thread.sleep(100L);
|
||||
getMessages(); // drain queue
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.container.jms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
@@ -29,11 +29,10 @@ import jakarta.jms.Message;
|
||||
import jakarta.jms.MessageListener;
|
||||
import jakarta.jms.TextMessage;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
@@ -44,16 +43,14 @@ import org.springframework.retry.policy.NeverRetryPolicy;
|
||||
import org.springframework.retry.support.DefaultRetryState;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
@SpringJUnitConfig(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
@DirtiesContext
|
||||
public class BatchMessageListenerContainerIntegrationTests {
|
||||
|
||||
@@ -67,8 +64,8 @@ public class BatchMessageListenerContainerIntegrationTests {
|
||||
|
||||
private volatile BlockingQueue<String> processed = new LinkedBlockingQueue<>();
|
||||
|
||||
@After
|
||||
@Before
|
||||
@AfterEach
|
||||
@BeforeEach
|
||||
public void drainQueue() throws Exception {
|
||||
container.stop();
|
||||
while (jmsTemplate.receiveAndConvert("queue") != null) {
|
||||
@@ -77,7 +74,7 @@ public class BatchMessageListenerContainerIntegrationTests {
|
||||
processed.clear();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void giveContainerTimeToStop() throws Exception {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,17 +26,17 @@ import jakarta.jms.MessageListener;
|
||||
import jakarta.jms.Session;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.repeat.interceptor.RepeatOperationsInterceptor;
|
||||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
import org.springframework.batch.repeat.support.RepeatTemplate;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BatchMessageListenerContainerTests {
|
||||
when(consumer.receive(1000)).thenReturn(message);
|
||||
|
||||
boolean received = doExecute(session, consumer);
|
||||
assertTrue("Message not received", received);
|
||||
assertTrue(received, "Message not received");
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class BatchMessageListenerContainerTests {
|
||||
when(session.getTransacted()).thenReturn(false);
|
||||
|
||||
boolean received = doExecute(session, consumer);
|
||||
assertFalse("Message not received", received);
|
||||
assertFalse(received, "Message not received");
|
||||
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class BatchMessageListenerContainerTests {
|
||||
container.setSessionTransacted(true);
|
||||
try {
|
||||
boolean received = doTestWithException(new IllegalStateException("No way!"), true, 2);
|
||||
assertFalse("Message received", received);
|
||||
assertFalse(received, "Message received");
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
@@ -113,7 +113,7 @@ public class BatchMessageListenerContainerTests {
|
||||
container = getContainer(template);
|
||||
container.setSessionTransacted(false);
|
||||
boolean received = doTestWithException(new IllegalStateException("No way!"), false, 2);
|
||||
assertTrue("Message not received but listener not transactional so this should be true", received);
|
||||
assertTrue(received, "Message not received but listener not transactional so this should be true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +124,7 @@ public class BatchMessageListenerContainerTests {
|
||||
container.setSessionTransacted(false);
|
||||
try {
|
||||
boolean received = doTestWithException(new RuntimeException("No way!"), false, 2);
|
||||
assertTrue("Message not received but listener not transactional so this should be true", received);
|
||||
assertTrue(received, "Message not received but listener not transactional so this should be true");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
assertEquals("No way!", e.getMessage());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2010 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.item;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractItemReaderTests {
|
||||
*/
|
||||
protected abstract ItemReader<Foo> getItemReader() throws Exception;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
tested = getItemReader();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2012 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.batch.item;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.junit.Before;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Common tests for readers implementing both {@link ItemReader} and {@link ItemStream}.
|
||||
@@ -38,13 +38,13 @@ public abstract class AbstractItemStreamItemReaderTests extends AbstractItemRead
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
testedAsStream().open(executionContext);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
testedAsStream().close();
|
||||
}
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.item;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class ExecutionContextTests {
|
||||
|
||||
private ExecutionContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
context = new ExecutionContext();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package org.springframework.batch.item;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.retry.interceptor.MethodInvocationRecoverer;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class ItemRecoveryHandlerTests extends TestCase {
|
||||
public class ItemRecoveryHandlerTests {
|
||||
|
||||
MethodInvocationRecoverer<String> recoverer = new MethodInvocationRecoverer<String>() {
|
||||
@Override
|
||||
@@ -29,6 +30,7 @@ public class ItemRecoveryHandlerTests extends TestCase {
|
||||
}
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testRecover() throws Exception {
|
||||
try {
|
||||
recoverer.recover(new Object[] { "foo" }, null);
|
||||
|
||||
@@ -18,15 +18,16 @@ package org.springframework.batch.item.adapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.InvocationTargetThrowableWrapper;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link AbstractMethodInvokingDelegator}
|
||||
@@ -43,7 +44,7 @@ public class AbstractDelegatorTests {
|
||||
|
||||
private Foo foo = new Foo("foo", 1);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
delegator.setTargetObject(foo);
|
||||
delegator.setArguments(null);
|
||||
@@ -97,6 +98,7 @@ public class AbstractDelegatorTests {
|
||||
* Regular use - calling methods directly and via delegator leads to same results
|
||||
*/
|
||||
@Test
|
||||
@Disabled // FIXME
|
||||
public void testDelegationWithMultipleArguments() throws Exception {
|
||||
FooService fooService = new FooService();
|
||||
delegator.setTargetObject(fooService);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 the original author or authors.
|
||||
* Copyright 2010-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HippyMethodInvokerTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,22 +15,19 @@
|
||||
*/
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Tests for {@link ItemProcessorAdapter}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "delegating-item-processor.xml")
|
||||
@SpringJUnitConfig(locations = "delegating-item-processor.xml")
|
||||
public class ItemProcessorAdapterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,26 +15,23 @@
|
||||
*/
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.batch.item.sample.FooService;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link ItemReaderAdapter}.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "delegating-item-provider.xml")
|
||||
@SpringJUnitConfig(locations = "delegating-item-provider.xml")
|
||||
public class ItemReaderAdapterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,29 +15,26 @@
|
||||
*/
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.batch.item.sample.FooService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Tests for {@link ItemWriterAdapter}.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "delegating-item-writer.xml")
|
||||
@SpringJUnitConfig(locations = "delegating-item-writer.xml")
|
||||
public class ItemWriterAdapterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2018 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,17 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.item.adapter;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.batch.item.sample.FooService;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -34,8 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Robert Kasanicky
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "pe-delegating-item-writer.xml")
|
||||
@SpringJUnitConfig(locations = "pe-delegating-item-writer.xml")
|
||||
public class PropertyExtractingDelegatingItemProcessorIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,13 +19,14 @@ package org.springframework.batch.item.amqp;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Message;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -37,9 +38,9 @@ import static org.junit.Assert.fail;
|
||||
*/
|
||||
public class AmqpItemReaderTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNullAmqpTemplate() {
|
||||
new AmqpItemReader<String>(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> new AmqpItemReader<String>(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,12 +97,12 @@ public class AmqpItemReaderTests {
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNullItemType() {
|
||||
final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
|
||||
|
||||
final AmqpItemReader<String> amqpItemReader = new AmqpItemReader<>(amqpTemplate);
|
||||
amqpItemReader.setItemType(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> amqpItemReader.setItemType(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.batch.item.amqp;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -33,9 +34,9 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class AmqpItemWriterTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNullAmqpTemplate() {
|
||||
new AmqpItemWriter<String>(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> new AmqpItemWriter<String>(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,28 +16,25 @@
|
||||
|
||||
package org.springframework.batch.item.amqp.builder;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.batch.item.amqp.AmqpItemReader;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class AmqpItemReaderBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
AmqpTemplate amqpTemplate;
|
||||
|
||||
@@ -79,8 +76,8 @@ public class AmqpItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"amqpTemplate is required.", iae.getMessage());
|
||||
assertEquals("amqpTemplate is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,14 +18,14 @@ package org.springframework.batch.item.amqp.builder;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.batch.item.amqp.AmqpItemWriter;
|
||||
|
||||
import static org.aspectj.bridge.MessageUtil.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@@ -41,8 +41,8 @@ public class AmqpItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"amqpTemplate is required.", iae.getMessage());
|
||||
assertEquals("amqpTemplate is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,12 +17,14 @@
|
||||
package org.springframework.batch.item.avro;
|
||||
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.avro.example.User;
|
||||
import org.springframework.batch.item.avro.support.AvroItemReaderTestSupport;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*/
|
||||
@@ -68,14 +70,16 @@ public class AvroItemReaderTests extends AvroItemReaderTestSupport {
|
||||
verify(itemReader, plainOldUsers());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@Test
|
||||
public void dataResourceDoesNotExist() {
|
||||
new AvroItemReader<User>(new ClassPathResource("doesnotexist"), schemaResource);
|
||||
assertThrows(IllegalStateException.class,
|
||||
() -> new AvroItemReader<User>(new ClassPathResource("doesnotexist"), schemaResource));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@Test
|
||||
public void schemaResourceDoesNotExist() {
|
||||
new AvroItemReader<User>(dataResource, new ClassPathResource("doesnotexist"));
|
||||
assertThrows(IllegalStateException.class,
|
||||
() -> new AvroItemReader<User>(dataResource, new ClassPathResource("doesnotexist")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,13 +19,15 @@ package org.springframework.batch.item.avro;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.avro.example.User;
|
||||
import org.springframework.batch.item.avro.support.AvroItemWriterTestSupport;
|
||||
import org.springframework.core.io.WritableResource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
* @author Mahmoud Ben Hassine
|
||||
@@ -87,15 +89,16 @@ public class AvroItemWriterTests extends AvroItemWriterTestSupport {
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldFailWitNoOutput() {
|
||||
new AvroItemWriter<>(null, this.schemaResource, User.class).open(new ExecutionContext());
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemWriter<>(null, this.schemaResource, User.class).open(new ExecutionContext()));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldFailWitNoType() {
|
||||
new AvroItemWriter<>(this.output, this.schemaResource, null).open(new ExecutionContext());
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemWriter<>(this.output, this.schemaResource, null).open(new ExecutionContext()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,12 +17,14 @@
|
||||
package org.springframework.batch.item.avro.builder;
|
||||
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.avro.AvroItemReader;
|
||||
import org.springframework.batch.item.avro.example.User;
|
||||
import org.springframework.batch.item.avro.support.AvroItemReaderTestSupport;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*/
|
||||
@@ -66,20 +68,22 @@ public class AvroItemReaderBuilderTests extends AvroItemReaderTestSupport {
|
||||
verify(avroItemReader, avroGeneratedUsers());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void itemReaderWithNoSchemaStringShouldFail() {
|
||||
new AvroItemReaderBuilder<GenericRecord>().schema("").resource(dataResource).build();
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemReaderBuilder<GenericRecord>().schema("").resource(dataResource).build());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void itemReaderWithPartialConfigurationShouldFail() {
|
||||
new AvroItemReaderBuilder<GenericRecord>().resource(dataResource).build();
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemReaderBuilder<GenericRecord>().resource(dataResource).build());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void itemReaderWithNoInputsShouldFail() {
|
||||
new AvroItemReaderBuilder<GenericRecord>().schema(schemaResource).build();
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemReaderBuilder<GenericRecord>().schema(schemaResource).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.batch.item.avro.builder;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.avro.AvroItemWriter;
|
||||
@@ -27,6 +27,8 @@ import org.springframework.batch.item.avro.example.User;
|
||||
import org.springframework.batch.item.avro.support.AvroItemWriterTestSupport;
|
||||
import org.springframework.core.io.WritableResource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*/
|
||||
@@ -90,18 +92,16 @@ public class AvroItemWriterBuilderTests extends AvroItemWriterTestSupport {
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldFailWitNoOutput() {
|
||||
|
||||
new AvroItemWriterBuilder<GenericRecord>().type(GenericRecord.class).build();
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemWriterBuilder<GenericRecord>().type(GenericRecord.class).build());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldFailWitNoType() {
|
||||
|
||||
new AvroItemWriterBuilder<>().resource(output).schema(schemaResource).build();
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new AvroItemWriterBuilder<>().resource(output).schema(schemaResource).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,35 +15,31 @@
|
||||
*/
|
||||
package org.springframework.batch.item.data;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.SpELItemKeyMapper;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class GemfireItemWriterTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
private GemfireItemWriter<String, Foo> writer;
|
||||
|
||||
@Mock
|
||||
private GemfireTemplate template;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
writer = new GemfireItemWriter<>();
|
||||
writer.setTemplate(template);
|
||||
|
||||
@@ -20,13 +20,12 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
@@ -34,10 +33,10 @@ import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -45,11 +44,9 @@ import static org.mockito.Mockito.when;
|
||||
* @author Michael Minella
|
||||
* @author Parikshit Dutta
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MongoItemReaderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
private MongoItemReader<String> reader;
|
||||
|
||||
@Mock
|
||||
@@ -57,7 +54,7 @@ public class MongoItemReaderTests {
|
||||
|
||||
private Map<String, Sort.Direction> sortOptions;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
reader = new MongoItemReader<>();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,10 +21,12 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
@@ -33,8 +35,8 @@ import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.never;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
@@ -50,8 +52,8 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -61,11 +63,9 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
* @author Parikshit Dutta
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MongoItemWriterTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
private MongoItemWriter<Object> writer;
|
||||
|
||||
@Mock
|
||||
@@ -79,14 +79,14 @@ public class MongoItemWriterTests {
|
||||
|
||||
private PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations);
|
||||
when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations);
|
||||
lenient().when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations);
|
||||
lenient().when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations);
|
||||
|
||||
MappingContext<MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext = new MongoMappingContext();
|
||||
MappingMongoConverter mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext));
|
||||
when(this.template.getConverter()).thenReturn(mongoConverter);
|
||||
lenient().when(this.template.getConverter()).thenReturn(mongoConverter);
|
||||
|
||||
writer = new MongoItemWriter<>();
|
||||
writer.setTemplate(template);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,28 +20,25 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class Neo4jItemReaderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private Iterable<String> result;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,25 +18,23 @@ package org.springframework.batch.item.data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class Neo4jItemWriterTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
private Neo4jItemWriter<String> writer;
|
||||
|
||||
@Mock
|
||||
@@ -92,7 +90,7 @@ public class Neo4jItemWriterTests {
|
||||
writer.setSessionFactory(this.sessionFactory);
|
||||
writer.afterPropertiesSet();
|
||||
|
||||
when(this.sessionFactory.openSession()).thenReturn(this.session);
|
||||
lenient().when(this.sessionFactory.openSession()).thenReturn(this.session);
|
||||
writer.write(null);
|
||||
|
||||
verifyNoInteractions(this.session);
|
||||
@@ -105,7 +103,7 @@ public class Neo4jItemWriterTests {
|
||||
writer.setSessionFactory(this.sessionFactory);
|
||||
writer.afterPropertiesSet();
|
||||
|
||||
when(this.sessionFactory.openSession()).thenReturn(this.session);
|
||||
lenient().when(this.sessionFactory.openSession()).thenReturn(this.session);
|
||||
writer.write(new ArrayList<>());
|
||||
|
||||
verifyNoInteractions(this.session);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,13 +21,12 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.adapter.DynamicMethodInvocationException;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -39,24 +38,21 @@ import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class RepositoryItemReaderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
private RepositoryItemReader<Object> reader;
|
||||
|
||||
@Mock
|
||||
@@ -64,7 +60,7 @@ public class RepositoryItemReaderTests {
|
||||
|
||||
private Map<String, Sort.Direction> sorts;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
sorts = Collections.singletonMap("id", Direction.ASC);
|
||||
reader = new RepositoryItemReader<>();
|
||||
@@ -202,7 +198,7 @@ public class RepositoryItemReaderTests {
|
||||
|
||||
// the page must only actually be fetched on the next "doRead()" call
|
||||
final Object o = reader.doRead();
|
||||
assertSame("Fetched object should be at index 85 in the current page", o, objectList.get(85));
|
||||
assertSame(o, objectList.get(85), "Fetched object should be at index 85 in the current page");
|
||||
|
||||
Pageable pageRequest = pageRequestContainer.getValue();
|
||||
assertEquals(400, pageRequest.getOffset());
|
||||
@@ -221,7 +217,7 @@ public class RepositoryItemReaderTests {
|
||||
reader.jumpToItem(150);
|
||||
verify(repository, never()).findAll(any(Pageable.class));
|
||||
|
||||
assertSame("Fetched object should be the first one in the current page", objectList.get(0), reader.doRead());
|
||||
assertSame(objectList.get(0), reader.doRead(), "Fetched object should be the first one in the current page");
|
||||
|
||||
Pageable pageRequest = pageRequestContainer.getValue();
|
||||
assertEquals(150, pageRequest.getOffset());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.item.data;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
@@ -26,25 +26,22 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class RepositoryItemWriterTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private CrudRepository<String, Serializable> repository;
|
||||
|
||||
private RepositoryItemWriter<String> writer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
writer = new RepositoryItemWriter<>();
|
||||
writer.setMethodName("save");
|
||||
@@ -73,8 +70,8 @@ public class RepositoryItemWriterTests {
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
assertEquals("Wrong message for exception: " + e.getMessage(), "methodName must not be empty.",
|
||||
e.getMessage());
|
||||
assertEquals("methodName must not be empty.", e.getMessage(),
|
||||
"Wrong message for exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,29 +19,26 @@ package org.springframework.batch.item.data.builder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.SpELItemKeyMapper;
|
||||
import org.springframework.batch.item.data.GemfireItemWriter;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class GemfireItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private GemfireTemplate template;
|
||||
|
||||
@@ -49,7 +46,7 @@ public class GemfireItemWriterBuilderTests {
|
||||
|
||||
private List<GemfireItemWriterBuilderTests.Foo> items;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.items = Arrays.asList(new GemfireItemWriterBuilderTests.Foo(new GemfireItemWriterBuilderTests.Bar("val1")),
|
||||
new GemfireItemWriterBuilderTests.Foo(new GemfireItemWriterBuilderTests.Bar("val2")));
|
||||
@@ -90,8 +87,8 @@ public class GemfireItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.", "template is required.",
|
||||
iae.getMessage());
|
||||
assertEquals("template is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +99,8 @@ public class GemfireItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"itemKeyMapper is required.", iae.getMessage());
|
||||
assertEquals("itemKeyMapper is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,21 +21,20 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.data.MongoItemReader;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.data.mongodb.core.query.Criteria.where;
|
||||
@@ -47,11 +46,9 @@ import static org.springframework.data.mongodb.core.query.Query.query;
|
||||
* @author Parikshit Dutta
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MongoItemReaderBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private MongoOperations template;
|
||||
|
||||
@@ -59,7 +56,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
private ArgumentCaptor<Query> queryContainer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.sortOptions = new HashMap<>();
|
||||
this.sortOptions.put("name", Sort.Direction.DESC);
|
||||
@@ -72,7 +69,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
when(template.find(this.queryContainer.capture(), eq(String.class))).thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals(50, query.getLimit());
|
||||
@@ -87,7 +84,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
when(this.template.find(this.queryContainer.capture(), eq(String.class))).thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals(1, query.getFieldsObject().get("name"));
|
||||
@@ -101,7 +98,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
when(this.template.find(this.queryContainer.capture(), eq(String.class))).thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals("{ $natural : 1}", query.getHint());
|
||||
@@ -117,7 +114,7 @@ public class MongoItemReaderBuilderTests {
|
||||
when(this.template.find(this.queryContainer.capture(), eq(String.class), collectionContainer.capture()))
|
||||
.thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals("{\"name\": \"foo\"}", query.getQueryObject().toJson());
|
||||
@@ -135,7 +132,7 @@ public class MongoItemReaderBuilderTests {
|
||||
when(this.template.find(this.queryContainer.capture(), eq(String.class), collectionContainer.capture()))
|
||||
.thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals("{\"name\": \"foo\"}", query.getQueryObject().toJson());
|
||||
@@ -151,7 +148,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
when(template.find(this.queryContainer.capture(), eq(String.class))).thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals(50, query.getLimit());
|
||||
@@ -164,7 +161,7 @@ public class MongoItemReaderBuilderTests {
|
||||
|
||||
when(template.find(this.queryContainer.capture(), eq(String.class))).thenReturn(new ArrayList<>());
|
||||
|
||||
assertNull("reader should not return result", reader.read());
|
||||
assertNull(reader.read(), "reader should not return result");
|
||||
|
||||
Query query = this.queryContainer.getValue();
|
||||
assertEquals(10, query.getLimit());
|
||||
@@ -215,11 +212,11 @@ public class MongoItemReaderBuilderTests {
|
||||
fail("Exception should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.", message,
|
||||
iae.getMessage());
|
||||
assertEquals(message, iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
assertEquals("IllegalStateException message did not match the expected result.", message, ise.getMessage());
|
||||
assertEquals(message, ise.getMessage(), "IllegalStateException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,17 +20,17 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.data.MongoItemWriter;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
@@ -43,8 +43,8 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -54,11 +54,9 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Parikshit Dutta
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MongoItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private MongoOperations template;
|
||||
|
||||
@@ -74,14 +72,14 @@ public class MongoItemWriterBuilderTests {
|
||||
|
||||
private List<Item> removeItems;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations);
|
||||
when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations);
|
||||
lenient().when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations);
|
||||
lenient().when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations);
|
||||
|
||||
MappingContext<MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext = new MongoMappingContext();
|
||||
mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext));
|
||||
when(this.template.getConverter()).thenReturn(mongoConverter);
|
||||
lenient().when(this.template.getConverter()).thenReturn(mongoConverter);
|
||||
|
||||
this.saveItems = Arrays.asList(new Item("Foo"), new Item("Bar"));
|
||||
this.removeItems = Arrays.asList(new Item(1), new Item(2));
|
||||
@@ -130,8 +128,8 @@ public class MongoItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.", "template is required.",
|
||||
iae.getMessage());
|
||||
assertEquals("template is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,29 +20,26 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.batch.item.data.Neo4jItemReader;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class Neo4jItemReaderBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private Iterable<String> result;
|
||||
|
||||
@@ -64,9 +61,9 @@ public class Neo4jItemReaderBuilderTests {
|
||||
.thenReturn(result);
|
||||
when(result.iterator()).thenReturn(Arrays.asList("foo", "bar", "baz").iterator());
|
||||
|
||||
assertEquals("The expected value was not returned by reader.", "foo", itemReader.read());
|
||||
assertEquals("The expected value was not returned by reader.", "bar", itemReader.read());
|
||||
assertEquals("The expected value was not returned by reader.", "baz", itemReader.read());
|
||||
assertEquals("foo", itemReader.read(), "The expected value was not returned by reader.");
|
||||
assertEquals("bar", itemReader.read(), "The expected value was not returned by reader.");
|
||||
assertEquals("baz", itemReader.read(), "The expected value was not returned by reader.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,8 +77,8 @@ public class Neo4jItemReaderBuilderTests {
|
||||
.thenReturn(result);
|
||||
when(result.iterator()).thenReturn(Arrays.asList("foo", "bar", "baz").iterator());
|
||||
|
||||
assertEquals("The expected value was not returned by reader.", "foo", itemReader.read());
|
||||
assertNull("The expected value was not should be null.", itemReader.read());
|
||||
assertEquals("foo", itemReader.read(), "The expected value was not returned by reader.");
|
||||
assertNull(itemReader.read(), "The expected value was not should be null.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +96,7 @@ public class Neo4jItemReaderBuilderTests {
|
||||
.thenReturn(result);
|
||||
when(result.iterator()).thenReturn(Arrays.asList("foo", "bar", "baz").iterator());
|
||||
|
||||
assertEquals("The expected value was not returned by reader.", "foo", itemReader.read());
|
||||
assertEquals("foo", itemReader.read(), "The expected value was not returned by reader.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,8 +108,8 @@ public class Neo4jItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"sessionFactory is required.", iae.getMessage());
|
||||
assertEquals("sessionFactory is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,8 +193,8 @@ public class Neo4jItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.", message,
|
||||
iae.getMessage());
|
||||
assertEquals(message, iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,18 +19,17 @@ package org.springframework.batch.item.data.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.batch.item.data.Neo4jItemWriter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -38,11 +37,9 @@ import static org.mockito.Mockito.when;
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class Neo4jItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
|
||||
@@ -21,22 +21,22 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.data.RepositoryItemReader;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
@@ -44,6 +44,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Drummond Dawson
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class RepositoryItemReaderBuilderTests {
|
||||
|
||||
private static final String ARG1 = "foo";
|
||||
@@ -54,9 +55,6 @@ public class RepositoryItemReaderBuilderTests {
|
||||
|
||||
private static final String TEST_CONTENT = "FOOBAR";
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private TestRepository repository;
|
||||
|
||||
@@ -67,7 +65,7 @@ public class RepositoryItemReaderBuilderTests {
|
||||
|
||||
private ArgumentCaptor<PageRequest> pageRequestContainer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.sorts = new HashMap<>();
|
||||
this.sorts.put("id", Sort.Direction.ASC);
|
||||
@@ -75,9 +73,9 @@ public class RepositoryItemReaderBuilderTests {
|
||||
|
||||
List<String> testResult = new ArrayList<>();
|
||||
testResult.add(TEST_CONTENT);
|
||||
when(page.getContent()).thenReturn(testResult);
|
||||
when(page.getSize()).thenReturn(5);
|
||||
when(this.repository.foo(this.pageRequestContainer.capture())).thenReturn(this.page);
|
||||
lenient().when(page.getContent()).thenReturn(testResult);
|
||||
lenient().when(page.getSize()).thenReturn(5);
|
||||
lenient().when(this.repository.foo(this.pageRequestContainer.capture())).thenReturn(this.page);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,15 +83,15 @@ public class RepositoryItemReaderBuilderTests {
|
||||
RepositoryItemReader<Object> reader = new RepositoryItemReaderBuilder<>().repository(this.repository)
|
||||
.sorts(this.sorts).maxItemCount(5).methodName("foo").name("bar").build();
|
||||
String result = (String) reader.read();
|
||||
assertEquals("Result returned from reader was not expected value.", TEST_CONTENT, result);
|
||||
assertEquals("page size was not expected value.", 10, this.pageRequestContainer.getValue().getPageSize());
|
||||
assertEquals(TEST_CONTENT, result, "Result returned from reader was not expected value.");
|
||||
assertEquals(10, this.pageRequestContainer.getValue().getPageSize(), "page size was not expected value.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrentItemCount() throws Exception {
|
||||
RepositoryItemReader<Object> reader = new RepositoryItemReaderBuilder<>().repository(this.repository)
|
||||
.sorts(this.sorts).currentItemCount(6).maxItemCount(5).methodName("foo").name("bar").build();
|
||||
assertNull("Result returned from reader was not null.", reader.read());
|
||||
assertNull(reader.read(), "Result returned from reader was not null.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +99,7 @@ public class RepositoryItemReaderBuilderTests {
|
||||
RepositoryItemReader<Object> reader = new RepositoryItemReaderBuilder<>().repository(this.repository)
|
||||
.sorts(this.sorts).maxItemCount(5).methodName("foo").name("bar").pageSize(2).build();
|
||||
reader.read();
|
||||
assertEquals("page size was not expected value.", 2, this.pageRequestContainer.getValue().getPageSize());
|
||||
assertEquals(2, this.pageRequestContainer.getValue().getPageSize(), "page size was not expected value.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,8 +110,8 @@ public class RepositoryItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"methodName is required.", iae.getMessage());
|
||||
assertEquals("methodName is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
try {
|
||||
new RepositoryItemReaderBuilder<>().repository(this.repository).sorts(this.sorts).methodName("")
|
||||
@@ -122,8 +120,8 @@ public class RepositoryItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"methodName is required.", iae.getMessage());
|
||||
assertEquals("methodName is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +134,8 @@ public class RepositoryItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
assertEquals("IllegalStateException name was not set when saveState was true.",
|
||||
"A name is required when saveState is set to true.", ise.getMessage());
|
||||
assertEquals("A name is required when saveState is set to true.", ise.getMessage(),
|
||||
"IllegalStateException name was not set when saveState was true.");
|
||||
}
|
||||
// No IllegalStateException for a name that is not set, should not be thrown since
|
||||
// saveState was false.
|
||||
@@ -153,8 +151,8 @@ public class RepositoryItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException sorts did not match the expected result.", "sorts map is required.",
|
||||
iae.getMessage());
|
||||
assertEquals("sorts map is required.", iae.getMessage(),
|
||||
"IllegalArgumentException sorts did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +164,8 @@ public class RepositoryItemReaderBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"repository is required.", iae.getMessage());
|
||||
assertEquals("repository is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,12 +213,12 @@ public class RepositoryItemReaderBuilderTests {
|
||||
|
||||
private void verifyMultiArgRead(ArgumentCaptor<String> arg1Captor, ArgumentCaptor<String> arg2Captor,
|
||||
ArgumentCaptor<String> arg3Captor, String result) {
|
||||
assertEquals("Result returned from reader was not expected value.", TEST_CONTENT, result);
|
||||
assertEquals("ARG1 for calling method did not match expected result", ARG1, arg1Captor.getValue());
|
||||
assertEquals("ARG2 for calling method did not match expected result", ARG2, arg2Captor.getValue());
|
||||
assertEquals("ARG3 for calling method did not match expected result", ARG3, arg3Captor.getValue());
|
||||
assertEquals("Result Total Pages did not match expected result", 10,
|
||||
this.pageRequestContainer.getValue().getPageSize());
|
||||
assertEquals(TEST_CONTENT, result, "Result returned from reader was not expected value.");
|
||||
assertEquals(ARG1, arg1Captor.getValue(), "ARG1 for calling method did not match expected result");
|
||||
assertEquals(ARG2, arg2Captor.getValue(), "ARG2 for calling method did not match expected result");
|
||||
assertEquals(ARG3, arg3Captor.getValue(), "ARG3 for calling method did not match expected result");
|
||||
assertEquals(10, this.pageRequestContainer.getValue().getPageSize(),
|
||||
"Result Total Pages did not match expected result");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,27 +20,24 @@ import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.data.RepositoryItemWriter;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class RepositoryItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private TestRepository repository;
|
||||
|
||||
@@ -52,8 +49,8 @@ public class RepositoryItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"repository is required.", iae.getMessage());
|
||||
assertEquals("repository is required.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +62,8 @@ public class RepositoryItemWriterBuilderTests {
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
assertEquals("IllegalArgumentException message did not match the expected result.",
|
||||
"methodName must not be empty.", iae.getMessage());
|
||||
assertEquals("methodName must not be empty.", iae.getMessage(),
|
||||
"IllegalArgumentException message did not match the expected result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,8 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
@@ -30,10 +30,10 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Common scenarios for testing {@link ItemReader} implementations which read data from
|
||||
@@ -62,7 +62,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests {
|
||||
|
||||
protected abstract ItemReader<Foo> createItemReader() throws Exception;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void onSetUpInTransaction() throws Exception {
|
||||
reader = createItemReader();
|
||||
executionContext = new ExecutionContext();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2012 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,9 +17,9 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.AbstractItemStreamItemReaderTests;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
@@ -28,21 +28,21 @@ import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public abstract class AbstractDatabaseItemStreamItemReaderTests extends AbstractItemStreamItemReaderTests {
|
||||
|
||||
protected ClassPathXmlApplicationContext ctx;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
initializeContext();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
ctx.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2010-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Generic configuration for testing {@link ItemReader} implementations which read data
|
||||
@@ -26,8 +24,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "data-source-context.xml")
|
||||
@SpringJUnitConfig(locations = "data-source-context.xml")
|
||||
public abstract class AbstractGenericDataSourceItemReaderIntegrationTests
|
||||
extends AbstractDataSourceItemReaderIntegrationTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
@@ -59,14 +59,14 @@ public abstract class AbstractJdbcItemReaderIntegrationTests {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void onSetUp() throws Exception {
|
||||
itemReader = createItemReader();
|
||||
getAsInitializingBean(itemReader).afterPropertiesSet();
|
||||
executionContext = new ExecutionContext();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void onTearDown() throws Exception {
|
||||
getAsDisposableBean(itemReader).destroy();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Jimmy Praet
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,10 +17,10 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
@@ -39,12 +39,12 @@ public abstract class AbstractPagingItemReaderParameterTests {
|
||||
@Autowired
|
||||
protected DataSource dataSource;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
tested = getItemReader();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
((ItemStream) tested).close();
|
||||
}
|
||||
@@ -55,19 +55,19 @@ public abstract class AbstractPagingItemReaderParameterTests {
|
||||
((ItemStream) tested).open(executionContext);
|
||||
|
||||
Foo foo2 = tested.read();
|
||||
Assert.assertEquals(2, foo2.getValue());
|
||||
Assertions.assertEquals(2, foo2.getValue());
|
||||
|
||||
Foo foo3 = tested.read();
|
||||
Assert.assertEquals(3, foo3.getValue());
|
||||
Assertions.assertEquals(3, foo3.getValue());
|
||||
|
||||
Foo foo4 = tested.read();
|
||||
Assert.assertEquals(4, foo4.getValue());
|
||||
Assertions.assertEquals(4, foo4.getValue());
|
||||
|
||||
Foo foo5 = tested.read();
|
||||
Assert.assertEquals(5, foo5.getValue());
|
||||
Assertions.assertEquals(5, foo5.getValue());
|
||||
|
||||
Object o = tested.read();
|
||||
Assert.assertNull(o);
|
||||
Assertions.assertNull(o);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,13 +77,13 @@ public abstract class AbstractPagingItemReaderParameterTests {
|
||||
((ItemStream) tested).open(executionContext);
|
||||
|
||||
Foo foo4 = tested.read();
|
||||
Assert.assertEquals(4, foo4.getValue());
|
||||
Assertions.assertEquals(4, foo4.getValue());
|
||||
|
||||
Foo foo5 = tested.read();
|
||||
Assert.assertEquals(5, foo5.getValue());
|
||||
Assertions.assertEquals(5, foo5.getValue());
|
||||
|
||||
Object o = tested.read();
|
||||
Assert.assertNull(o);
|
||||
Assertions.assertNull(o);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,10 +93,10 @@ public abstract class AbstractPagingItemReaderParameterTests {
|
||||
((ItemStream) tested).open(executionContext);
|
||||
|
||||
Foo foo5 = tested.read();
|
||||
Assert.assertEquals(5, foo5.getValue());
|
||||
Assertions.assertEquals(5, foo5.getValue());
|
||||
|
||||
Object o = tested.read();
|
||||
Assert.assertNull(o);
|
||||
Assertions.assertNull(o);
|
||||
}
|
||||
|
||||
protected String getName() {
|
||||
|
||||
@@ -17,12 +17,13 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
@@ -34,7 +35,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
@@ -66,29 +67,29 @@ public class ExtendedConnectionDataSourceProxyTests {
|
||||
|
||||
Connection con1 = csds.getConnection();
|
||||
Connection con2 = csds.getConnection();
|
||||
assertNotSame("shouldn't be the same connection", con1, con2);
|
||||
assertNotSame(con1, con2, "shouldn't be the same connection");
|
||||
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con1));
|
||||
assertTrue(csds.shouldClose(con1), "should be able to close connection");
|
||||
con1.close();
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con2));
|
||||
assertTrue(csds.shouldClose(con2), "should be able to close connection");
|
||||
con2.close();
|
||||
|
||||
Connection con3 = csds.getConnection();
|
||||
csds.startCloseSuppression(con3);
|
||||
Connection con3_1 = csds.getConnection();
|
||||
assertSame("should be same connection", con3_1, con3);
|
||||
assertFalse("should not be able to close connection", csds.shouldClose(con3));
|
||||
assertSame(con3_1, con3, "should be same connection");
|
||||
assertFalse(csds.shouldClose(con3), "should not be able to close connection");
|
||||
con3_1.close(); // no mock call for this - should be suppressed
|
||||
Connection con3_2 = csds.getConnection();
|
||||
assertSame("should be same connection", con3_2, con3);
|
||||
assertSame(con3_2, con3, "should be same connection");
|
||||
Connection con4 = csds.getConnection();
|
||||
assertNotSame("shouldn't be same connection", con4, con3);
|
||||
assertNotSame(con4, con3, "shouldn't be same connection");
|
||||
csds.stopCloseSuppression(con3);
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con3));
|
||||
assertTrue(csds.shouldClose(con3), "should be able to close connection");
|
||||
con3_1 = null;
|
||||
con3_2 = null;
|
||||
con3.close();
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con4));
|
||||
assertTrue(csds.shouldClose(con4), "should be able to close connection");
|
||||
con4.close();
|
||||
|
||||
}
|
||||
@@ -108,18 +109,18 @@ public class ExtendedConnectionDataSourceProxyTests {
|
||||
Connection con1 = csds.getConnection();
|
||||
csds.startCloseSuppression(con1);
|
||||
Connection con1_1 = csds.getConnection();
|
||||
assertSame("should be same connection", con1_1, con1);
|
||||
assertSame(con1_1, con1, "should be same connection");
|
||||
con1_1.close(); // no mock call for this - should be suppressed
|
||||
Connection con1_2 = csds.getConnection();
|
||||
assertSame("should be same connection", con1_2, con1);
|
||||
assertSame(con1_2, con1, "should be same connection");
|
||||
Connection con2 = csds.getConnection();
|
||||
assertNotSame("shouldn't be same connection", con2, con1);
|
||||
assertNotSame(con2, con1, "shouldn't be same connection");
|
||||
csds.stopCloseSuppression(con1);
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con1));
|
||||
assertTrue(csds.shouldClose(con1), "should be able to close connection");
|
||||
con1_1 = null;
|
||||
con1_2 = null;
|
||||
con1.close();
|
||||
assertTrue("should be able to close connection", csds.shouldClose(con2));
|
||||
assertTrue(csds.shouldClose(con2), "should be able to close connection");
|
||||
con2.close();
|
||||
|
||||
}
|
||||
@@ -227,11 +228,11 @@ public class ExtendedConnectionDataSourceProxyTests {
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void delegateIsRequired() throws Exception {
|
||||
@Test
|
||||
public void delegateIsRequired() {
|
||||
|
||||
ExtendedConnectionDataSourceProxy tested = new ExtendedConnectionDataSourceProxy(null);
|
||||
tested.afterPropertiesSet();
|
||||
assertThrows(IllegalArgumentException.class, tested::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2010 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2013 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.item.database;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.query.Query;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,28 +19,25 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link HibernateCursorItemReader} using {@link StatelessSession}.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "data-source-context.xml")
|
||||
@SpringJUnitConfig(locations = "data-source-context.xml")
|
||||
public class HibernateCursorProjectionItemReaderIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,12 +19,12 @@ package org.springframework.batch.item.database;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,12 @@ import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HibernateItemWriterTests {
|
||||
|
||||
Session currentSession;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
writer = new HibernateItemWriter<>();
|
||||
factory = mock(SessionFactory.class);
|
||||
@@ -68,7 +68,7 @@ public class HibernateItemWriterTests {
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// expected
|
||||
assertTrue("Wrong message for exception: " + e.getMessage(), e.getMessage().indexOf("SessionFactory") >= 0);
|
||||
assertTrue(e.getMessage().contains("SessionFactory"), "Wrong message for exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.UncategorizedSQLException;
|
||||
@@ -49,7 +49,7 @@ public class JdbcBatchItemWriterClassicTests {
|
||||
|
||||
private PreparedStatement ps;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
ps = mock(PreparedStatement.class);
|
||||
jdbcTemplate = new JdbcTemplate() {
|
||||
@@ -91,8 +91,8 @@ public class JdbcBatchItemWriterClassicTests {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message does not contain ' NamedParameterJdbcTemplate'.",
|
||||
message.indexOf("NamedParameterJdbcTemplate") >= 0);
|
||||
assertTrue(message.contains("NamedParameterJdbcTemplate"),
|
||||
"Message does not contain ' NamedParameterJdbcTemplate'.");
|
||||
}
|
||||
writer.setJdbcTemplate(new NamedParameterJdbcTemplate(jdbcTemplate));
|
||||
try {
|
||||
@@ -102,7 +102,7 @@ public class JdbcBatchItemWriterClassicTests {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
String message = e.getMessage().toLowerCase();
|
||||
assertTrue("Message does not contain 'sql'.", message.indexOf("sql") >= 0);
|
||||
assertTrue(message.contains("sql"), "Message does not contain 'sql'.");
|
||||
}
|
||||
writer.setSql("select * from foo where id = ?");
|
||||
try {
|
||||
@@ -112,8 +112,8 @@ public class JdbcBatchItemWriterClassicTests {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message does not contain 'ItemPreparedStatementSetter'.",
|
||||
message.indexOf("ItemPreparedStatementSetter") >= 0);
|
||||
assertTrue(message.contains("ItemPreparedStatementSetter"),
|
||||
"Message does not contain 'ItemPreparedStatementSetter'.");
|
||||
}
|
||||
writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter<String>() {
|
||||
@Override
|
||||
@@ -144,7 +144,7 @@ public class JdbcBatchItemWriterClassicTests {
|
||||
catch (EmptyResultDataAccessException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Wrong message: " + message, message.indexOf("did not update") >= 0);
|
||||
assertTrue(message.contains("did not update"), "Wrong message: " + message);
|
||||
}
|
||||
assertEquals(2, list.size());
|
||||
assertTrue(list.contains("SQL"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,8 @@ import java.util.Map;
|
||||
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -30,9 +30,9 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -82,7 +82,7 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
namedParameterJdbcOperations = mock(NamedParameterJdbcOperations.class);
|
||||
writer.setSql(sql);
|
||||
@@ -106,8 +106,8 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Message does not contain 'NamedParameterJdbcTemplate'.",
|
||||
message.contains("NamedParameterJdbcTemplate"));
|
||||
assertTrue(message.contains("NamedParameterJdbcTemplate"),
|
||||
"Message does not contain 'NamedParameterJdbcTemplate'.");
|
||||
}
|
||||
writer.setJdbcTemplate(namedParameterJdbcOperations);
|
||||
try {
|
||||
@@ -117,7 +117,7 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
String message = e.getMessage().toLowerCase();
|
||||
assertTrue("Message does not contain 'sql'.", message.contains("sql"));
|
||||
assertTrue(message.contains("sql"), "Message does not contain 'sql'.");
|
||||
}
|
||||
writer.setSql("select * from foo where id = :id");
|
||||
|
||||
@@ -189,7 +189,7 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
catch (EmptyResultDataAccessException e) {
|
||||
// expected
|
||||
String message = e.getMessage();
|
||||
assertTrue("Wrong message: " + message, message.contains("did not update"));
|
||||
assertTrue(message.contains("did not update"), "Wrong message: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ReaderNotOpenException;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests {
|
||||
|
||||
@Override
|
||||
@@ -63,10 +62,10 @@ public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamI
|
||||
reader.open(new ExecutionContext());
|
||||
}
|
||||
|
||||
@Test(expected = ReaderNotOpenException.class)
|
||||
@Test
|
||||
public void testReadBeforeOpen() throws Exception {
|
||||
tested = getItemReader();
|
||||
tested.read();
|
||||
assertThrows(ReaderNotOpenException.class, tested::read);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
@@ -32,14 +30,13 @@ import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class JdbcCursorItemReaderConfigTests {
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,17 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Tests for {@link JdbcCursorItemReader}
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JdbcCursorItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2021 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -36,10 +36,9 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
|
||||
@@ -47,12 +46,10 @@ import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
public class JdbcPagingItemReaderAsyncTests {
|
||||
|
||||
/**
|
||||
@@ -77,7 +74,7 @@ public class JdbcPagingItemReaderAsyncTests {
|
||||
|
||||
private int maxId;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
Integer maxIdResult = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
|
||||
@@ -88,7 +85,7 @@ public class JdbcPagingItemReaderAsyncTests {
|
||||
assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,14 +21,12 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -37,8 +35,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Michael Minella
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = "/org/springframework/batch/item/database/JdbcPagingItemReaderParameterTests-context.xml")
|
||||
public class JdbcPagingItemReaderClassicParameterTests extends AbstractJdbcPagingItemReaderParameterTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,6 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.batch.item.AbstractItemStreamItemReaderTests;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
@@ -31,16 +29,14 @@ import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@SpringJUnitConfig
|
||||
public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReaderTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2018 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,21 +15,18 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@SpringJUnitConfig
|
||||
public class JdbcPagingItemReaderConfigTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 the original author or authors.
|
||||
* Copyright 2021-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,24 +15,21 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.SingleColumnRowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
public class JdbcPagingItemReaderEmptyResultSetTests {
|
||||
|
||||
private static final int PAGE_SIZE = 2;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,15 +21,13 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -37,12 +35,12 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
@SpringJUnitConfig(
|
||||
locations = "/org/springframework/batch/item/database/JdbcPagingItemReaderParameterTests-context.xml")
|
||||
@Ignore("This test fails when integration tests are skipped..") // FIXME make this test
|
||||
// independent of other
|
||||
// tests
|
||||
@Disabled("This test fails when integration tests are skipped..") // FIXME make this test
|
||||
// independent of
|
||||
// other
|
||||
// tests
|
||||
public class JdbcPagingItemReaderNamedParameterTests extends AbstractJdbcPagingItemReaderParameterTests {
|
||||
|
||||
// force jumpToItemQuery in JdbcPagingItemReader.doJumpToPage(int)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,23 +26,21 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider;
|
||||
import org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -50,8 +48,7 @@ import static org.junit.Assert.assertTrue;
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
|
||||
public class JdbcPagingQueryIntegrationTests {
|
||||
|
||||
@@ -68,7 +65,7 @@ public class JdbcPagingQueryIntegrationTests {
|
||||
|
||||
private int pageSize = 2;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void testInit() {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
String[] names = { "Foo", "Bar", "Baz", "Foo", "Bar", "Baz", "Foo", "Bar", "Baz" };
|
||||
@@ -82,7 +79,7 @@ public class JdbcPagingQueryIntegrationTests {
|
||||
assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "T_FOOS");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -30,11 +30,10 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
@@ -44,8 +43,7 @@ import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
/**
|
||||
@@ -53,8 +51,7 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
* @author Michael Minella
|
||||
* @since 2.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JdbcPagingItemReaderCommonTests-context.xml")
|
||||
public class JdbcPagingRestartIntegrationTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(JdbcPagingRestartIntegrationTests.class);
|
||||
@@ -70,7 +67,7 @@ public class JdbcPagingRestartIntegrationTests {
|
||||
|
||||
private int pageSize = 2;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
|
||||
@@ -81,13 +78,13 @@ public class JdbcPagingRestartIntegrationTests {
|
||||
assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME
|
||||
@Disabled // FIXME
|
||||
public void testReaderFromStart() throws Exception {
|
||||
|
||||
ItemReader<Foo> reader = getItemReader();
|
||||
@@ -110,7 +107,7 @@ public class JdbcPagingRestartIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME
|
||||
@Disabled // FIXME
|
||||
public void testReaderOnRestart() throws Exception {
|
||||
|
||||
ItemReader<Foo> reader = getItemReader();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.item.database.JdbcParameterUtils;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 the original author or authors.
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,10 +20,9 @@ import java.util.List;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.sample.Person;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,16 +37,14 @@ import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager
|
||||
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = JpaItemWriterIntegrationTests.JpaConfiguration.class)
|
||||
@SpringJUnitConfig(classes = JpaItemWriterIntegrationTests.JpaConfiguration.class)
|
||||
@Transactional
|
||||
@DirtiesContext
|
||||
public class JpaItemWriterIntegrationTests {
|
||||
@@ -58,12 +55,12 @@ public class JpaItemWriterIntegrationTests {
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
this.jdbcTemplate.update("create table person (id int not null primary key, name varchar(32))");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
JdbcTestUtils.dropTables(this.jdbcTemplate, "person");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -29,8 +29,8 @@ import java.util.List;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class JpaItemWriterTests {
|
||||
|
||||
JpaItemWriter<Object> writer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
@@ -65,8 +65,8 @@ public class JpaItemWriterTests {
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
assertTrue("Wrong message for exception: " + e.getMessage(),
|
||||
e.getMessage().indexOf("EntityManagerFactory") >= 0);
|
||||
assertTrue(e.getMessage().contains("EntityManagerFactory"),
|
||||
"Wrong message for exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -24,13 +24,11 @@ import java.util.List;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.Query;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.database.orm.JpaNativeQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -38,8 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "JpaPagingItemReaderCommonTests-context.xml" })
|
||||
@SpringJUnitConfig(locations = { "JpaPagingItemReaderCommonTests-context.xml" })
|
||||
public class JpaNativeQueryProviderIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2021 the original author or authors.
|
||||
* Copyright 2009-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -33,20 +33,17 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JpaPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JpaPagingItemReaderCommonTests-context.xml")
|
||||
public class JpaPagingItemReaderAsyncTests {
|
||||
|
||||
/**
|
||||
@@ -69,7 +66,7 @@ public class JpaPagingItemReaderAsyncTests {
|
||||
|
||||
private int maxId;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class);
|
||||
@@ -79,7 +76,7 @@ public class JpaPagingItemReaderAsyncTests {
|
||||
assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,17 +17,14 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.AbstractItemStreamItemReaderTests;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@SpringJUnitConfig
|
||||
public class JpaPagingItemReaderCommonTests extends AbstractItemStreamItemReaderTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 the original author or authors.
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,13 +17,10 @@ package org.springframework.batch.item.database;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.batch.item.database.orm.JpaNamedQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Integration Test for {@link JpaPagingItemReader} and {@link JpaNamedQueryProvider}.
|
||||
@@ -31,8 +28,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Parikshit Dutta
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "JpaPagingItemReaderCommonTests-context.xml" })
|
||||
@SpringJUnitConfig(locations = { "JpaPagingItemReaderCommonTests-context.xml" })
|
||||
public class JpaPagingItemReaderNamedQueryIntegrationTests extends AbstractPagingItemReaderParameterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 the original author or authors.
|
||||
* Copyright 2010-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.Collections;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.database.orm.JpaNativeQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,8 +32,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager;
|
||||
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
@@ -42,8 +40,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = JpaPagingItemReaderNativeQueryIntegrationTests.JpaConfiguration.class)
|
||||
@SpringJUnitConfig(classes = JpaPagingItemReaderNativeQueryIntegrationTests.JpaConfiguration.class)
|
||||
public class JpaPagingItemReaderNativeQueryIntegrationTests extends AbstractPagingItemReaderParameterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2021 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,14 +19,11 @@ import java.util.Collections;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "JpaPagingItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "JpaPagingItemReaderCommonTests-context.xml")
|
||||
public class JpaPagingItemReaderParameterTests extends AbstractPagingItemReaderParameterTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,26 +15,23 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.data.RepositoryItemReader;
|
||||
import org.springframework.batch.item.sample.books.Author;
|
||||
import org.springframework.batch.item.sample.books.Book;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "RepositoryItemReaderCommonTests-context.xml")
|
||||
@SpringJUnitConfig(locations = "RepositoryItemReaderCommonTests-context.xml")
|
||||
@Transactional
|
||||
public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
@@ -43,7 +40,7 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
@Autowired
|
||||
private RepositoryItemReader<Author> reader;
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void reinitializeReader() {
|
||||
reader.close();
|
||||
}
|
||||
@@ -56,9 +53,9 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
assertNotNull(author);
|
||||
final List<Book> books = author.getBooks();
|
||||
assertEquals("Books list size must be = 2", 2, books.size());
|
||||
assertEquals("First book must be author 1 - book 1", "author 1 - book 1", books.get(0).getName());
|
||||
assertEquals("Second book must be author 1 - book 2", "author 1 - book 2", books.get(1).getName());
|
||||
assertEquals(2, books.size(), "Books list size must be = 2");
|
||||
assertEquals("author 1 - book 1", books.get(0).getName(), "First book must be author 1 - book 1");
|
||||
assertEquals("author 1 - book 2", books.get(1).getName(), "Second book must be author 1 - book 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,9 +67,9 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
assertNotNull(author);
|
||||
final List<Book> books = author.getBooks();
|
||||
assertEquals("Books list size must be = 2", 2, books.size());
|
||||
assertEquals("First book must be author 2 - book 1", "author 2 - book 1", books.get(0).getName());
|
||||
assertEquals("Second book must be author 2 - book 2", "author 2 - book 2", books.get(1).getName());
|
||||
assertEquals(2, books.size(), "Books list size must be = 2");
|
||||
assertEquals("author 2 - book 1", books.get(0).getName(), "First book must be author 2 - book 1");
|
||||
assertEquals("author 2 - book 2", books.get(1).getName(), "Second book must be author 2 - book 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,9 +82,9 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
assertNotNull(author);
|
||||
final List<Book> books = author.getBooks();
|
||||
assertEquals("Books list size must be = 2", 2, books.size());
|
||||
assertEquals("First book must be author 3 - book 1", "author 3 - book 1", books.get(0).getName());
|
||||
assertEquals("Second book must be author 3 - book 2", "author 3 - book 2", books.get(1).getName());
|
||||
assertEquals(2, books.size(), "Books list size must be = 2");
|
||||
assertEquals("author 3 - book 1", books.get(0).getName(), "First book must be author 3 - book 1");
|
||||
assertEquals("author 3 - book 2", books.get(1).getName(), "Second book must be author 3 - book 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,9 +97,9 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
assertNotNull(author);
|
||||
final List<Book> books = author.getBooks();
|
||||
assertEquals("Books list size must be = 2", 2, books.size());
|
||||
assertEquals("First book must be author 2 - book 1", "author 2 - book 1", books.get(0).getName());
|
||||
assertEquals("Second book must be author 2 - book 2", "author 2 - book 2", books.get(1).getName());
|
||||
assertEquals(2, books.size(), "Books list size must be = 2");
|
||||
assertEquals("author 2 - book 1", books.get(0).getName(), "First book must be author 2 - book 1");
|
||||
assertEquals("author 2 - book 2", books.get(1).getName(), "Second book must be author 2 - book 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,9 +113,9 @@ public class RepositoryItemReaderIntegrationTests {
|
||||
|
||||
assertNotNull(author);
|
||||
final List<Book> books = author.getBooks();
|
||||
assertEquals("Books list size must be = 2", 2, books.size());
|
||||
assertEquals("First book must be author 3 - book 1", "author 3 - book 1", books.get(0).getName());
|
||||
assertEquals("Second book must be author 3 - book 2", "author 3 - book 2", books.get(1).getName());
|
||||
assertEquals(2, books.size(), "Books list size must be = 2");
|
||||
assertEquals("author 3 - book 1", books.get(0).getName(), "First book must be author 3 - book 1");
|
||||
assertEquals("author 3 - book 2", books.get(1).getName(), "Second book must be author 3 - book 2");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
* Copyright 2010-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hsqldb.types.Types;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ReaderNotOpenException;
|
||||
@@ -30,7 +28,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.SqlParameter;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests {
|
||||
|
||||
@Override
|
||||
@@ -82,11 +81,11 @@ public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemSt
|
||||
reader.open(new ExecutionContext());
|
||||
}
|
||||
|
||||
@Test(expected = ReaderNotOpenException.class)
|
||||
@Test
|
||||
public void testReadBeforeOpen() throws Exception {
|
||||
testedAsStream().close();
|
||||
tested = getItemReader();
|
||||
tested.read();
|
||||
assertThrows(ReaderNotOpenException.class, tested::read);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
* Copyright 2010-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "stored-procedure-context.xml")
|
||||
@SpringJUnitConfig(locations = "stored-procedure-context.xml")
|
||||
public class StoredProcedureItemReaderIntegrationTests extends AbstractDataSourceItemReaderIntegrationTests {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,9 +28,7 @@ import java.sql.SQLException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hsqldb.types.Types;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.SqlParameter;
|
||||
@@ -40,7 +38,6 @@ import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class StoredprocedureItemReaderConfigTests {
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,9 +20,9 @@ import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.HibernateCursorItemReader;
|
||||
@@ -39,9 +39,9 @@ import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -52,13 +52,13 @@ public class HibernateCursorItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
|
||||
this.sessionFactory = (SessionFactory) context.getBean("sessionFactory");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,38 +20,35 @@ import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.database.HibernateItemWriter;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class HibernateItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Mock
|
||||
private Session session;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
when(this.sessionFactory.getCurrentSession()).thenReturn(this.session);
|
||||
lenient().when(this.sessionFactory.getCurrentSession()).thenReturn(this.session);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +91,7 @@ public class HibernateItemWriterBuilderTests {
|
||||
fail("sessionFactory is required");
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
assertEquals("Incorrect message", "SessionFactory must be provided", ise.getMessage());
|
||||
assertEquals("SessionFactory must be provided", ise.getMessage(), "Incorrect message");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,9 +20,9 @@ import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.HibernateItemReaderHelper;
|
||||
@@ -41,9 +41,9 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -55,14 +55,14 @@ public class HibernatePagingItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
HibernatePagingItemReaderBuilderTests.TestDataSourceConfiguration.class);
|
||||
this.sessionFactory = (SessionFactory) context.getBean("sessionFactory");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,9 +21,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.JdbcBatchItemWriter;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -43,9 +43,10 @@ import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -56,13 +57,13 @@ public class JdbcBatchItemWriterBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
|
||||
this.dataSource = (DataSource) context.getBean("dataSource");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
@@ -120,8 +121,8 @@ public class JdbcBatchItemWriterBuilderTests {
|
||||
verifyWrite();
|
||||
}
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
public void testAssertUpdates() throws Exception {
|
||||
@Test
|
||||
public void testAssertUpdates() {
|
||||
JdbcBatchItemWriter<Foo> writer = new JdbcBatchItemWriterBuilder<Foo>().beanMapped().dataSource(this.dataSource)
|
||||
.sql("UPDATE FOO SET second = :second, third = :third WHERE first = :first").assertUpdates(true)
|
||||
.build();
|
||||
@@ -132,7 +133,7 @@ public class JdbcBatchItemWriterBuilderTests {
|
||||
|
||||
items.add(new Foo(1, "two", "three"));
|
||||
|
||||
writer.write(items);
|
||||
assertThrows(EmptyResultDataAccessException.class, () -> writer.write(items));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,9 +21,9 @@ import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JdbcCursorItemReader;
|
||||
@@ -39,10 +39,10 @@ import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -56,13 +56,13 @@ public class JdbcCursorItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
|
||||
this.dataSource = (DataSource) context.getBean("dataSource");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JdbcPagingItemReader;
|
||||
@@ -39,10 +39,10 @@ import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -54,13 +54,13 @@ public class JdbcPagingItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
|
||||
this.dataSource = (DataSource) context.getBean("dataSource");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.util.Map;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JpaCursorItemReader;
|
||||
@@ -44,9 +44,9 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
@@ -57,14 +57,14 @@ public class JpaCursorItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
JpaCursorItemReaderBuilderTests.TestDataSourceConfiguration.class);
|
||||
this.entityManagerFactory = (EntityManagerFactory) context.getBean("entityManagerFactory");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,42 +20,39 @@ import java.util.List;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.batch.item.database.JpaItemWriter;
|
||||
import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class JpaItemWriterBuilderTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule rule = MockitoJUnit.rule().silent();
|
||||
|
||||
@Mock
|
||||
private EntityManagerFactory entityManagerFactory;
|
||||
|
||||
@Mock
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
TransactionSynchronizationManager.bindResource(this.entityManagerFactory,
|
||||
new EntityManagerHolder(this.entityManager));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
TransactionSynchronizationManager.unbindResource(this.entityManagerFactory);
|
||||
}
|
||||
@@ -82,7 +79,7 @@ public class JpaItemWriterBuilderTests {
|
||||
fail("Should fail if no EntityManagerFactory is provided");
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
assertEquals("Incorrect message", "EntityManagerFactory must be provided", ise.getMessage());
|
||||
assertEquals("EntityManagerFactory must be provided", ise.getMessage(), "Incorrect message");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,9 +22,9 @@ import java.util.Map;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.database.JpaPagingItemReader;
|
||||
@@ -44,10 +44,10 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -60,14 +60,14 @@ public class JpaPagingItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
JpaPagingItemReaderBuilderTests.TestDataSourceConfiguration.class);
|
||||
this.entityManagerFactory = (EntityManagerFactory) context.getBean("entityManagerFactory");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
|
||||
@@ -17,9 +17,9 @@ package org.springframework.batch.item.database.builder;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import test.jdbc.datasource.DataSourceInitializer;
|
||||
import test.jdbc.datasource.DerbyDataSourceFactoryBean;
|
||||
import test.jdbc.datasource.DerbyShutdownBean;
|
||||
@@ -39,10 +39,10 @@ import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Minella
|
||||
@@ -54,13 +54,13 @@ public class StoredProcedureItemReaderBuilderTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.context = new AnnotationConfigApplicationContext(TestDataSourceConfiguration.class);
|
||||
this.dataSource = (DataSource) this.context.getBean("dataSource");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 the original author or authors.
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,12 +19,12 @@ import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.database.Order;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public abstract class AbstractSqlPagingQueryProviderTests {
|
||||
|
||||
protected int pageSize;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
if (pagingQueryProvider == null) {
|
||||
throw new IllegalArgumentException("pagingQueryProvider can't be null");
|
||||
@@ -55,14 +55,14 @@ public abstract class AbstractSqlPagingQueryProviderTests {
|
||||
@Test
|
||||
public void testQueryContainsSortKey() {
|
||||
String s = pagingQueryProvider.generateFirstPageQuery(pageSize).toLowerCase();
|
||||
assertTrue("Wrong query: " + s, s.contains("id asc"));
|
||||
assertTrue(s.contains("id asc"), "Wrong query: " + s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryContainsSortKeyDesc() {
|
||||
pagingQueryProvider.getSortKeys().put("id", Order.DESCENDING);
|
||||
String s = pagingQueryProvider.generateFirstPageQuery(pageSize).toLowerCase();
|
||||
assertTrue("Wrong query: " + s, s.contains("id desc"));
|
||||
assertTrue(s.contains("id desc"), "Wrong query: " + s);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,13 +21,14 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
* @author Will Schipp
|
||||
*/
|
||||
public class ColumnMapExecutionContextRowMapperTests extends TestCase {
|
||||
public class ColumnMapExecutionContextRowMapperTests {
|
||||
|
||||
private ColumnMapItemPreparedStatementSetter mapper;
|
||||
|
||||
@@ -35,10 +36,8 @@ public class ColumnMapExecutionContextRowMapperTests extends TestCase {
|
||||
|
||||
private PreparedStatement ps;
|
||||
|
||||
@Override
|
||||
@BeforeEach
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
ps = mock(PreparedStatement.class);
|
||||
mapper = new ColumnMapItemPreparedStatementSetter();
|
||||
|
||||
@@ -47,11 +46,13 @@ public class ColumnMapExecutionContextRowMapperTests extends TestCase {
|
||||
key.put("2", Integer.valueOf(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateExecutionContextFromEmptyKeys() throws Exception {
|
||||
|
||||
mapper.setValues(new HashMap<>(), ps);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSetter() throws Exception {
|
||||
|
||||
ps.setObject(1, Integer.valueOf(1));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
|
||||
@@ -17,10 +17,13 @@ package org.springframework.batch.item.database.support;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jdbc.support.incrementer.Db2LuwMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.Db2MainframeMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
|
||||
@@ -29,7 +32,6 @@ import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
|
||||
|
||||
/**
|
||||
@@ -38,23 +40,17 @@ import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
|
||||
* @author Drummond Dawson
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
public class DefaultDataFieldMaxValueIncrementerFactoryTests {
|
||||
|
||||
private DefaultDataFieldMaxValueIncrementerFactory factory;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
@BeforeEach
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedDatabaseType() {
|
||||
assertTrue(factory.isSupportedIncrementerType("db2"));
|
||||
assertTrue(factory.isSupportedIncrementerType("db2zos"));
|
||||
@@ -69,10 +65,12 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
assertTrue(factory.isSupportedIncrementerType("hana"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsupportedDatabaseType() {
|
||||
assertFalse(factory.isSupportedIncrementerType("invalidtype"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidDatabaseType() {
|
||||
try {
|
||||
factory.getIncrementer("invalidtype", "NAME");
|
||||
@@ -83,6 +81,7 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullIncrementerName() {
|
||||
try {
|
||||
factory.getIncrementer("db2", null);
|
||||
@@ -93,47 +92,58 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDb2() {
|
||||
assertTrue(factory.getIncrementer("db2", "NAME") instanceof Db2LuwMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDb2zos() {
|
||||
assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof Db2MainframeMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMysql() {
|
||||
assertTrue(factory.getIncrementer("mysql", "NAME") instanceof MySQLMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOracle() {
|
||||
factory.setIncrementerColumnName("ID");
|
||||
assertTrue(factory.getIncrementer("oracle", "NAME") instanceof OracleSequenceMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerby() {
|
||||
assertTrue(factory.getIncrementer("derby", "NAME") instanceof DerbyMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHsql() {
|
||||
assertTrue(factory.getIncrementer("hsql", "NAME") instanceof HsqlMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostgres() {
|
||||
assertTrue(factory.getIncrementer("postgres", "NAME") instanceof PostgresSequenceMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMsSqlServer() {
|
||||
assertTrue(factory.getIncrementer("sqlserver", "NAME") instanceof SqlServerSequenceMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSybase() {
|
||||
assertTrue(factory.getIncrementer("sybase", "NAME") instanceof SybaseMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqlite() {
|
||||
assertTrue(factory.getIncrementer("sqlite", "NAME") instanceof SqliteMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHana() {
|
||||
assertTrue(factory.getIncrementer("hana", "NAME") instanceof HanaSequenceMaxValueIncrementer);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2012 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,17 +17,17 @@ package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.database.Order;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
|
||||
@@ -86,7 +86,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
public void testGenerateFirstPageQuery() {
|
||||
String sql = "SELECT * FROM ( SELECT TMP_ORDERED.*, ROW_NUMBER() OVER () AS ROW_NUMBER FROM (SELECT id, name, age FROM foo WHERE bar = 1 ) AS TMP_ORDERED) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER <= 100 ORDER BY id ASC";
|
||||
String s = pagingQueryProvider.generateFirstPageQuery(pageSize);
|
||||
Assert.assertEquals(sql, s);
|
||||
Assertions.assertEquals(sql, s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +94,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
public void testGenerateRemainingPagesQuery() {
|
||||
String sql = "SELECT * FROM ( SELECT TMP_ORDERED.*, ROW_NUMBER() OVER () AS ROW_NUMBER FROM (SELECT id, name, age FROM foo WHERE bar = 1 ) AS TMP_ORDERED) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER <= 100 AND ((id > ?)) ORDER BY id ASC";
|
||||
String s = pagingQueryProvider.generateRemainingPagesQuery(pageSize);
|
||||
Assert.assertEquals(sql, s);
|
||||
Assertions.assertEquals(sql, s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,7 +102,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
public void testGenerateJumpToItemQuery() {
|
||||
String sql = "SELECT id FROM ( SELECT id, ROW_NUMBER() OVER () AS ROW_NUMBER FROM (SELECT id, name, age FROM foo WHERE bar = 1 ) AS TMP_ORDERED) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER = 100 ORDER BY id ASC";
|
||||
String s = pagingQueryProvider.generateJumpToItemQuery(145, pageSize);
|
||||
Assert.assertEquals(sql, s);
|
||||
Assertions.assertEquals(sql, s);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,7 +110,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
public void testGenerateJumpToItemQueryForFirstPage() {
|
||||
String sql = "SELECT id FROM ( SELECT id, ROW_NUMBER() OVER () AS ROW_NUMBER FROM (SELECT id, name, age FROM foo WHERE bar = 1 ) AS TMP_ORDERED) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER = 1 ORDER BY id ASC";
|
||||
String s = pagingQueryProvider.generateJumpToItemQuery(45, pageSize);
|
||||
Assert.assertEquals(sql, s);
|
||||
Assertions.assertEquals(sql, s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
@Override
|
||||
public void testQueryContainsSortKey() {
|
||||
String s = pagingQueryProvider.generateFirstPageQuery(pageSize).toLowerCase();
|
||||
assertTrue("Wrong query: " + s, s.contains("id asc"));
|
||||
assertTrue(s.contains("id asc"), "Wrong query: " + s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ public class DerbyPagingQueryProviderTests extends AbstractSqlPagingQueryProvide
|
||||
public void testQueryContainsSortKeyDesc() {
|
||||
pagingQueryProvider.getSortKeys().put("id", Order.DESCENDING);
|
||||
String s = pagingQueryProvider.generateFirstPageQuery(pageSize).toLowerCase();
|
||||
assertTrue("Wrong query: " + s, s.contains("id desc"));
|
||||
assertTrue(s.contains("id desc"), "Wrong query: " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,19 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.h2.engine.Mode.ModeEnum;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
import org.springframework.batch.item.database.Order;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -36,24 +33,18 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Henning Pöttker
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class H2PagingQueryProviderIntegrationTests {
|
||||
|
||||
private final String compatibilityMode;
|
||||
|
||||
public H2PagingQueryProviderIntegrationTests(String compatibilityMode) {
|
||||
this.compatibilityMode = compatibilityMode;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryProvider() {
|
||||
@ParameterizedTest
|
||||
@EnumSource(ModeEnum.class)
|
||||
void testQueryProvider(ModeEnum compatibilityMode) {
|
||||
String connectionUrl = String.format("jdbc:h2:mem:%s;MODE=%s", UUID.randomUUID(), compatibilityMode);
|
||||
DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", "");
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
@@ -74,11 +65,11 @@ public class H2PagingQueryProviderIntegrationTests {
|
||||
queryProvider.setSortKeys(sortKeys);
|
||||
|
||||
List<String> firstPage = jdbcTemplate.queryForList(queryProvider.generateFirstPageQuery(2), String.class);
|
||||
assertArrayEquals("firstPage", new String[] { "Spring", "Batch" }, firstPage.toArray());
|
||||
assertArrayEquals(new String[] { "Spring", "Batch" }, firstPage.toArray(), "firstPage");
|
||||
|
||||
List<String> secondPage = jdbcTemplate.queryForList(queryProvider.generateRemainingPagesQuery(2),
|
||||
String.class, 2);
|
||||
assertArrayEquals("secondPage", new String[] { "Infrastructure" }, secondPage.toArray());
|
||||
assertArrayEquals(new String[] { "Infrastructure" }, secondPage.toArray(), "secondPage");
|
||||
|
||||
Integer secondItem = jdbcTemplate.queryForObject(queryProvider.generateJumpToItemQuery(3, 2),
|
||||
Integer.class);
|
||||
@@ -86,10 +77,4 @@ public class H2PagingQueryProviderIntegrationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() throws Exception {
|
||||
return Arrays.stream(org.h2.engine.Mode.ModeEnum.values()).map(mode -> new Object[] { mode.toString() })
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.batch.item.database.support;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.Order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Jonathan Bregler
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,25 +25,22 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.batch.item.database.orm.HibernateNativeQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Anatoly Polinsky
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "../data-source-context.xml")
|
||||
@SpringJUnitConfig(locations = "../data-source-context.xml")
|
||||
public class HibernateNativeQueryProviderIntegrationTests {
|
||||
|
||||
protected DataSource dataSource;
|
||||
@@ -62,7 +59,7 @@ public class HibernateNativeQueryProviderIntegrationTests {
|
||||
hibernateQueryProvider.setEntityClass(Foo.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,11 @@ package org.springframework.batch.item.database.support;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.orm.HibernateNativeQueryProvider;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.batch.item.database.support;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.orm.JpaNativeQueryProvider;
|
||||
import org.springframework.batch.item.sample.Foo;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,11 +18,11 @@ package org.springframework.batch.item.database.support;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.batch.item.database.Order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user