diff --git a/pom.xml b/pom.xml
index 6813a1ac2..c26cb4405 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,6 +77,7 @@
1.01
multi
1.13.0.BUILD-SNAPSHOT
+ 3.5.2
@@ -202,6 +203,13 @@
${multithreadedtc.version}
test
+
+
+ org.assertj
+ assertj-core
+ ${assertj}
+ test
+
@@ -210,6 +218,12 @@
com.datastax.cassandra
cassandra-driver-core
+
+
+ org.assertj
+ assertj-core
+ test
+
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java
old mode 100644
new mode 100755
index 37998822d..b473a9d4d
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java
@@ -16,28 +16,15 @@
package org.springframework.cassandra.config;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import static org.mockito.Mockito.isA;
import org.junit.Test;
import org.mockito.Matchers;
import org.springframework.test.util.ReflectionTestUtils;
-import com.datastax.driver.core.AuthProvider;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Configuration;
-import com.datastax.driver.core.JdkSSLOptions;
-import com.datastax.driver.core.PlainTextAuthProvider;
-import com.datastax.driver.core.PoolingOptions;
-import com.datastax.driver.core.ProtocolOptions;
+import com.datastax.driver.core.*;
import com.datastax.driver.core.ProtocolOptions.Compression;
-import com.datastax.driver.core.ProtocolVersion;
-import com.datastax.driver.core.QueryOptions;
-import com.datastax.driver.core.SSLOptions;
-import com.datastax.driver.core.SocketOptions;
-import com.datastax.driver.core.TimestampGenerator;
import com.datastax.driver.core.policies.AddressTranslator;
import com.datastax.driver.core.policies.ExponentialReconnectionPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
@@ -65,10 +52,10 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
bean.afterPropertiesSet();
- assertThat(bean.getObject(), is(not(nullValue())));
- assertThat(bean.getObject().isClosed(), is(false));
- assertThat(getConfiguration(bean).getMetricsOptions(), is(not(nullValue())));
- assertThat(getConfiguration(bean).getMetricsOptions().isJMXReportingEnabled(), is(true));
+ assertThat(bean.getObject()).isNotNull();
+ assertThat(bean.getObject().isClosed()).isFalse();
+ assertThat(getConfiguration(bean).getMetricsOptions()).isNotNull();
+ assertThat(getConfiguration(bean).getMetricsOptions().isJMXReportingEnabled()).isTrue();
}
/**
@@ -82,7 +69,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.afterPropertiesSet();
bean.destroy();
- assertThat(bean.getObject().isClosed(), is(true));
+ assertThat(bean.getObject().isClosed()).isTrue();
}
/**
@@ -98,7 +85,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setCompressionType(compressionType);
bean.afterPropertiesSet();
- assertThat(getProtocolOptions(bean).getCompression(), is(Compression.LZ4));
+ assertThat(getProtocolOptions(bean).getCompression()).isEqualTo(Compression.LZ4);
}
/**
@@ -114,7 +101,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setCompressionType(compressionType);
bean.afterPropertiesSet();
- assertThat(getProtocolOptions(bean).getCompression(), is(Compression.SNAPPY));
+ assertThat(getConfiguration(bean).getProtocolOptions().getCompression()).isEqualTo(Compression.SNAPPY);
}
/**
@@ -130,7 +117,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setPoolingOptions(poolingOptions);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getPoolingOptions(), is(poolingOptions));
+ assertThat(getConfiguration(bean).getPoolingOptions()).isEqualTo(poolingOptions);
}
/**
@@ -146,7 +133,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setSocketOptions(socketOptions);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getSocketOptions(), is(socketOptions));
+ assertThat(getConfiguration(bean).getSocketOptions()).isEqualTo(socketOptions);
}
/**
@@ -162,7 +149,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setQueryOptions(queryOptions);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getQueryOptions(), is(queryOptions));
+ assertThat(getConfiguration(bean).getQueryOptions()).isEqualTo(queryOptions);
}
/**
@@ -177,8 +164,8 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getQueryOptions(), is(not(nullValue())));
- assertThat(getConfiguration(bean).getQueryOptions(), is(not(queryOptions)));
+ assertThat(getConfiguration(bean).getQueryOptions()).isNotNull();
+ assertThat(getConfiguration(bean).getQueryOptions()).isNotEqualTo(queryOptions);
}
/**
@@ -194,7 +181,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setAuthProvider(authProvider);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getProtocolOptions().getAuthProvider(), is(authProvider));
+ assertThat(getConfiguration(bean).getProtocolOptions().getAuthProvider()).isEqualTo(authProvider);
}
/**
@@ -212,7 +199,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.afterPropertiesSet();
AuthProvider result = getConfiguration(bean).getProtocolOptions().getAuthProvider();
- assertThat(result, is(equalTo(authProvider)));
+ assertThat(result).isEqualTo(authProvider);
}
/**
@@ -229,9 +216,9 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.afterPropertiesSet();
AuthProvider result = getConfiguration(bean).getProtocolOptions().getAuthProvider();
- assertThat(result, is(not(nullValue())));
- assertThat(ReflectionTestUtils.getField(result, "username"), is(equalTo((Object) "user")));
- assertThat(ReflectionTestUtils.getField(result, "password"), is(equalTo((Object) "password")));
+ assertThat(result).isNotNull();
+ assertThat(ReflectionTestUtils.getField(result, "username")).isEqualTo((Object) "user");
+ assertThat(ReflectionTestUtils.getField(result, "password")).isEqualTo((Object) "password");
}
/**
@@ -247,7 +234,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setLoadBalancingPolicy(loadBalancingPolicy);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getPolicies().getLoadBalancingPolicy(), is(loadBalancingPolicy));
+ assertThat(getConfiguration(bean).getPolicies().getLoadBalancingPolicy()).isEqualTo(loadBalancingPolicy);
}
/**
@@ -263,7 +250,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setReconnectionPolicy(reconnectionPolicy);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getPolicies().getReconnectionPolicy(), is(reconnectionPolicy));
+ assertThat(getConfiguration(bean).getPolicies().getReconnectionPolicy()).isEqualTo(reconnectionPolicy);
}
/**
@@ -277,8 +264,8 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setProtocolVersion(ProtocolVersion.V2);
bean.afterPropertiesSet();
- assertThat(ReflectionTestUtils.getField(getConfiguration(bean).getProtocolOptions(), "initialProtocolVersion"),
- is((Object) ProtocolVersion.V2));
+ assertThat(getConfiguration(bean).getProtocolOptions()).extracting("initialProtocolVersion")
+ .contains(ProtocolVersion.V2);
}
/**
@@ -295,7 +282,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setSslOptions(sslOptions);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getProtocolOptions().getSSLOptions(), is(sslOptions));
+ assertThat(getConfiguration(bean).getProtocolOptions().getSSLOptions()).isEqualTo(sslOptions);
}
/**
@@ -309,7 +296,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setMetricsEnabled(false);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getMetricsOptions().isEnabled(), is(false));
+ assertThat(getConfiguration(bean).getMetricsOptions().isEnabled()).isFalse();
}
/**
@@ -323,7 +310,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setJmxReportingEnabled(false);
bean.afterPropertiesSet();
- assertThat(getConfiguration(bean).getMetricsOptions().isJMXReportingEnabled(), is(false));
+ assertThat(getConfiguration(bean).getMetricsOptions().isJMXReportingEnabled()).isFalse();
}
@Test
@@ -350,7 +337,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setAddressTranslator(mockAddressTranslator);
bean.afterPropertiesSet();
- assertThat(getPolicies(bean).getAddressTranslator(), is(equalTo(mockAddressTranslator)));
+ assertThat(getPolicies(bean).getAddressTranslator()).isEqualTo(mockAddressTranslator);
}
/**
@@ -361,10 +348,11 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
final Cluster.Builder mockClusterBuilder = mock(Cluster.Builder.class);
- when(mockClusterBuilder.addContactPoints(Matchers.anyVararg())).thenReturn(mockClusterBuilder);
+ when(mockClusterBuilder.addContactPoints(Matchers. anyVararg())).thenReturn(mockClusterBuilder);
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean() {
- @Override Cluster.Builder newClusterBuilder() {
+ @Override
+ Cluster.Builder newClusterBuilder() {
return mockClusterBuilder;
}
};
@@ -384,10 +372,11 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
final Cluster.Builder mockClusterBuilder = mock(Cluster.Builder.class);
- when(mockClusterBuilder.addContactPoints(Matchers.anyVararg())).thenReturn(mockClusterBuilder);
+ when(mockClusterBuilder.addContactPoints(Matchers. anyVararg())).thenReturn(mockClusterBuilder);
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean() {
- @Override Cluster.Builder newClusterBuilder() {
+ @Override
+ Cluster.Builder newClusterBuilder() {
return mockClusterBuilder;
}
};
@@ -410,7 +399,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setMaxSchemaAgreementWaitSeconds(20);
bean.afterPropertiesSet();
- assertThat(getProtocolOptions(bean).getMaxSchemaAgreementWaitSeconds(), is(equalTo(20)));
+ assertThat(getProtocolOptions(bean).getMaxSchemaAgreementWaitSeconds()).isEqualTo(20);
}
/**
@@ -425,7 +414,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setSpeculativeExecutionPolicy(mockSpeculativeExecutionPolicy);
bean.afterPropertiesSet();
- assertThat(getPolicies(bean).getSpeculativeExecutionPolicy(), is(equalTo(mockSpeculativeExecutionPolicy)));
+ assertThat(getPolicies(bean).getSpeculativeExecutionPolicy()).isEqualTo(mockSpeculativeExecutionPolicy);
}
/**
@@ -440,7 +429,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
bean.setTimestampGenerator(mockTimestampGenerator);
bean.afterPropertiesSet();
- assertThat(getPolicies(bean).getTimestampGenerator(), is(equalTo(mockTimestampGenerator)));
+ assertThat(getPolicies(bean).getTimestampGenerator()).isEqualTo(mockTimestampGenerator);
}
private Policies getPolicies(CassandraCqlClusterFactoryBean bean) throws Exception {
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java
old mode 100644
new mode 100755
index 1c0ec18d6..cc342472b
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java
@@ -16,8 +16,7 @@
package org.springframework.cassandra.config;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
@@ -41,8 +40,8 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
/**
- * The CassandraCqlSessionFactoryBeanUnitTests class is a test suite of test cases testing the contract
- * and functionality of the {@link CassandraCqlSessionFactoryBean} class.
+ * The CassandraCqlSessionFactoryBeanUnitTests class is a test suite of test cases testing the contract and
+ * functionality of the {@link CassandraCqlSessionFactoryBean} class.
*
* @author John Blum
* @see org.springframework.cassandra.config.CassandraCqlSessionFactoryBean
@@ -52,14 +51,11 @@ import com.datastax.driver.core.Session;
@RunWith(MockitoJUnitRunner.class)
public class CassandraCqlSessionFactoryBeanUnitTests {
- @Rule
- public ExpectedException exception = ExpectedException.none();
+ @Rule public ExpectedException exception = ExpectedException.none();
- @Mock
- private Cluster mockCluster;
+ @Mock private Cluster mockCluster;
- @Mock
- private Session mockSession;
+ @Mock private Session mockSession;
private CassandraCqlSessionFactoryBean factoryBean;
@@ -68,8 +64,8 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
}
protected void assertNonNullEmptyCollection(Collection> collection) {
- assertThat(collection, is(notNullValue()));
- assertThat(collection.isEmpty(), is(true));
+ assertThat(collection).isNotNull();
+ assertThat(collection.isEmpty()).isTrue();
}
@Before
@@ -79,13 +75,13 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
@Test
public void cassandraCqlSessionFactoryBeanIsSingleton() {
- assertThat(factoryBean.isSingleton(), is(true));
+ assertThat(factoryBean.isSingleton()).isTrue();
}
@Test
public void objectTypeWhenSessionHasNotBeenInitializedIsSessionClass() {
- assertThat(factoryBean.getObject(), is(nullValue()));
- assertEquals(Session.class, factoryBean.getObjectType());
+ assertThat(factoryBean.getObject()).isNull();
+ assertThat(factoryBean. getObjectType()).isEqualTo(Session.class);
}
@Test
@@ -101,14 +97,14 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
factoryBean.setKeyspaceName("TestKeyspace");
factoryBean.setStartupScripts(expectedStartupScripts);
- assertThat(factoryBean.getKeyspaceName(), is(equalTo("TestKeyspace")));
- assertThat(factoryBean.getStartupScripts(), is(equalTo(expectedStartupScripts)));
+ assertThat(factoryBean.getKeyspaceName()).isEqualTo("TestKeyspace");
+ assertThat(factoryBean.getStartupScripts()).isEqualTo(expectedStartupScripts);
factoryBean.afterPropertiesSet();
- assertEquals(mockSession.getClass(), factoryBean.getObjectType());
- assertThat(factoryBean.getObject(), is(equalTo(mockSession)));
- assertThat(factoryBean.getSession(), is(equalTo(mockSession)));
+ assertThat(factoryBean.getObjectType()).isEqualTo(mockSession.getClass());
+ assertThat(factoryBean.getObject()).isEqualTo(mockSession);
+ assertThat(factoryBean.getSession()).isEqualTo(mockSession);
InOrder inOrder = inOrder(factoryBean);
@@ -125,7 +121,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
factoryBean.setCluster(mockCluster);
- assertThat(factoryBean.connect(null), is(equalTo(mockSession)));
+ assertThat(factoryBean.connect(null)).isEqualTo(mockSession);
verify(mockCluster, times(1)).connect();
verify(mockCluster, never()).connect(anyString());
@@ -137,7 +133,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
factoryBean.setCluster(mockCluster);
- assertThat(factoryBean.connect("TestKeyspace"), is(equalTo(mockSession)));
+ assertThat(factoryBean.connect("TestKeyspace")).isEqualTo(mockSession);
verify(mockCluster, never()).connect();
verify(mockCluster, times(1)).connect(eq("TestKeyspace"));
@@ -165,15 +161,15 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
@Test
public void isConnectedWithNullSessionIsFalse() {
- assertThat(factoryBean.getObject(), is(nullValue()));
- assertThat(factoryBean.isConnected(), is(false));
+ assertThat(factoryBean.getObject()).isNull();
+ assertThat(factoryBean.isConnected()).isFalse();
}
@Test
public void isConnectedWithClosedSessionIsFalse() {
doReturn(mockSession).when(factoryBean).getObject();
when(mockSession.isClosed()).thenReturn(true);
- assertThat(factoryBean.isConnected(), is(false));
+ assertThat(factoryBean.isConnected()).isFalse();
verify(mockSession, times(1)).isClosed();
}
@@ -181,56 +177,64 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
public void isConnectedWithOpenSessionIsTrue() {
doReturn(mockSession).when(factoryBean).getObject();
when(mockSession.isClosed()).thenReturn(false);
- assertThat(factoryBean.isConnected(), is(true));
+ assertThat(factoryBean.isConnected()).isTrue();
verify(mockSession, times(1)).isClosed();
}
@Test
public void setAndGetCluster() {
factoryBean.setCluster(mockCluster);
- assertThat(factoryBean.getCluster(), is(equalTo(mockCluster)));
+ assertThat(factoryBean.getCluster()).isEqualTo(mockCluster);
}
@Test
public void setClusterToNullThrowsIllegalArgumentException() {
- exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage("Cluster must not be null");
- factoryBean.setCluster(null);
+ try {
+ factoryBean.setCluster(null);
+ fail("Missing IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e).hasMessageContaining("Cluster must not be null");
+ }
+
}
@Test
public void getClusterWhenUninitializedThrowsIllegalStateException() {
- exception.expect(IllegalStateException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage("Cluster was not properly initialized");
- factoryBean.getCluster();
+ try {
+ factoryBean.getCluster();
+ fail("Missing IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e).hasMessageContaining("Cluster was not properly initialized");
+ }
}
@Test
public void setAndGetKeyspaceName() {
- assertThat(factoryBean.getKeyspaceName(), is(nullValue()));
+ assertThat(factoryBean.getKeyspaceName()).isNull();
factoryBean.setKeyspaceName("TEST");
- assertThat(factoryBean.getKeyspaceName(), is(equalTo("TEST")));
+ assertThat(factoryBean.getKeyspaceName()).isEqualTo("TEST");
factoryBean.setKeyspaceName(null);
- assertThat(factoryBean.getKeyspaceName(), is(nullValue()));
+ assertThat(factoryBean.getKeyspaceName()).isNull();
}
@Test
public void getSessionWhenUninitializedThrowsIllegalStateException() {
- exception.expect(IllegalStateException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage(is(equalTo("Session was not properly initialized")));
- assertThat(factoryBean.getObject(), is(nullValue()));
+ assertThat(factoryBean.getObject()).isNull();
+
+ try {
+ factoryBean.getSession();
+ fail("Missing IllegalStateException");
+ } catch (IllegalStateException e) {
+ assertThat(e).hasMessageContaining("Session was not properly initialized");
+ }
- factoryBean.getSession();
}
@Test
@@ -243,8 +247,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
List actualStartupScripts = factoryBean.getStartupScripts();
- assertThat(actualStartupScripts, is(not(sameInstance(expectedStartupScripts))));
- assertThat(actualStartupScripts, is(equalTo(expectedStartupScripts)));
+ assertThat(actualStartupScripts).isNotSameAs(expectedStartupScripts).isEqualTo(expectedStartupScripts);
factoryBean.setStartupScripts(null);
@@ -259,23 +262,21 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
List actualStartupScripts = factoryBean.getStartupScripts();
- assertThat(actualStartupScripts, is(notNullValue()));
- assertThat(actualStartupScripts, is(not(sameInstance(startupScripts))));
- assertThat(actualStartupScripts, is(equalTo(startupScripts)));
+ assertThat(actualStartupScripts).isEqualTo(startupScripts).isNotSameAs(startupScripts);
startupScripts.add("/path/to/another.cql");
actualStartupScripts = factoryBean.getStartupScripts();
- assertThat(actualStartupScripts, is(not(equalTo(startupScripts))));
- assertThat(actualStartupScripts.size(), is(equalTo(1)));
- assertThat(actualStartupScripts.get(0), is(equalTo(startupScripts.get(0))));
+ assertThat(actualStartupScripts).isNotEqualTo(startupScripts);
+ assertThat(actualStartupScripts).hasSize(1);
+ assertThat(actualStartupScripts.get(0)).isEqualTo(startupScripts.get(0));
try {
exception.expect(UnsupportedOperationException.class);
actualStartupScripts.add("/path/to/yetAnother.cql");
} finally {
- assertThat(actualStartupScripts.size(), is(equalTo(1)));
+ assertThat(actualStartupScripts).hasSize(1);
}
}
@@ -289,8 +290,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
List actualShutdownScripts = factoryBean.getShutdownScripts();
- assertThat(actualShutdownScripts, is(not(sameInstance(expectedShutdownScripts))));
- assertThat(actualShutdownScripts, is(equalTo(expectedShutdownScripts)));
+ assertThat(actualShutdownScripts).isEqualTo(expectedShutdownScripts).isNotSameAs(expectedShutdownScripts);
factoryBean.setShutdownScripts(null);
@@ -305,23 +305,20 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
List actualShutdownScripts = factoryBean.getShutdownScripts();
- assertThat(actualShutdownScripts, is(notNullValue()));
- assertThat(actualShutdownScripts, is(not(sameInstance(shutdownScripts))));
- assertThat(actualShutdownScripts, is(equalTo(shutdownScripts)));
+ assertThat(actualShutdownScripts).isEqualTo(shutdownScripts).isNotSameAs(shutdownScripts);
shutdownScripts.add("/path/to/corruptSession.cql");
actualShutdownScripts = factoryBean.getShutdownScripts();
- assertThat(actualShutdownScripts, is(not(sameInstance(shutdownScripts))));
- assertThat(actualShutdownScripts, is(not(equalTo(shutdownScripts))));
- assertThat(actualShutdownScripts.size(), is(equalTo(1)));
+ assertThat(actualShutdownScripts).isNotEqualTo(shutdownScripts);
+ assertThat(actualShutdownScripts).hasSize(1);
try {
exception.expect(UnsupportedOperationException.class);
actualShutdownScripts.add("/path/to/blowUpCluster.cql");
} finally {
- assertThat(actualShutdownScripts.size(), is(equalTo(1)));
+ assertThat(actualShutdownScripts).hasSize(1);
}
}
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java
old mode 100644
new mode 100755
index 4a0e65917..791a6fcc4
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java
@@ -15,15 +15,14 @@
*/
package org.springframework.cassandra.config;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.assumeNotNull;
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assume.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.same;
-import static org.springframework.util.ReflectionUtils.invokeMethod;
+import static org.springframework.util.ReflectionUtils.*;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;
@@ -36,10 +35,10 @@ import org.mockito.Spy;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import org.springframework.util.ReflectionUtils;
import com.datastax.driver.core.HostDistance;
import com.datastax.driver.core.PoolingOptions;
-import org.springframework.util.ReflectionUtils;
/**
* Unit tests for {@link PoolingOptionsFactoryBean}.
@@ -66,18 +65,18 @@ public class PoolingOptionsFactoryBeanUnitTests {
@Test
public void getObjectReturnsNullWhenNotInitialized() throws Exception {
- assertThat(poolingOptionsFactoryBean.getObject(), is(nullValue(PoolingOptions.class)));
+ assertThat(poolingOptionsFactoryBean.getObject()).isNull();
}
@Test
@SuppressWarnings("unchecked")
public void getObjectTypeReturnsPoolingOptionsClassWhenNotInitialized() {
- assertThat((Class) poolingOptionsFactoryBean.getObjectType(), is(equalTo(PoolingOptions.class)));
+ assertThat((Class) poolingOptionsFactoryBean.getObjectType()).isEqualTo(PoolingOptions.class);
}
@Test
public void isSingletonIsTrue() {
- assertThat(poolingOptionsFactoryBean.isSingleton(), is(true));
+ assertThat(poolingOptionsFactoryBean.isSingleton()).isTrue();
}
/**
@@ -100,18 +99,18 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean.setRemoteMaxSimultaneousRequests(100);
poolingOptionsFactoryBean.setRemoteMinSimultaneousRequests(50);
- assertThat(poolingOptionsFactoryBean.getHeartbeatIntervalSeconds(), is(equalTo(15)));
- assertThat(poolingOptionsFactoryBean.getIdleTimeoutSeconds(), is(equalTo(120)));
- assertThat(poolingOptionsFactoryBean.getInitializationExecutor(), is(equalTo(mockExecutor)));
- assertThat(poolingOptionsFactoryBean.getLocalCoreConnections(), is(equalTo(50)));
- assertThat(poolingOptionsFactoryBean.getLocalMaxConnections(), is(equalTo(1000)));
- assertThat(poolingOptionsFactoryBean.getLocalMaxSimultaneousRequests(), is(equalTo(200)));
- assertThat(poolingOptionsFactoryBean.getLocalMinSimultaneousRequests(), is(equalTo(100)));
- assertThat(poolingOptionsFactoryBean.getPoolTimeoutMilliseconds(), is(equalTo(300)));
- assertThat(poolingOptionsFactoryBean.getRemoteCoreConnections(), is(equalTo(25)));
- assertThat(poolingOptionsFactoryBean.getRemoteMaxConnections(), is(equalTo(250)));
- assertThat(poolingOptionsFactoryBean.getRemoteMaxSimultaneousRequests(), is(equalTo(100)));
- assertThat(poolingOptionsFactoryBean.getRemoteMinSimultaneousRequests(), is(equalTo(50)));
+ assertThat(poolingOptionsFactoryBean.getHeartbeatIntervalSeconds()).isEqualTo(15);
+ assertThat(poolingOptionsFactoryBean.getIdleTimeoutSeconds()).isEqualTo(120);
+ assertThat(poolingOptionsFactoryBean.getInitializationExecutor()).isEqualTo(mockExecutor);
+ assertThat(poolingOptionsFactoryBean.getLocalCoreConnections()).isEqualTo(50);
+ assertThat(poolingOptionsFactoryBean.getLocalMaxConnections()).isEqualTo(1000);
+ assertThat(poolingOptionsFactoryBean.getLocalMaxSimultaneousRequests()).isEqualTo(200);
+ assertThat(poolingOptionsFactoryBean.getLocalMinSimultaneousRequests()).isEqualTo(100);
+ assertThat(poolingOptionsFactoryBean.getPoolTimeoutMilliseconds()).isEqualTo(300);
+ assertThat(poolingOptionsFactoryBean.getRemoteCoreConnections()).isEqualTo(25);
+ assertThat(poolingOptionsFactoryBean.getRemoteMaxConnections()).isEqualTo(250);
+ assertThat(poolingOptionsFactoryBean.getRemoteMaxSimultaneousRequests()).isEqualTo(100);
+ assertThat(poolingOptionsFactoryBean.getRemoteMinSimultaneousRequests()).isEqualTo(50);
}
/**
@@ -137,12 +136,12 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean.setLocalMinSimultaneousRequests(5);
poolingOptionsFactoryBean.setPoolTimeoutMilliseconds(180);
- assertThat(poolingOptionsFactoryBean.getObject(), is(nullValue(PoolingOptions.class)));
+ assertThat(poolingOptionsFactoryBean.getObject()).isNull();
poolingOptionsFactoryBean.afterPropertiesSet();
- assertThat(poolingOptionsFactoryBean.getObject(), is(sameInstance(poolingOptionsSpy)));
- assertThat(poolingOptionsFactoryBean.getObjectType(), is(equalTo((Class) poolingOptionsSpy.getClass())));
+ assertThat(poolingOptionsFactoryBean.getObject()).isSameAs(poolingOptionsSpy);
+ assertThat(poolingOptionsFactoryBean.getObjectType()).isEqualTo(poolingOptionsSpy.getClass());
verify(poolingOptionsSpy).setHeartbeatIntervalSeconds(eq(60));
verify(poolingOptionsSpy).setIdleTimeoutSeconds(eq(300));
@@ -181,12 +180,12 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean.setRemoteMaxSimultaneousRequests(20);
poolingOptionsFactoryBean.setRemoteMinSimultaneousRequests(5);
- assertThat(poolingOptionsFactoryBean.getObject(), is(nullValue(PoolingOptions.class)));
+ assertThat(poolingOptionsFactoryBean.getObject()).isNull();
poolingOptionsFactoryBean.afterPropertiesSet();
- assertThat(poolingOptionsFactoryBean.getObject(), is(sameInstance(poolingOptionsSpy)));
- assertThat(poolingOptionsFactoryBean.getObjectType(), is(equalTo((Class) poolingOptionsSpy.getClass())));
+ assertThat(poolingOptionsFactoryBean.getObject()).isSameAs(poolingOptionsSpy);
+ assertThat(poolingOptionsFactoryBean.getObjectType()).isEqualTo(poolingOptionsSpy.getClass());
verify(poolingOptionsSpy).setHeartbeatIntervalSeconds(eq(33));
verify(poolingOptionsSpy).setIdleTimeoutSeconds(eq(112));
@@ -208,11 +207,9 @@ public class PoolingOptionsFactoryBeanUnitTests {
@Test
public void afterPropertiesSetInitializesMaxQueueSize() throws Exception {
- Method setMaxQueueSize = ReflectionUtils
- .findMethod(PoolingOptions.class, "setMaxQueueSize", int.class);
+ Method setMaxQueueSize = ReflectionUtils.findMethod(PoolingOptions.class, "setMaxQueueSize", int.class);
- Method getMaxQueueSize = ReflectionUtils
- .findMethod(PoolingOptions.class, "getMaxQueueSize");
+ Method getMaxQueueSize = ReflectionUtils.findMethod(PoolingOptions.class, "getMaxQueueSize");
assumeNotNull(setMaxQueueSize);
@@ -227,9 +224,9 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean.afterPropertiesSet();
- assertThat(poolingOptionsFactoryBean.getObject(), is(sameInstance(poolingOptionsSpy)));
- assertThat(poolingOptionsFactoryBean.getObjectType(), is(equalTo((Class) poolingOptionsSpy.getClass())));
- assertThat(invokeMethod(getMaxQueueSize, poolingOptionsSpy), is(equalTo((Object) 1234)));
+ assertThat(poolingOptionsFactoryBean.getObject()).isSameAs(poolingOptionsSpy);
+ assertThat(poolingOptionsFactoryBean.getObjectType()).isEqualTo(poolingOptionsSpy.getClass());
+ assertThat(invokeMethod(getMaxQueueSize, poolingOptionsSpy)).isEqualTo(1234);
}
/**
@@ -260,21 +257,21 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean.setRemoteMaxSimultaneousRequests(127);
poolingOptionsFactoryBean.setRemoteMinSimultaneousRequests(111);
- assertThat(poolingOptionsFactoryBean.getObject(), is(nullValue(PoolingOptions.class)));
+ assertThat(poolingOptionsFactoryBean.getObject()).isNull();
poolingOptionsFactoryBean.afterPropertiesSet();
PoolingOptions poolingOptions = poolingOptionsFactoryBean.getObject();
- assertThat(poolingOptions, is(notNullValue(PoolingOptions.class)));
- assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL), is(equalTo(100)));
- assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.LOCAL), is(equalTo(200)));
- assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.LOCAL), is(equalTo(99)));
- assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.LOCAL), is(equalTo(97)));
- assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.REMOTE), is(equalTo(110)));
- assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.REMOTE), is(equalTo(210)));
- assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.REMOTE), is(equalTo(127)));
- assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE), is(equalTo(111)));
+ assertThat(poolingOptions).isNotNull();
+ assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL)).isEqualTo(100);
+ assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.LOCAL)).isEqualTo(200);
+ assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.LOCAL)).isEqualTo(99);
+ assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.LOCAL)).isEqualTo(97);
+ assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.REMOTE)).isEqualTo(110);
+ assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.REMOTE)).isEqualTo(210);
+ assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.REMOTE)).isEqualTo(127);
+ assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE)).isEqualTo(111);
verify(poolingOptions).setMaxConnectionsPerHost(eq(HostDistance.LOCAL), eq(200));
verify(poolingOptions).setCoreConnectionsPerHost(eq(HostDistance.LOCAL), eq(100));
@@ -304,11 +301,11 @@ public class PoolingOptionsFactoryBeanUnitTests {
PoolingOptionsFactoryBean.HostDistancePoolingOptions poolingOptions = poolingOptionsFactoryBean
.newLocalHostDistancePoolingOptions();
- assertThat(poolingOptions.getHostDistance(), is(equalTo(HostDistance.LOCAL)));
- assertThat(poolingOptions.getCoreConnectionsPerHost(), is(equalTo(50)));
- assertThat(poolingOptions.getMaxConnectionsPerHost(), is(equalTo(500)));
- assertThat(poolingOptions.getMaxRequestsPerConnection(), is(equalTo(1000)));
- assertThat(poolingOptions.getNewConnectionThreshold(), is(equalTo(100)));
+ assertThat(poolingOptions.getHostDistance()).isEqualTo(HostDistance.LOCAL);
+ assertThat(poolingOptions.getCoreConnectionsPerHost()).isEqualTo(50);
+ assertThat(poolingOptions.getMaxConnectionsPerHost()).isEqualTo(500);
+ assertThat(poolingOptions.getMaxRequestsPerConnection()).isEqualTo(1000);
+ assertThat(poolingOptions.getNewConnectionThreshold()).isEqualTo(100);
}
/**
@@ -329,11 +326,11 @@ public class PoolingOptionsFactoryBeanUnitTests {
PoolingOptionsFactoryBean.HostDistancePoolingOptions poolingOptions = poolingOptionsFactoryBean
.newRemoteHostDistancePoolingOptions();
- assertThat(poolingOptions.getHostDistance(), is(equalTo(HostDistance.REMOTE)));
- assertThat(poolingOptions.getCoreConnectionsPerHost(), is(equalTo(20)));
- assertThat(poolingOptions.getMaxConnectionsPerHost(), is(equalTo(200)));
- assertThat(poolingOptions.getMaxRequestsPerConnection(), is(equalTo(400)));
- assertThat(poolingOptions.getNewConnectionThreshold(), is(equalTo(40)));
+ assertThat(poolingOptions.getHostDistance()).isEqualTo(HostDistance.REMOTE);
+ assertThat(poolingOptions.getCoreConnectionsPerHost()).isEqualTo(20);
+ assertThat(poolingOptions.getMaxConnectionsPerHost()).isEqualTo(200);
+ assertThat(poolingOptions.getMaxRequestsPerConnection()).isEqualTo(400);
+ assertThat(poolingOptions.getNewConnectionThreshold()).isEqualTo(40);
}
/**
@@ -359,8 +356,8 @@ public class PoolingOptionsFactoryBeanUnitTests {
}
};
- assertThat(poolingOptionsFactoryBean.configureLocalHostDistancePoolingOptions(poolingOptionsSpy),
- is(sameInstance(poolingOptionsSpy)));
+ assertThat(poolingOptionsFactoryBean.configureLocalHostDistancePoolingOptions(poolingOptionsSpy))
+ .isSameAs(poolingOptionsSpy);
verify(mockHostDistancePoolingOptions).configure(same(poolingOptionsSpy));
}
@@ -388,8 +385,8 @@ public class PoolingOptionsFactoryBeanUnitTests {
}
};
- assertThat(poolingOptionsFactoryBean.configureRemoteHostDistancePoolingOptions(poolingOptionsSpy),
- is(sameInstance(poolingOptionsSpy)));
+ assertThat(poolingOptionsFactoryBean.configureRemoteHostDistancePoolingOptions(poolingOptionsSpy))
+ .isSameAs(poolingOptionsSpy);
verify(mockHostDistancePoolingOptions).configure(same(poolingOptionsSpy));
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java
old mode 100644
new mode 100755
index a31cd924d..d8db161c5
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java
@@ -16,9 +16,7 @@
package org.springframework.cassandra.config.java;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
-import static org.mockito.Mockito.isA;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
@@ -30,19 +28,9 @@ import org.springframework.cassandra.config.ClusterBuilderConfigurer;
import org.springframework.cassandra.config.CompressionType;
import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
import org.springframework.cassandra.core.keyspace.DropKeyspaceSpecification;
-import org.springframework.test.util.ReflectionTestUtils;
-import com.datastax.driver.core.AuthProvider;
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Configuration;
-import com.datastax.driver.core.PlainTextAuthProvider;
-import com.datastax.driver.core.PoolingOptions;
-import com.datastax.driver.core.ProtocolOptions;
+import com.datastax.driver.core.*;
import com.datastax.driver.core.ProtocolOptions.Compression;
-import com.datastax.driver.core.ProtocolVersion;
-import com.datastax.driver.core.QueryOptions;
-import com.datastax.driver.core.SocketOptions;
-import com.datastax.driver.core.TimestampGenerator;
import com.datastax.driver.core.policies.AddressTranslator;
import com.datastax.driver.core.policies.ExponentialReconnectionPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
@@ -74,10 +62,10 @@ public class AbstractClusterConfigurationUnitTests {
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(cluster, is(not(nullValue())));
- assertThat(cluster.isClosed(), is(false));
- assertThat(getConfiguration(cluster).getMetricsOptions(), is(not(nullValue())));
- assertThat(getConfiguration(cluster).getMetricsOptions().isJMXReportingEnabled(), is(true));
+ assertThat(cluster).isNotNull();
+ assertThat(cluster.isClosed()).isFalse();
+ assertThat(getConfiguration(cluster).getMetricsOptions()).isNotNull();
+ assertThat(getConfiguration(cluster).getMetricsOptions().isJMXReportingEnabled()).isTrue();
}
/**
@@ -97,7 +85,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getProtocolOptions().getCompression(), is(Compression.SNAPPY));
+ assertThat(getConfiguration(cluster).getProtocolOptions().getCompression()).isEqualTo(Compression.SNAPPY);
}
/**
@@ -117,7 +105,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getPoolingOptions(), is(poolingOptions));
+ assertThat(getConfiguration(cluster).getPoolingOptions()).isEqualTo(poolingOptions);
}
/**
@@ -137,7 +125,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getSocketOptions(), is(socketOptions));
+ assertThat(getConfiguration(cluster).getSocketOptions()).isEqualTo(socketOptions);
}
/**
@@ -157,7 +145,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getQueryOptions(), is(queryOptions));
+ assertThat(getConfiguration(cluster).getQueryOptions()).isEqualTo(queryOptions);
}
/**
@@ -177,7 +165,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getProtocolOptions().getAuthProvider(), is(authProvider));
+ assertThat(getConfiguration(cluster).getProtocolOptions().getAuthProvider()).isEqualTo(authProvider);
}
/**
@@ -197,7 +185,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getPolicies(cluster).getLoadBalancingPolicy(), is(loadBalancingPolicy));
+ assertThat(getConfiguration(cluster).getPolicies().getLoadBalancingPolicy()).isEqualTo(loadBalancingPolicy);
}
/**
@@ -217,7 +205,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getPolicies(cluster).getReconnectionPolicy(), is(reconnectionPolicy));
+ assertThat(getConfiguration(cluster).getPolicies().getReconnectionPolicy()).isEqualTo(reconnectionPolicy);
}
/**
@@ -235,8 +223,8 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(ReflectionTestUtils.getField(getConfiguration(cluster).getProtocolOptions(), "initialProtocolVersion"),
- is((Object) ProtocolVersion.V2));
+ assertThat(getConfiguration(cluster).getProtocolOptions()).extracting("initialProtocolVersion")
+ .contains(ProtocolVersion.V2);
}
/**
@@ -254,7 +242,7 @@ public class AbstractClusterConfigurationUnitTests {
};
Cluster cluster = getCluster(clusterConfiguration);
- assertThat(getConfiguration(cluster).getMetricsOptions().isEnabled(), is(false));
+ assertThat(getConfiguration(cluster).getMetricsOptions().isEnabled()).isFalse();
}
/**
@@ -272,7 +260,7 @@ public class AbstractClusterConfigurationUnitTests {
}
};
- assertThat(clusterConfiguration.cluster().getKeyspaceCreations(), is(equalTo(specification)));
+ assertThat(clusterConfiguration.cluster().getKeyspaceCreations()).isEqualTo(specification);
}
/**
@@ -290,7 +278,7 @@ public class AbstractClusterConfigurationUnitTests {
}
};
- assertThat(clusterConfiguration.cluster().getKeyspaceDrops(), is(equalTo(specification)));
+ assertThat(clusterConfiguration.cluster().getKeyspaceDrops()).isEqualTo(specification);
}
/**
@@ -307,7 +295,7 @@ public class AbstractClusterConfigurationUnitTests {
}
};
- assertThat(clusterConfiguration.cluster().getStartupScripts(), is(equalTo(scripts)));
+ assertThat(clusterConfiguration.cluster().getStartupScripts()).isEqualTo(scripts);
}
/**
@@ -324,7 +312,7 @@ public class AbstractClusterConfigurationUnitTests {
}
};
- assertThat(clusterConfiguration.cluster().getShutdownScripts(), is(equalTo(scripts)));
+ assertThat(clusterConfiguration.cluster().getShutdownScripts()).isEqualTo(scripts);
}
/**
@@ -332,17 +320,17 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetAddressTranslator() throws Exception {
-
+
final AddressTranslator mockAddressTranslator = mock(AddressTranslator.class);
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected AddressTranslator getAddressTranslator() {
+ @Override
+ protected AddressTranslator getAddressTranslator() {
return mockAddressTranslator;
}
};
- assertThat(getPolicies(getCluster(clusterConfiguration)).getAddressTranslator(),
- is(equalTo(mockAddressTranslator)));
+ assertThat(getPolicies(getCluster(clusterConfiguration)).getAddressTranslator()).isEqualTo(mockAddressTranslator);
}
/**
@@ -350,17 +338,17 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetAndApplyClusterBuilderConfigurer() throws Exception {
-
+
final ClusterBuilderConfigurer mockClusterBuilderConfigurer = mock(ClusterBuilderConfigurer.class);
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected ClusterBuilderConfigurer getClusterBuilderConfigurer() {
+ @Override
+ protected ClusterBuilderConfigurer getClusterBuilderConfigurer() {
return mockClusterBuilderConfigurer;
}
};
- assertThat(getCluster(clusterConfiguration), is(notNullValue(Cluster.class)));
-
+ assertThat(getCluster(clusterConfiguration)).isNotNull();
verify(mockClusterBuilderConfigurer, times(1)).configure(isA(Cluster.Builder.class));
}
@@ -370,14 +358,15 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetClusterName() throws Exception {
-
+
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected String getClusterName() {
+ @Override
+ protected String getClusterName() {
return "testCluster";
}
};
- assertThat(getCluster(clusterConfiguration).getClusterName(), is(equalTo("testCluster")));
+ assertThat(getCluster(clusterConfiguration).getClusterName()).isEqualTo("testCluster");
}
/**
@@ -385,15 +374,15 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetMaxSchemaAgreementWaitInSeconds() throws Exception {
-
+
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected int getMaxSchemaAgreementWaitSeconds() {
+ @Override
+ protected int getMaxSchemaAgreementWaitSeconds() {
return 30;
}
};
- assertThat(getProtocolOptions(getCluster(clusterConfiguration)).getMaxSchemaAgreementWaitSeconds(),
- is(equalTo(30)));
+ assertThat(getProtocolOptions(getCluster(clusterConfiguration)).getMaxSchemaAgreementWaitSeconds()).isEqualTo(30);
}
/**
@@ -401,17 +390,18 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetSpeculativeExecutionPolicy() throws Exception {
-
+
final SpeculativeExecutionPolicy mockSpeculativeExecutionPolicy = mock(SpeculativeExecutionPolicy.class);
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected SpeculativeExecutionPolicy getSpeculativeExecutionPolicy() {
+ @Override
+ protected SpeculativeExecutionPolicy getSpeculativeExecutionPolicy() {
return mockSpeculativeExecutionPolicy;
}
};
- assertThat(getPolicies(getCluster(clusterConfiguration)).getSpeculativeExecutionPolicy(),
- is(equalTo(mockSpeculativeExecutionPolicy)));
+ assertThat(getPolicies(getCluster(clusterConfiguration)).getSpeculativeExecutionPolicy())
+ .isEqualTo(mockSpeculativeExecutionPolicy);
}
/**
@@ -419,17 +409,17 @@ public class AbstractClusterConfigurationUnitTests {
*/
@Test
public void shouldSetTimestampGenerator() throws Exception {
-
+
final TimestampGenerator mockTimestampGenerator = mock(TimestampGenerator.class);
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
- @Override protected TimestampGenerator getTimestampGenerator() {
+ @Override
+ protected TimestampGenerator getTimestampGenerator() {
return mockTimestampGenerator;
}
};
- assertThat(getPolicies(getCluster(clusterConfiguration)).getTimestampGenerator(),
- is(equalTo(mockTimestampGenerator)));
+ assertThat(getPolicies(getCluster(clusterConfiguration)).getTimestampGenerator()).isEqualTo(mockTimestampGenerator);
}
private Policies getPolicies(Cluster cluster) {
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java
old mode 100644
new mode 100755
index 8e1e4fe0e..f298672e3
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java
@@ -15,9 +15,7 @@
*/
package org.springframework.cassandra.config.xml;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import static org.springframework.cassandra.support.BeanDefinitionTestUtils.*;
@@ -62,7 +60,7 @@ public class CassandraCqlClusterParserUnitTests {
when(mockElement.getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE))).thenReturn("test");
- assertThat(parser.resolveId(mockElement, null, null), is(equalTo("test")));
+ assertThat(parser.resolveId(mockElement, null, null)).isEqualTo("test");
verify(mockElement).getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE));
}
@@ -74,7 +72,7 @@ public class CassandraCqlClusterParserUnitTests {
when(mockElement.getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE))).thenReturn("");
- assertThat(parser.resolveId(mockElement, null, null), is(equalTo(DefaultCqlBeanNames.CLUSTER)));
+ assertThat(parser.resolveId(mockElement, null, null)).isEqualTo(DefaultCqlBeanNames.CLUSTER);
verify(mockElement).getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE));
}
@@ -112,41 +110,41 @@ public class CassandraCqlClusterParserUnitTests {
CassandraCqlClusterParser parser = new CassandraCqlClusterParser() {
@Override
- protected void parseChildElements(Element element, ParserContext parserContext,
- BeanDefinitionBuilder builder) {
- }
+ protected void parseChildElements(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {}
};
- AbstractBeanDefinition beanDefinition = parser.parseInternal(mockElement, mockParserContext(
- mockContainingBeanDefinition));
+ AbstractBeanDefinition beanDefinition = parser.parseInternal(mockElement,
+ mockParserContext(mockContainingBeanDefinition));
- assertThat(beanDefinition, is(notNullValue(BeanDefinition.class)));
- assertThat(beanDefinition.getBeanClassName(), is(equalTo(CassandraCqlClusterFactoryBean.class.getName())));
- assertThat(beanDefinition.getDestroyMethodName(), is(equalTo("destroy")));
- assertThat((Element) beanDefinition.getSource(), is(equalTo(mockElement)));
- assertThat(beanDefinition.isLazyInit(), is(false));
- assertThat(getPropertyValueAsString(beanDefinition, "addressTranslator"), is(equalTo("testAddressTranslator")));
- assertThat(getPropertyValueAsString(beanDefinition, "authProvider"), is(equalTo("testAuthInfoProvider")));
- assertThat(getPropertyValueAsString(beanDefinition, "clusterBuilderConfigurer"), is(equalTo("testClusterBuilderConfigurer")));
- assertThat(getPropertyValueAsString(beanDefinition, "hostStateListener"), is(equalTo("testHostStateListener")));
- assertThat(getPropertyValueAsString(beanDefinition, "latencyTracker"), is(equalTo("testLatencyTracker")));
- assertThat(getPropertyValueAsString(beanDefinition, "loadBalancingPolicy"), is(equalTo("testLoadBalancingPolicy")));
- assertThat(getPropertyValueAsString(beanDefinition, "nettyOptions"), is(equalTo("testNettyOptions")));
- assertThat(getPropertyValueAsString(beanDefinition, "reconnectionPolicy"), is(equalTo("testReconnectionPolicy")));
- assertThat(getPropertyValueAsString(beanDefinition, "retryPolicy"), is(equalTo("testRetryPolicy")));
- assertThat(getPropertyValueAsString(beanDefinition, "speculativeExecutionPolicy"), is(equalTo("testSpeculativeExecutionPolicy")));
- assertThat(getPropertyValueAsString(beanDefinition, "sslOptions"), is(equalTo("testSslOptions")));
- assertThat(getPropertyValueAsString(beanDefinition, "timestampGenerator"), is(equalTo("testTimestampGenerator")));
- assertThat(getPropertyValueAsString(beanDefinition, "clusterName"), is(equalTo("testCluster")));
- assertThat(getPropertyValueAsString(beanDefinition, "contactPoints"), is(equalTo("skullbox")));
- assertThat(getPropertyValueAsString(beanDefinition, "compressionType"), is(equalTo("SNAPPY")));
- assertThat(getPropertyValueAsString(beanDefinition, "jmxReportingEnabled"), is(equalTo("true")));
- assertThat(getPropertyValueAsString(beanDefinition, "maxSchemaAgreementWaitSeconds"), is(equalTo("30")));
- assertThat(getPropertyValueAsString(beanDefinition, "metricsEnabled"), is(equalTo("true")));
- assertThat(getPropertyValueAsString(beanDefinition, "password"), is(equalTo("p@55w0rd")));
- assertThat(getPropertyValueAsString(beanDefinition, "port"), is(equalTo("12345")));
- assertThat(getPropertyValueAsString(beanDefinition, "sslEnabled"), is(equalTo("true")));
- assertThat(getPropertyValueAsString(beanDefinition, "username"), is(equalTo("jonDoe")));
+ assertThat(beanDefinition).isNotNull();
+ assertThat(beanDefinition.getBeanClassName()).isEqualTo(CassandraCqlClusterFactoryBean.class.getName());
+ assertThat(beanDefinition.getDestroyMethodName()).isEqualTo("destroy");
+ assertThat((Element) beanDefinition.getSource()).isEqualTo(mockElement);
+ assertThat(beanDefinition.isLazyInit()).isFalse();
+ assertThat(getPropertyValueAsString(beanDefinition, "addressTranslator")).isEqualTo("testAddressTranslator");
+ assertThat(getPropertyValueAsString(beanDefinition, "authProvider")).isEqualTo("testAuthInfoProvider");
+ assertThat(getPropertyValueAsString(beanDefinition, "clusterBuilderConfigurer"))
+ .isEqualTo("testClusterBuilderConfigurer");
+ assertThat(getPropertyValueAsString(beanDefinition, "hostStateListener")).isEqualTo("testHostStateListener");
+ assertThat(getPropertyValueAsString(beanDefinition, "latencyTracker")).isEqualTo("testLatencyTracker");
+ assertThat(getPropertyValueAsString(beanDefinition, "loadBalancingPolicy")).isEqualTo("testLoadBalancingPolicy");
+ assertThat(getPropertyValueAsString(beanDefinition, "nettyOptions")).isEqualTo("testNettyOptions");
+ assertThat(getPropertyValueAsString(beanDefinition, "reconnectionPolicy")).isEqualTo("testReconnectionPolicy");
+ assertThat(getPropertyValueAsString(beanDefinition, "retryPolicy")).isEqualTo("testRetryPolicy");
+ assertThat(getPropertyValueAsString(beanDefinition, "speculativeExecutionPolicy"))
+ .isEqualTo("testSpeculativeExecutionPolicy");
+ assertThat(getPropertyValueAsString(beanDefinition, "sslOptions")).isEqualTo("testSslOptions");
+ assertThat(getPropertyValueAsString(beanDefinition, "timestampGenerator")).isEqualTo("testTimestampGenerator");
+ assertThat(getPropertyValueAsString(beanDefinition, "clusterName")).isEqualTo("testCluster");
+ assertThat(getPropertyValueAsString(beanDefinition, "contactPoints")).isEqualTo("skullbox");
+ assertThat(getPropertyValueAsString(beanDefinition, "compressionType")).isEqualTo("SNAPPY");
+ assertThat(getPropertyValueAsString(beanDefinition, "jmxReportingEnabled")).isEqualTo("true");
+ assertThat(getPropertyValueAsString(beanDefinition, "maxSchemaAgreementWaitSeconds")).isEqualTo("30");
+ assertThat(getPropertyValueAsString(beanDefinition, "metricsEnabled")).isEqualTo("true");
+ assertThat(getPropertyValueAsString(beanDefinition, "password")).isEqualTo("p@55w0rd");
+ assertThat(getPropertyValueAsString(beanDefinition, "port")).isEqualTo("12345");
+ assertThat(getPropertyValueAsString(beanDefinition, "sslEnabled")).isEqualTo("true");
+ assertThat(getPropertyValueAsString(beanDefinition, "username")).isEqualTo("jonDoe");
verify(mockContainingBeanDefinition).getScope();
verify(mockElement).getAttribute(eq("address-translator-ref"));
@@ -202,20 +200,21 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition poolingOptionsBeanDefinition = getPropertyValue(beanDefinition, "poolingOptions");
- assertThat(poolingOptionsBeanDefinition, is(notNullValue(BeanDefinition.class)));
- assertThat(poolingOptionsBeanDefinition.getBeanClassName(), is(equalTo(PoolingOptionsFactoryBean.class.getName())));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "heartbeatIntervalSeconds"), is(equalTo("15")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "idleTimeoutSeconds"), is(equalTo("120")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "initializationExecutor"), is(equalTo("testExecutor")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "poolTimeoutMilliseconds"), is(equalTo("60000")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localCoreConnections"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxConnections"), is(equalTo("200")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxSimultaneousRequests"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMinSimultaneousRequests"), is(equalTo("5")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteCoreConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMinSimultaneousRequests"), is(nullValue()));
+ assertThat(poolingOptionsBeanDefinition).isNotNull();
+ assertThat(poolingOptionsBeanDefinition.getBeanClassName()).isEqualTo(PoolingOptionsFactoryBean.class.getName());
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "heartbeatIntervalSeconds")).isEqualTo("15");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "idleTimeoutSeconds")).isEqualTo("120");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "initializationExecutor"))
+ .isEqualTo("testExecutor");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "poolTimeoutMilliseconds")).isEqualTo("60000");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localCoreConnections")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxConnections")).isEqualTo("200");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxSimultaneousRequests")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMinSimultaneousRequests")).isEqualTo("5");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteCoreConnections")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxConnections")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMinSimultaneousRequests")).isNull();
verify(mockElement).getChildNodes();
verify(mockElement).getAttribute(eq("heartbeat-interval-seconds"));
@@ -258,22 +257,21 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition poolingOptionsBeanDefinition = getPropertyValue(beanDefinition, "poolingOptions");
- assertThat(poolingOptionsBeanDefinition, is(notNullValue(BeanDefinition.class)));
- assertThat(poolingOptionsBeanDefinition.getBeanClassName(), is(equalTo(PoolingOptionsFactoryBean.class.getName())));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "heartbeatIntervalSeconds"), is(equalTo("15")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "idleTimeoutSeconds"), is(equalTo("120")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "initializationExecutor"), is(equalTo("testExecutor")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "poolTimeoutMilliseconds"), is(equalTo("60000")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localCoreConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMinSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteCoreConnections"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxConnections"), is(equalTo("200")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxSimultaneousRequests"), is(equalTo(
- "50")));
- assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMinSimultaneousRequests"), is(equalTo(
- "5")));
+ assertThat(poolingOptionsBeanDefinition).isNotNull();
+ assertThat(poolingOptionsBeanDefinition.getBeanClassName()).isEqualTo(PoolingOptionsFactoryBean.class.getName());
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "heartbeatIntervalSeconds")).isEqualTo("15");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "idleTimeoutSeconds")).isEqualTo("120");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "initializationExecutor"))
+ .isEqualTo("testExecutor");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "poolTimeoutMilliseconds")).isEqualTo("60000");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localCoreConnections")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxConnections")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMaxSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "localMinSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteCoreConnections")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxConnections")).isEqualTo("200");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMaxSimultaneousRequests")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(poolingOptionsBeanDefinition, "remoteMinSimultaneousRequests")).isEqualTo("5");
verify(mockElement).getChildNodes();
verify(mockElement).getAttribute(eq("heartbeat-interval-seconds"));
@@ -307,8 +305,7 @@ public class CassandraCqlClusterParserUnitTests {
when(mockShutdownCqlOne.getTextContent()).thenReturn("DROP KEYSPACE test;");
when(mockShutdownCqlTwo.getTextContent()).thenReturn("DROP USER jblum;");
- NodeList mockNodeList = mockNodeList(mockStartupCqlOne, mockStartupCqlTwo,
- mockShutdownCqlOne, mockShutdownCqlTwo);
+ NodeList mockNodeList = mockNodeList(mockStartupCqlOne, mockStartupCqlTwo, mockShutdownCqlOne, mockShutdownCqlTwo);
when(mockElement.getChildNodes()).thenReturn(mockNodeList);
@@ -319,10 +316,10 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition beanDefinition = builder.getBeanDefinition();
List startupScripts = getPropertyValue(beanDefinition, "startupScripts");
- assertThat(startupScripts, contains("CREATE KEYSPACE test;", "CREATE TABLE test.table;"));
+ assertThat(startupScripts).contains("CREATE KEYSPACE test;", "CREATE TABLE test.table;");
List shutdownScripts = getPropertyValue(beanDefinition, "shutdownScripts");
- assertThat(shutdownScripts, contains("DROP KEYSPACE test;", "DROP USER jblum;"));
+ assertThat(shutdownScripts).contains("DROP KEYSPACE test;", "DROP USER jblum;");
}
/**
@@ -342,18 +339,18 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition beanDefinition = builder.getBeanDefinition();
- assertThat(getPropertyValueAsString(beanDefinition, "heartbeatIntervalSeconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "idleTimeoutSeconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "initializationExecutor"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "poolTimeoutMilliseconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "localCoreConnections"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(beanDefinition, "localMaxConnections"), is(equalTo("200")));
- assertThat(getPropertyValueAsString(beanDefinition, "localMaxSimultaneousRequests"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(beanDefinition, "localMinSimultaneousRequests"), is(equalTo("5")));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteCoreConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMinSimultaneousRequests"), is(nullValue()));
+ assertThat(getPropertyValueAsString(beanDefinition, "heartbeatIntervalSeconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "idleTimeoutSeconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "initializationExecutor")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "poolTimeoutMilliseconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "localCoreConnections")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(beanDefinition, "localMaxConnections")).isEqualTo("200");
+ assertThat(getPropertyValueAsString(beanDefinition, "localMaxSimultaneousRequests")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(beanDefinition, "localMinSimultaneousRequests")).isEqualTo("5");
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteCoreConnections")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxConnections")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMinSimultaneousRequests")).isNull();
verify(mockElement, never()).getAttribute(eq("heartbeat-interval-seconds"));
verify(mockElement, never()).getAttribute(eq("idle-timeout-seconds"));
@@ -382,18 +379,18 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition beanDefinition = builder.getBeanDefinition();
- assertThat(getPropertyValueAsString(beanDefinition, "heartbeatIntervalSeconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "idleTimeoutSeconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "initializationExecutor"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "poolTimeoutMilliseconds"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "localCoreConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "localMaxConnections"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "localMaxSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "localMinSimultaneousRequests"), is(nullValue()));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteCoreConnections"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxConnections"), is(equalTo("200")));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxSimultaneousRequests"), is(equalTo("50")));
- assertThat(getPropertyValueAsString(beanDefinition, "remoteMinSimultaneousRequests"), is(equalTo("5")));
+ assertThat(getPropertyValueAsString(beanDefinition, "heartbeatIntervalSeconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "idleTimeoutSeconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "initializationExecutor")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "poolTimeoutMilliseconds")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "localCoreConnections")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "localMaxConnections")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "localMaxSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "localMinSimultaneousRequests")).isNull();
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteCoreConnections")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxConnections")).isEqualTo("200");
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMaxSimultaneousRequests")).isEqualTo("50");
+ assertThat(getPropertyValueAsString(beanDefinition, "remoteMinSimultaneousRequests")).isEqualTo("5");
verify(mockElement, never()).getAttribute(eq("heartbeat-interval-seconds"));
verify(mockElement, never()).getAttribute(eq("idle-timeout-seconds"));
@@ -412,7 +409,7 @@ public class CassandraCqlClusterParserUnitTests {
public void parseScript() {
when(mockElement.getTextContent()).thenReturn("CREATE TABLE schema.table;");
- assertThat(parser.parseScript(mockElement), is(equalTo("CREATE TABLE schema.table;")));
+ assertThat(parser.parseScript(mockElement)).isEqualTo("CREATE TABLE schema.table;");
verify(mockElement).getTextContent();
}
@@ -433,17 +430,17 @@ public class CassandraCqlClusterParserUnitTests {
BeanDefinition beanDefinition = parser.newSocketOptionsBeanDefinition(mockElement, mockParserContext(null));
- assertThat(beanDefinition, is(notNullValue(BeanDefinition.class)));
- assertThat(beanDefinition.getBeanClassName(), is(equalTo(SocketOptionsFactoryBean.class.getName())));
- assertThat((Element) beanDefinition.getSource(), is(equalTo(mockElement)));
- assertThat(getPropertyValueAsString(beanDefinition, "connectTimeoutMillis"), is(equalTo("15000")));
- assertThat(getPropertyValueAsString(beanDefinition, "keepAlive"), is(equalTo("true")));
- assertThat(getPropertyValueAsString(beanDefinition, "readTimeoutMillis"), is(equalTo("20000")));
- assertThat(getPropertyValueAsString(beanDefinition, "receiveBufferSize"), is(equalTo("32768")));
- assertThat(getPropertyValueAsString(beanDefinition, "reuseAddress"), is(equalTo("true")));
- assertThat(getPropertyValueAsString(beanDefinition, "sendBufferSize"), is(equalTo("16384")));
- assertThat(getPropertyValueAsString(beanDefinition, "soLinger"), is(equalTo("false")));
- assertThat(getPropertyValueAsString(beanDefinition, "tcpNoDelay"), is(equalTo("true")));
+ assertThat(beanDefinition).isNotNull();
+ assertThat(beanDefinition.getBeanClassName()).isEqualTo(SocketOptionsFactoryBean.class.getName());
+ assertThat((Element) beanDefinition.getSource()).isEqualTo(mockElement);
+ assertThat(getPropertyValueAsString(beanDefinition, "connectTimeoutMillis")).isEqualTo("15000");
+ assertThat(getPropertyValueAsString(beanDefinition, "keepAlive")).isEqualTo("true");
+ assertThat(getPropertyValueAsString(beanDefinition, "readTimeoutMillis")).isEqualTo("20000");
+ assertThat(getPropertyValueAsString(beanDefinition, "receiveBufferSize")).isEqualTo("32768");
+ assertThat(getPropertyValueAsString(beanDefinition, "reuseAddress")).isEqualTo("true");
+ assertThat(getPropertyValueAsString(beanDefinition, "sendBufferSize")).isEqualTo("16384");
+ assertThat(getPropertyValueAsString(beanDefinition, "soLinger")).isEqualTo("false");
+ assertThat(getPropertyValueAsString(beanDefinition, "tcpNoDelay")).isEqualTo("true");
verify(mockElement).getAttribute(eq("connect-timeout-millis"));
verify(mockElement).getAttribute(eq("keep-alive"));
@@ -470,7 +467,8 @@ public class CassandraCqlClusterParserUnitTests {
private ParserContext mockParserContext(BeanDefinition beanDefinition) {
- XmlReaderContext readerContext = new XmlReaderContext(null, null, null, new PassThroughSourceExtractor(), null, null);
+ XmlReaderContext readerContext = new XmlReaderContext(null, null, null, new PassThroughSourceExtractor(), null,
+ null);
return new ParserContext(readerContext, new BeanDefinitionParserDelegate(readerContext), beanDefinition);
}
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/ParsingUtilsUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/ParsingUtilsUnitTests.java
old mode 100644
new mode 100755
index 563198b6b..2af0756ea
--- a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/ParsingUtilsUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/ParsingUtilsUnitTests.java
@@ -16,8 +16,7 @@
package org.springframework.cassandra.config.xml;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.springframework.cassandra.support.BeanDefinitionTestUtils.*;
import org.junit.Rule;
@@ -48,8 +47,8 @@ public class ParsingUtilsUnitTests {
RuntimeBeanReference propertyValue = getPropertyValue(builder.getBeanDefinition(), "referenceProperty");
- assertThat(propertyValue, is(notNullValue(RuntimeBeanReference.class)));
- assertThat(propertyValue.getBeanName(), is(equalTo("defaultBeanReference")));
+ assertThat(propertyValue).isNotNull();
+ assertThat(propertyValue.getBeanName()).isEqualTo("defaultBeanReference");
}
/**
@@ -63,8 +62,8 @@ public class ParsingUtilsUnitTests {
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
- assertThat(beanDefinition.getPropertyValues().contains("referenceProperty"), is(false));
- assertThat(beanDefinition.getPropertyValues().isEmpty(), is(true));
+ assertThat(beanDefinition.getPropertyValues().contains("referenceProperty")).isFalse();
+ assertThat(beanDefinition.getPropertyValues().isEmpty()).isTrue();
}
/**
@@ -78,7 +77,7 @@ public class ParsingUtilsUnitTests {
String propertyValue = getPropertyValue(builder.getBeanDefinition(), "valueProperty");
- assertThat(propertyValue, is(equalTo("defaultValue")));
+ assertThat(propertyValue).isEqualTo("defaultValue");
}
/**
@@ -92,8 +91,8 @@ public class ParsingUtilsUnitTests {
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
- assertThat(beanDefinition.getPropertyValues().contains("valueProperty"), is(false));
- assertThat(beanDefinition.getPropertyValues().isEmpty(), is(true));
+ assertThat(beanDefinition.getPropertyValues().contains("valueProperty")).isFalse();
+ assertThat(beanDefinition.getPropertyValues().isEmpty()).isTrue();
}
/**
@@ -107,8 +106,8 @@ public class ParsingUtilsUnitTests {
RuntimeBeanReference propertyValue = getPropertyValue(builder.getBeanDefinition(), "referenceProperty");
- assertThat(propertyValue, is(notNullValue(RuntimeBeanReference.class)));
- assertThat(propertyValue.getBeanName(), is(equalTo("reference")));
+ assertThat(propertyValue).isNotNull();
+ assertThat(propertyValue.getBeanName()).isEqualTo("reference");
}
/**
@@ -118,7 +117,6 @@ public class ParsingUtilsUnitTests {
public void addRequiredReferencePropertyWithNoReferenceFails() {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("value required for property reference [referenceProperty] on class [null]");
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", null,
@@ -136,7 +134,7 @@ public class ParsingUtilsUnitTests {
String propertyValue = getPropertyValue(builder.getBeanDefinition(), "valueProperty");
- assertThat(propertyValue, is(equalTo("value")));
+ assertThat(propertyValue).isEqualTo("value");
}
/**
@@ -146,7 +144,6 @@ public class ParsingUtilsUnitTests {
public void addRequiredValuePropertyWithNoValueFails() {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("value required for property [valueProperty] on class [null]");
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null, "defaultValue", true,
@@ -160,7 +157,6 @@ public class ParsingUtilsUnitTests {
public void addPropertyThrowsIllegalArgumentExceptionForNullBuilder() {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("BeanDefinitionBuilder must not be null");
ParsingUtils.addProperty(null, "propertyName", "value", "defaultValue", false, false);
@@ -173,7 +169,6 @@ public class ParsingUtilsUnitTests {
public void addPropertyThrowsIllegalArgumentExceptionForNullPropertyName() {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("Property name must not be null");
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), null, "value", "defaultValue", false, true);
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java
old mode 100644
new mode 100755
index 46ca6b4a6..c66e3581c
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java
@@ -16,8 +16,7 @@
package org.springframework.cassandra.core;
import static edu.umd.cs.mtc.TestFramework.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
@@ -82,7 +81,7 @@ public class CachedPreparedStatementCreatorUnitTests {
PreparedStatement result = cachedPreparedStatementCreator.createPreparedStatement(sessionMock);
- assertThat(result, is(sameInstance(preparedStatement)));
+ assertThat(result).isSameAs(preparedStatement);
verify(sessionMock).prepare("my cql");
}
@@ -99,7 +98,7 @@ public class CachedPreparedStatementCreatorUnitTests {
PreparedStatement result = cachedPreparedStatementCreator.createPreparedStatement(sessionMock);
- assertThat(result, is(sameInstance(preparedStatement)));
+ assertThat(result).isSameAs(preparedStatement);
verify(sessionMock, times(1)).prepare("my cql");
}
@@ -150,7 +149,7 @@ public class CachedPreparedStatementCreatorUnitTests {
preparedStatementCreator.createPreparedStatement(session);
- assertThat(atomicInteger.get(), is(1));
+ assertThat(atomicInteger.get()).isEqualTo(1);
}
public void thread2() {
@@ -159,7 +158,7 @@ public class CachedPreparedStatementCreatorUnitTests {
preparedStatementCreator.createPreparedStatement(session);
- assertThat(atomicInteger.get(), is(1));
+ assertThat(atomicInteger.get()).isEqualTo(1);
}
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/ConsistencyLevelResolverUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/ConsistencyLevelResolverUnitTests.java
index f567706e0..1ab994de0 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/ConsistencyLevelResolverUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/ConsistencyLevelResolverUnitTests.java
@@ -15,8 +15,7 @@
*/
package org.springframework.cassandra.core;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -86,6 +85,6 @@ public class ConsistencyLevelResolverUnitTests {
*/
@Test
public void shouldResolveCorrectly() {
- assertThat(ConsistencyLevelResolver.resolve(from), is(equalTo(expected)));
+ assertThat(ConsistencyLevelResolver.resolve(from)).isEqualTo(expected);
}
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java
old mode 100644
new mode 100755
index 48eb53036..250bd455d
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java
@@ -15,8 +15,7 @@
*/
package org.springframework.cassandra.core;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Iterator;
@@ -93,7 +92,7 @@ public class CqlTemplateUnitTests {
}
});
- assertThat(result, is(equalTo("test")));
+ assertThat(result).isEqualTo("test");
verify(mockSession, times(1)).execute(eq("test"));
}
@@ -119,16 +118,18 @@ public class CqlTemplateUnitTests {
*/
@Test
public void doExecuteInSessionCallbackTranslatesToCassandraUncategorizedException() {
- exception.expect(CassandraUncategorizedException.class);
- exception.expectCause(org.hamcrest.Matchers.isA(DriverException.class));
- exception.expectMessage(containsString("test"));
- template.doExecute(new SessionCallback() {
- @Override
- public String doInSession(Session session) throws DataAccessException {
- throw new DriverException("test");
- }
- });
+ try {
+ template.doExecute(new SessionCallback() {
+ @Override
+ public String doInSession(Session session) throws DataAccessException {
+ throw new DriverException("test");
+ }
+ });
+ fail("Missing CassandraUncategorizedException");
+ } catch (CassandraUncategorizedException e) {
+ assertThat(e).hasMessageContaining("test").hasRootCauseInstanceOf(DriverException.class);
+ }
}
/**
@@ -136,25 +137,29 @@ public class CqlTemplateUnitTests {
*/
@Test
public void doExecuteInSessionCallbackTranslatesToCassandraUncategorizedDataAccessException() {
- exception.expect(CassandraUncategorizedDataAccessException.class);
- exception.expectCause(org.hamcrest.Matchers.isA(Error.class));
- exception.expectMessage(containsString("test"));
- template.doExecute(new SessionCallback() {
- @Override
- public String doInSession(Session session) throws DataAccessException {
- throw new Error("test");
- }
- });
+ try {
+ template.doExecute(new SessionCallback() {
+ @Override
+ public String doInSession(Session session) throws DataAccessException {
+ throw new Error("test");
+ }
+ });
+ fail("Missing CassandraUncategorizedException");
+ } catch (CassandraUncategorizedDataAccessException e) {
+ assertThat(e).hasMessageContaining("test").hasCauseInstanceOf(Error.class);
+ }
}
@Test
public void doExecuteWithNullSessionCallbackThrowsIllegalArgumentException() {
- exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage("SessionCallback must not be null");
- template.doExecute((SessionCallback) null);
+ try {
+ template.doExecute((SessionCallback) null);
+ fail("Missing IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertThat(e).hasMessageContaining("SessionCallback must not be null");
+ }
}
@Test
@@ -165,7 +170,7 @@ public class CqlTemplateUnitTests {
ResultSet resultSet = template.doExecuteQueryReturnResultSet("SELECT * FROM Customers");
- assertThat(resultSet, is(equalTo(mockResultSet)));
+ assertThat(resultSet).isEqualTo(mockResultSet);
verify(mockSession, times(1)).execute(eq("SELECT * FROM Customers"));
verifyZeroInteractions(mockResultSet);
@@ -180,7 +185,7 @@ public class CqlTemplateUnitTests {
ResultSet resultSet = template.doExecuteQueryReturnResultSet(mockSelect);
- assertThat(resultSet, is(equalTo(mockResultSet)));
+ assertThat(resultSet).isEqualTo(mockResultSet);
verify(mockSession, times(1)).execute(eq(mockSelect));
verifyZeroInteractions(mockResultSet);
@@ -205,14 +210,14 @@ public class CqlTemplateUnitTests {
template = new CqlTemplate() {
@Override
T columnToObject(Row row, ColumnDefinitions.Definition columnDefinition) {
- assertThat(row, is(sameInstance(mockRow)));
- assertThat(columnDefinition, is(sameInstance(mockColumnDefinition)));
+ assertThat(row).isSameAs(mockRow);
+ assertThat(columnDefinition).isSameAs(mockColumnDefinition);
return (T) "test";
}
};
- assertThat(String.valueOf(template.firstColumnToObject(mockRow)), is(equalTo("test")));
+ assertThat(String.valueOf(template.firstColumnToObject(mockRow))).isEqualTo("test");
verify(mockRow, times(1)).getColumnDefinitions();
verify(mockColumnDefinitions, times(1)).iterator();
@@ -235,7 +240,7 @@ public class CqlTemplateUnitTests {
when(mockColumnDefinitions.iterator()).thenReturn(mockIterator);
when(mockIterator.hasNext()).thenReturn(false);
- assertThat(template.firstColumnToObject(mockRow), is(nullValue(Object.class)));
+ assertThat(template.firstColumnToObject(mockRow)).isNull();
verify(mockRow, times(1)).getColumnDefinitions();
verify(mockColumnDefinitions, times(1)).iterator();
@@ -257,7 +262,7 @@ public class CqlTemplateUnitTests {
when(mockResultSet.isExhausted()).thenReturn(true);
when(mockRowMapper.mapRow(eq(mockRow), eq(0))).thenReturn("test");
- assertThat(template.processOne(mockResultSet, mockRowMapper), is(equalTo("test")));
+ assertThat(template.processOne(mockResultSet, mockRowMapper)).isEqualTo("test");
verify(mockResultSet, times(1)).one();
verify(mockResultSet, times(1)).isExhausted();
@@ -277,12 +282,11 @@ public class CqlTemplateUnitTests {
when(mockResultSet.one()).thenReturn(null);
try {
- exception.expect(IncorrectResultSizeDataAccessException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage(containsString("expected 1, actual 0"));
template.processOne(mockResultSet, mockRowMapper);
-
+ fail("Missing IncorrectResultSizeDataAccessException");
+ } catch (IncorrectResultSizeDataAccessException e) {
+ assertThat(e).hasMessageContaining("expected 1, actual 0");
} finally {
verify(mockResultSet, times(1)).one();
verify(mockResultSet, never()).isExhausted();
@@ -304,12 +308,10 @@ public class CqlTemplateUnitTests {
when(mockResultSet.isExhausted()).thenReturn(false);
try {
- exception.expect(IncorrectResultSizeDataAccessException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage("ResultSet size exceeds 1");
-
template.processOne(mockResultSet, mockRowMapper);
-
+ fail("Missing IncorrectResultSizeDataAccessException");
+ } catch (IncorrectResultSizeDataAccessException e) {
+ assertThat(e).hasMessage("ResultSet size exceeds 1");
} finally {
verify(mockResultSet, times(1)).one();
verify(mockResultSet, times(1)).isExhausted();
@@ -328,8 +330,6 @@ public class CqlTemplateUnitTests {
try {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
-
template.processOne(null, mockRowMapper);
} finally {
verifyZeroInteractions(mockRowMapper);
@@ -351,15 +351,14 @@ public class CqlTemplateUnitTests {
template = new CqlTemplate() {
@Override
protected Object firstColumnToObject(Row row) {
- assertThat(row, is(equalTo(mockRow)));
+ assertThat(row).isEqualTo(mockRow);
return 1L;
}
};
Number value = template.processOne(mockResultSet, Long.class);
- assertThat(value, is(instanceOf(Long.class)));
- assertThat(value.longValue(), is(equalTo(1L)));
+ assertThat(value).isInstanceOf(Long.class).isEqualTo(1L);
verify(mockResultSet, times(1)).one();
verify(mockResultSet, times(1)).isExhausted();
@@ -377,12 +376,10 @@ public class CqlTemplateUnitTests {
when(mockResultSet.one()).thenReturn(null);
try {
- exception.expect(IncorrectResultSizeDataAccessException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage(containsString("expected 1, actual 0"));
-
template.processOne(mockResultSet, Integer.class);
-
+ fail("Missing IncorrectResultSizeDataAccessException");
+ } catch (IncorrectResultSizeDataAccessException e) {
+ assertThat(e).hasMessageContaining("expected 1, actual 0");
} finally {
verify(mockResultSet, times(1)).one();
verify(mockResultSet, never()).isExhausted();
@@ -402,12 +399,11 @@ public class CqlTemplateUnitTests {
when(mockResultSet.isExhausted()).thenReturn(false);
try {
- exception.expect(IncorrectResultSizeDataAccessException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage(containsString("ResultSet size exceeds 1"));
-
template.processOne(mockResultSet, Double.class);
+ fail("Missing IncorrectResultSizeDataAccessException");
+ } catch (IncorrectResultSizeDataAccessException e) {
+ assertThat(e).hasMessageContaining("ResultSet size exceeds 1");
} finally {
verify(mockResultSet, times(1)).one();
verify(mockResultSet, times(1)).isExhausted();
@@ -421,7 +417,6 @@ public class CqlTemplateUnitTests {
@Test
public void processOneWithRequiredTypePassingNullResultSetThrowsIllegalArgumentException() {
exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
template.processOne(null, String.class);
}
@@ -465,8 +460,7 @@ public class CqlTemplateUnitTests {
@Test
public void addStatementQueryOptionsShouldAddDriverQueryOptions() {
- QueryOptions queryOptions = QueryOptions.builder()
- .consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
+ QueryOptions queryOptions = QueryOptions.builder().consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
.retryPolicy(FallthroughRetryPolicy.INSTANCE) //
.build();
@@ -555,8 +549,7 @@ public class CqlTemplateUnitTests {
.consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
.retryPolicy(FallthroughRetryPolicy.INSTANCE) //
.ttl(10) //
- .tracing(false)
- .build();
+ .tracing(false).build();
template.addWriteOptions(mockUpdate, writeOptions);
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/QueryOptionsUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/QueryOptionsUnitTests.java
index 149e865a3..632e79cf1 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/QueryOptionsUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/QueryOptionsUnitTests.java
@@ -15,8 +15,7 @@
*/
package org.springframework.cassandra.core;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.concurrent.TimeUnit;
@@ -48,13 +47,13 @@ public class QueryOptionsUnitTests {
.tracing(true)//
.build(); //
- assertThat((Class) queryOptions.getClass(), is(equalTo((Class) QueryOptions.class)));
- assertThat(queryOptions.getRetryPolicy(), is(RetryPolicy.DEFAULT));
- assertThat(queryOptions.getConsistencyLevel(), is(nullValue()));
- assertThat(queryOptions.getDriverConsistencyLevel(), is(ConsistencyLevel.ANY));
- assertThat(queryOptions.getReadTimeout(), is(1000L));
- assertThat(queryOptions.getFetchSize(), is(10));
- assertThat(queryOptions.getTracing(), is(true));
+ assertThat(queryOptions.getClass()).isEqualTo(QueryOptions.class);
+ assertThat(queryOptions.getRetryPolicy()).isEqualTo(RetryPolicy.DEFAULT);
+ assertThat(queryOptions.getConsistencyLevel()).isNull();
+ assertThat(queryOptions.getDriverConsistencyLevel()).isEqualTo(ConsistencyLevel.ANY);
+ assertThat(queryOptions.getReadTimeout()).isEqualTo(1000);
+ assertThat(queryOptions.getFetchSize()).isEqualTo(10);
+ assertThat(queryOptions.getTracing()).isTrue();
}
/**
@@ -67,8 +66,8 @@ public class QueryOptionsUnitTests {
.retryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)) //
.build(); //
- assertThat(writeOptions.getRetryPolicy(), is(nullValue()));
- assertThat(writeOptions.getDriverRetryPolicy(), is(instanceOf(LoggingRetryPolicy.class)));
+ assertThat(writeOptions.getRetryPolicy()).isNull();
+ assertThat(writeOptions.getDriverRetryPolicy()).isInstanceOf(LoggingRetryPolicy.class);
}
/**
@@ -81,8 +80,8 @@ public class QueryOptionsUnitTests {
.retryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY) //
.build(); //
- assertThat(writeOptions.getRetryPolicy(), is(RetryPolicy.DOWNGRADING_CONSISTENCY));
- assertThat(writeOptions.getDriverRetryPolicy(), is(nullValue()));
+ assertThat(writeOptions.getRetryPolicy()).isEqualTo(RetryPolicy.DOWNGRADING_CONSISTENCY);
+ assertThat(writeOptions.getDriverRetryPolicy()).isNull();
}
/**
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/WriteOptionsUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/WriteOptionsUnitTests.java
index 2b7943c6c..06d74d3c5 100644
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/WriteOptionsUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/WriteOptionsUnitTests.java
@@ -15,8 +15,7 @@
*/
package org.springframework.cassandra.core;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.concurrent.TimeUnit;
@@ -46,13 +45,13 @@ public class WriteOptionsUnitTests {
.withTracing()//
.build(); //
- assertThat(writeOptions.getTtl(), is(123));
- assertThat(writeOptions.getRetryPolicy(), is(RetryPolicy.DEFAULT));
- assertThat(writeOptions.getConsistencyLevel(), is(nullValue()));
- assertThat(writeOptions.getDriverConsistencyLevel(), is(com.datastax.driver.core.ConsistencyLevel.ANY));
- assertThat(writeOptions.getReadTimeout(), is(1L));
- assertThat(writeOptions.getFetchSize(), is(10));
- assertThat(writeOptions.getTracing(), is(true));
+ assertThat(writeOptions.getTtl()).isEqualTo(123);
+ assertThat(writeOptions.getRetryPolicy()).isEqualTo(RetryPolicy.DEFAULT);
+ assertThat(writeOptions.getConsistencyLevel()).isNull();
+ assertThat(writeOptions.getDriverConsistencyLevel()).isEqualTo(com.datastax.driver.core.ConsistencyLevel.ANY);
+ assertThat(writeOptions.getReadTimeout()).isEqualTo(1);
+ assertThat(writeOptions.getFetchSize()).isEqualTo(10);
+ assertThat(writeOptions.getTracing()).isTrue();
}
/**
@@ -63,9 +62,9 @@ public class WriteOptionsUnitTests {
WriteOptions writeOptions = WriteOptions.builder().readTimeout(1, TimeUnit.MINUTES).build();
- assertThat(writeOptions.getReadTimeout(), is(60L * 1000L));
- assertThat(writeOptions.getFetchSize(), is(nullValue()));
- assertThat(writeOptions.getTracing(), is(nullValue()));
+ assertThat(writeOptions.getReadTimeout()).isEqualTo(60L * 1000L);
+ assertThat(writeOptions.getFetchSize()).isNull();
+ assertThat(writeOptions.getTracing()).isNull();
}
/**
@@ -76,9 +75,8 @@ public class WriteOptionsUnitTests {
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).build();
- assertThat(writeOptions.getRetryPolicy(), is(nullValue()));
- assertThat(writeOptions.getDriverRetryPolicy(),
- is(equalTo((com.datastax.driver.core.policies.RetryPolicy) FallthroughRetryPolicy.INSTANCE)));
+ assertThat(writeOptions.getRetryPolicy()).isNull();
+ assertThat(writeOptions.getDriverRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE);
}
/**
@@ -89,8 +87,8 @@ public class WriteOptionsUnitTests {
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY).build();
- assertThat(writeOptions.getRetryPolicy(), is(RetryPolicy.DOWNGRADING_CONSISTENCY));
- assertThat(writeOptions.getDriverRetryPolicy(), is(nullValue()));
+ assertThat(writeOptions.getRetryPolicy()).isEqualTo(RetryPolicy.DOWNGRADING_CONSISTENCY);
+ assertThat(writeOptions.getDriverRetryPolicy()).isNull();
}
/**
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
old mode 100644
new mode 100755
index 0209e72ca..75ba52efb
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/CqlIdentifierUnitTests.java
@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import static org.springframework.cassandra.core.cql.CqlIdentifier.*;
import org.junit.Test;
@@ -36,8 +36,8 @@ public class CqlIdentifierUnitTests {
for (String id : ids) {
CqlIdentifier cqlId = cqlId(id);
- assertFalse(cqlId.isQuoted());
- assertEquals(id.toLowerCase(), cqlId.toCql());
+ assertThat(cqlId.isQuoted()).isFalse();
+ assertThat(cqlId.toCql()).isEqualTo(id.toLowerCase());
}
}
@@ -48,8 +48,8 @@ public class CqlIdentifierUnitTests {
for (String id : ids) {
CqlIdentifier cqlId = quotedCqlId(id);
- assertTrue(cqlId.isQuoted());
- assertEquals("\"" + id + "\"", cqlId.toCql());
+ assertThat(cqlId.isQuoted()).isTrue();
+ assertThat(cqlId.toCql()).isEqualTo("\"" + id + "\"");
}
}
@@ -58,12 +58,12 @@ public class CqlIdentifierUnitTests {
for (ReservedKeyword id : ReservedKeyword.values()) {
CqlIdentifier cqlId = cqlId(id.name());
- assertTrue(cqlId.isQuoted());
- assertEquals("\"" + id.name() + "\"", cqlId.toCql());
+ assertThat(cqlId.isQuoted()).isTrue();
+ assertThat(cqlId.toCql()).isEqualTo("\"" + id.name() + "\"");
cqlId = cqlId(id.name().toLowerCase());
- assertTrue(cqlId.isQuoted());
- assertEquals("\"" + id.name().toLowerCase() + "\"", cqlId.toCql());
+ assertThat(cqlId.isQuoted()).isTrue();
+ assertThat(cqlId.toCql()).isEqualTo("\"" + id.name().toLowerCase() + "\"");
}
}
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractIndexOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractIndexOperationCqlGeneratorTest.java
old mode 100644
new mode 100755
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractKeyspaceOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractKeyspaceOperationCqlGeneratorTest.java
old mode 100644
new mode 100755
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractTableOperationCqlGeneratorTest.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AbstractTableOperationCqlGeneratorTest.java
old mode 100644
new mode 100755
diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
old mode 100644
new mode 100755
index 4c302d5d3..b7cf0a461
--- a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
+++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java
@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
@@ -39,20 +39,20 @@ public class AlterKeyspaceCqlGeneratorUnitTests {
* Asserts that the preamble is first & correctly formatted in the given CQL string.
*/
public static void assertPreamble(String tableName, String cql) {
- assertTrue(cql.startsWith("ALTER KEYSPACE " + tableName + " "));
+ assertThat(cql.startsWith("ALTER KEYSPACE " + tableName + " ")).isTrue();
}
private static void assertReplicationMap(Map