DATAGEODE-4 - Polish.
This commit is contained in:
@@ -10,9 +10,10 @@
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -27,20 +27,20 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The AnimalRepositoryTest class is a test suite of test cases testing the functionality behind PR #55 involving
|
||||
* persisting application domain object/entities to multiple Regions in GemFire's Cache.
|
||||
* Integration test testing the functionality behind PR #55 involving persisting application domain object/entities
|
||||
* to multiple Regions in a GemFire Cache.
|
||||
*
|
||||
* @author Stuart Williams
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.4.0
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @link https://github.com/spring-projects/spring-data-gemfire/pull/55
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class AnimalRepositoryTest {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class AnimalRepositoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityStoredInMultipleRegions() {
|
||||
public void entityStoredInMultipleRegionsIsSuccessful() {
|
||||
Animal felix = newAnimal(1, "Felix");
|
||||
Animal leo = newAnimal(2, "Leo");
|
||||
Animal cerberus = newAnimal(3, "Cerberus");
|
||||
|
||||
@@ -39,15 +39,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*/
|
||||
public class IncompatibleRegionKeyEntityIdAnimalRepositoryTest {
|
||||
|
||||
protected static final String APPLICATION_CONTEXT_CONFIG_LOCATION = String.format("%1$s%2$s%1$s%3$s",
|
||||
private static final String APPLICATION_CONTEXT_CONFIG_LOCATION = String.format("%1$s%2$s%1$s%3$s",
|
||||
File.separator, AnimalRepositoryTest.class.getPackage().getName().replace('.', File.separatorChar),
|
||||
"IncompatibleRegionKeyEntityIdAnimalRepositoryTest-context.xml");
|
||||
String.format("%s-context.xml", IncompatibleRegionKeyEntityIdAnimalRepositoryTest.class.getSimpleName()));
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void storeAnimalHavingLongIdInRabbitsRegionWithStringKey() {
|
||||
try {
|
||||
ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
APPLICATION_CONTEXT_CONFIG_LOCATION);
|
||||
ConfigurableApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext(APPLICATION_CONTEXT_CONFIG_LOCATION);
|
||||
|
||||
applicationContext.getBean(RabbitRepository.class);
|
||||
}
|
||||
// NOTE the ClassCastException thrown from GemFire is unexpected; this is not correct and the identifying type
|
||||
@@ -62,8 +63,9 @@ public class IncompatibleRegionKeyEntityIdAnimalRepositoryTest {
|
||||
catch (BeanCreationException expected) {
|
||||
//expected.printStackTrace(System.err);
|
||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
||||
assertEquals(String.format("The Region referenced only supports keys of type %1$s, but the entity to be stored has an id of type %2$s",
|
||||
assertEquals(String.format("The Region referenced only supports keys of type [%1$s], but the entity to be stored has an id of type [%2$s]",
|
||||
String.class.getName(), Long.class.getName()), expected.getCause().getMessage());
|
||||
|
||||
throw (IllegalArgumentException) expected.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*/
|
||||
public class PlantRepositoryTest {
|
||||
|
||||
protected static final String APPLICATION_CONTEXT_CONFIG_LOCATION = String.format("%1$s%2$s%1$s%3$s",
|
||||
private static final String APPLICATION_CONTEXT_CONFIG_LOCATION = String.format("%1$s%2$s%1$s%3$s",
|
||||
File.separator, PlantRepositoryTest.class.getPackage().getName().replace('.', File.separatorChar),
|
||||
"PlantRepositoryTest-context.xml");
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void storePlantHavingStringIdInPlantsRegionWithLongKey() {
|
||||
try {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
APPLICATION_CONTEXT_CONFIG_LOCATION);
|
||||
ConfigurableApplicationContext context =
|
||||
new ClassPathXmlApplicationContext(APPLICATION_CONTEXT_CONFIG_LOCATION);
|
||||
|
||||
context.getBean(PlantRepository.class);
|
||||
}
|
||||
// NOTE technically, the IllegalArgumentException for incompatible Region 'Key' and Entity ID is thrown
|
||||
@@ -54,8 +55,9 @@ public class PlantRepositoryTest {
|
||||
catch (BeanCreationException expected) {
|
||||
//expected.printStackTrace(System.err);
|
||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
||||
assertEquals(String.format("The Region referenced only supports keys of type %1$s, but the entity to be stored has an id of type %2$s",
|
||||
assertEquals(String.format("The Region referenced only supports keys of type [%1$s], but the entity to be stored has an id of type [%2$s]",
|
||||
Long.class.getName(), String.class.getName()), expected.getCause().getMessage());
|
||||
|
||||
throw (IllegalArgumentException) expected.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -34,11 +37,10 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.repository.Wrapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The SubRegionRepositoryTest class is a test suite of test cases testing the use of GemFire Repositories on GemFire
|
||||
* Cache Subregions.
|
||||
* Integration tests testing the use of GemFire Repositories on GemFire Cache Subregions.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -53,8 +55,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @link https://jira.springsource.org/browse/SGF-252
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("subregionRepository.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class SubRegionRepositoryIntegrationTest {
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ public class GemfireRepositoryFactoryUnitTests {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage(String.format(
|
||||
"The Region referenced only supports keys of type %1$s, but the entity to be stored has an id of type %2$s",
|
||||
"The Region referenced only supports keys of type [%1$s], but the entity to be stored has an id of type [%2$s]",
|
||||
String.class.getName(), Long.class.getName()));
|
||||
|
||||
gemfireRepositoryFactory.getTemplate(mockRepositoryMetadata);
|
||||
@@ -248,7 +248,7 @@ public class GemfireRepositoryFactoryUnitTests {
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage(String.format(
|
||||
"No Region 'People' found for domain class %s; Make sure you have configured a GemFire Region of that name in your application context",
|
||||
"No Region [People] was found for domain class [%s]; Make sure you have configured a GemFire Region of that name in your application context",
|
||||
Person.class.getName()));
|
||||
|
||||
gemfireRepositoryFactory.getTemplate(mockRepositoryMetadata);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -58,7 +58,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@SuppressWarnings("unused")
|
||||
public class SimpleGemfireRepositoryIntegrationTests {
|
||||
|
||||
protected static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||
|
||||
@Autowired
|
||||
private GemfireTemplate template;
|
||||
@@ -177,7 +177,7 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class RegionClearListener extends CacheListenerAdapter {
|
||||
|
||||
public volatile boolean eventFired;
|
||||
volatile boolean eventFired;
|
||||
|
||||
@Override
|
||||
public void afterRegionClear(RegionEvent ev) {
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,16 +39,15 @@ import org.springframework.data.gemfire.repository.GemfireRepository;
|
||||
import org.springframework.data.gemfire.repository.sample.Customer;
|
||||
import org.springframework.data.repository.core.support.ReflectionEntityInformation;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* The SimpleGemfireRepositoryTransactionalIntegrationTest class is a test suite of test cases testing
|
||||
* the SimpleGemfireRepository class and SDC Repository abstraction implementation in the context of
|
||||
* GemFire "Cache" Transactions.
|
||||
* Integration tests testing the {@link SimpleGemfireRepository} class and SDC Repository abstraction implementation
|
||||
* in the context of GemFire "Cache" Transactions.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -55,14 +57,14 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
|
||||
// TODO add additional test cases for SimpleGemfireRepository (Region operations) in the presence of Transactions!!!
|
||||
|
||||
protected static final AtomicLong ID_SEQUENCE = new AtomicLong(0l);
|
||||
static final AtomicLong ID_SEQUENCE = new AtomicLong(0L);
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
@@ -70,7 +72,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
@Resource(name = "Customers")
|
||||
private Region customers;
|
||||
|
||||
protected static Customer createCustomer(final String firstName, final String lastName) {
|
||||
static Customer createCustomer(String firstName, String lastName) {
|
||||
Customer customer = new SerializableCustomer(firstName, lastName);
|
||||
customer.setId(ID_SEQUENCE.incrementAndGet());
|
||||
return customer;
|
||||
@@ -146,7 +148,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
}
|
||||
|
||||
public void saveAll(final Iterable<Customer> customers) {
|
||||
void saveAll(final Iterable<Customer> customers) {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override protected void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
customerRepository.saveAll(customers);
|
||||
@@ -154,7 +156,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
});
|
||||
}
|
||||
|
||||
public void removeAllCausingTransactionRollback() {
|
||||
void removeAllCausingTransactionRollback() {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override protected void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
removeAll();
|
||||
@@ -163,7 +165,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
});
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
void removeAll() {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override protected void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
customerRepository.deleteAll();
|
||||
@@ -171,5 +173,4 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,19 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
Reference in New Issue
Block a user