TAMAYA-218: Migrate test assertions to AssertJ
diff --git a/camel/pom.xml b/camel/pom.xml
index b303fee..1d2cf77 100644
--- a/camel/pom.xml
+++ b/camel/pom.xml
@@ -61,6 +61,10 @@
<artifactId>java-hamcrest</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.tamaya</groupId>
diff --git a/camel/src/test/java/org/apache/tamaya/camel/TamayaPropertyResolverTest.java b/camel/src/test/java/org/apache/tamaya/camel/TamayaPropertyResolverTest.java
index 10ffa9b..ee7af5e 100644
--- a/camel/src/test/java/org/apache/tamaya/camel/TamayaPropertyResolverTest.java
+++ b/camel/src/test/java/org/apache/tamaya/camel/TamayaPropertyResolverTest.java
@@ -28,7 +28,7 @@
import java.io.InputStream;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for integration of Tamaya with Apache Camel using Java DSL and XML DSL.
@@ -49,7 +49,7 @@
// test configuration is injected right...
Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greetMessage);
}
@Test
@@ -66,7 +66,7 @@
// test configuration is injected right...
Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greetMessage);
}
@Test
@@ -85,7 +85,7 @@
// test configuration is injected right...
Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greetMessage);
}
@Test
@@ -103,14 +103,14 @@
}
camelContext.start();
Greeter greeter = new ProxyBuilder(camelContext).endpoint("direct:hello1").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greeter.greet());
greeter = new ProxyBuilder(camelContext).endpoint("direct:hello2").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greeter.greet());
greeter = new ProxyBuilder(camelContext).endpoint("direct:hello3").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
+ assertThat("Good Bye from Apache Tamaya!").isEqualTo(greeter.greet());
}
public interface Greeter {
String greet();
}
-}
\ No newline at end of file
+}
diff --git a/configjsr/pom.xml b/configjsr/pom.xml
index fb52cc9..6345748 100644
--- a/configjsr/pom.xml
+++ b/configjsr/pom.xml
@@ -87,7 +87,6 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
- <version>${assertj.version}</version>
</dependency>
<!-- Config API -->
<dependency>
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigAdapterTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigAdapterTest.java
index c00949e..54e536d 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigAdapterTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigAdapterTest.java
@@ -24,7 +24,6 @@
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource;
-import org.assertj.core.api.Assertions;
import org.junit.Test;
import javax.config.Config;
@@ -36,15 +35,15 @@
import javax.config.spi.Converter;
import java.util.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
public class JavaConfigAdapterTest {
@Test
public void toConfig() throws Exception {
Configuration config = Configuration.current();
Config mpConfig = JavaConfigAdapterFactory.toConfig(config);
- assertNotNull(mpConfig);
- assertEquals(config.getProperties().keySet(), mpConfig.getPropertyNames());
+ assertThat(mpConfig).isNotNull();
+ assertThat(config.getProperties().keySet()).isEqualTo(mpConfig.getPropertyNames());
}
@Test
@@ -55,7 +54,7 @@
Config result = JavaConfigAdapterFactory.toConfig(tamayaConfiguration);
- Assertions.assertThat(result).isNotNull()
+ assertThat(result).isNotNull()
.isInstanceOf(JavaConfigAdapter.class)
.isSameAs(config);
}
@@ -64,8 +63,8 @@
public void toConfiguration() throws Exception {
Config mpConfig = ConfigProvider.getConfig();
Configuration config = JavaConfigAdapterFactory.toConfiguration(mpConfig);
- assertNotNull(config);
- assertEquals(mpConfig.getPropertyNames(), config.getProperties().keySet());
+ assertThat(config).isNotNull();
+ assertThat(mpConfig.getPropertyNames()).isEqualTo(config.getProperties().keySet());
}
@Test
@@ -73,7 +72,7 @@
Config config = new MyConfig();
Configuration result = JavaConfigAdapterFactory.toConfiguration(config);
- Assertions.assertThat(result).isNotNull()
+ assertThat(result).isNotNull()
.isInstanceOf(TamayaConfigurationAdapter.class);
}
@@ -87,17 +86,17 @@
List<PropertySource> tamayaSources = new ArrayList<>();
tamayaSources.add(testPropertySource);
List<ConfigSource> configSources = JavaConfigAdapterFactory.toConfigSources(tamayaSources);
- assertNotNull(configSources);
- assertEquals(tamayaSources.size(), configSources.size());
+ assertThat(configSources).isNotNull();
+ assertThat(tamayaSources.size()).isEqualTo(configSources.size());
compare(testPropertySource, configSources.get(0));
}
private void compare(PropertySource tamayaSource, ConfigSource mpSource) {
- assertEquals(mpSource.getName(),tamayaSource.getName());
- assertEquals(mpSource.getOrdinal(), tamayaSource.getOrdinal());
- assertEquals(mpSource.getProperties().keySet(), tamayaSource.getProperties().keySet());
+ assertThat(mpSource.getName()).isEqualTo(tamayaSource.getName());
+ assertThat(mpSource.getOrdinal()).isEqualTo(tamayaSource.getOrdinal());
+ assertThat(mpSource.getProperties().keySet()).isEqualTo(tamayaSource.getProperties().keySet());
for(String key:mpSource.getPropertyNames()){
- assertEquals(mpSource.getValue(key), tamayaSource.get(key).getValue());
+ assertThat(mpSource.getValue(key)).isEqualTo(tamayaSource.get(key).getValue());
}
}
@@ -111,8 +110,8 @@
List<ConfigSource> configSources = new ArrayList<>();
configSources.add(configSource);
List<PropertySource> propertySources = JavaConfigAdapterFactory.toPropertySources(configSources);
- assertNotNull(propertySources);
- assertEquals(propertySources.size(), configSources.size());
+ assertThat(propertySources).isNotNull();
+ assertThat(propertySources.size()).isEqualTo(configSources.size());
compare(propertySources.get(0), configSource);
}
@@ -124,7 +123,7 @@
.withSimpleProperty("int0", "0")
.build();
ConfigSource configSource = JavaConfigAdapterFactory.toConfigSource(tamayaSource);
- assertNotNull(configSource);
+ assertThat(configSource).isNotNull();
compare(tamayaSource, configSource);
}
@@ -136,28 +135,28 @@
.withProperty("int0", "0")
.build();
PropertySource tamayaSource = JavaConfigAdapterFactory.toPropertySource(configSource);
- assertNotNull(configSource);
+ assertThat(configSource).isNotNull();
compare(tamayaSource, configSource);
}
@Test
public void toPropertyConverter() throws Exception {
PropertyConverter<String> tamayaConverter = JavaConfigAdapterFactory.toPropertyConverter(new UppercaseConverter());
- assertNotNull(tamayaConverter);
- assertEquals("ABC", tamayaConverter.convert("aBC", null));
+ assertThat(tamayaConverter).isNotNull();
+ assertThat("ABC").isEqualTo(tamayaConverter.convert("aBC", null));
}
@Test
public void toConverter() throws Exception {
Converter<String> mpConverter = JavaConfigAdapterFactory.toConverter(new UppercasePropertyConverter());
- assertNotNull(mpConverter);
- assertEquals("ABC", mpConverter.convert("aBC"));
+ assertThat(mpConverter).isNotNull();
+ assertThat("ABC").isEqualTo(mpConverter.convert("aBC"));
}
@Test
public void toConfigBuilder() throws Exception {
ConfigBuilder builder = JavaConfigAdapterFactory.toConfigBuilder(ConfigurationProvider.getConfigurationBuilder());
- assertNotNull(builder);
+ assertThat(builder).isNotNull();
}
@Test
@@ -165,9 +164,9 @@
Map<String,PropertyValue> props = new HashMap<>();
props.put("a", PropertyValue.of("a","b", "toStringMap"));
Map<String, String> mpProps = JavaConfigAdapterFactory.toStringMap(props);
- assertNotNull(mpProps);
- assertEquals(props.keySet(), mpProps.keySet());
- assertEquals(mpProps.get("a"), "b");
+ assertThat(mpProps).isNotNull();
+ assertThat(props.keySet()).isEqualTo(mpProps.keySet());
+ assertThat(mpProps.get("a")).isEqualTo("b");
}
@Test
@@ -175,10 +174,10 @@
Map<String,String> props = new HashMap<>();
props.put("a", "b");
Map<String, PropertyValue> tamayaProps = JavaConfigAdapterFactory.toPropertyValueMap(props, "toPropertyValueMap");
- assertNotNull(tamayaProps);
- assertEquals(tamayaProps.keySet(), props.keySet());
- assertEquals(tamayaProps.get("a").getValue(), "b");
- assertEquals("toPropertyValueMap", tamayaProps.get("a").getSource());
+ assertThat(tamayaProps).isNotNull();
+ assertThat(tamayaProps.keySet()).isEqualTo(props.keySet());
+ assertThat(tamayaProps.get("a").getValue()).isEqualTo("b");
+ assertThat("toPropertyValueMap").isEqualTo(tamayaProps.get("a").getSource());
}
static class MyConfig implements Config {
@@ -260,4 +259,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigBuilderTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigBuilderTest.java
index 445102e..b25f977 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigBuilderTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigBuilderTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya.jsr382;
-import org.assertj.core.api.Assertions;
import org.junit.Test;
import javax.config.Config;
@@ -31,7 +30,7 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by atsticks on 24.03.17.
@@ -63,40 +62,40 @@
@Test
public void testBuildEmptyConfig(){
ConfigBuilder builder = ConfigProviderResolver.instance().getBuilder();
- assertNotNull(builder);
+ assertThat(builder).isNotNull();
Config config = builder.build();
- assertNotNull(config);
- assertFalse(config.getPropertyNames().iterator().hasNext());
- assertFalse(config.getConfigSources().iterator().hasNext());
+ assertThat(config).isNotNull();
+ assertThat(config.getPropertyNames().iterator().hasNext()).isFalse();
+ assertThat(config.getConfigSources().iterator().hasNext()).isFalse();
}
@Test
public void testBuildConfig(){
ConfigBuilder builder = ConfigProviderResolver.instance().getBuilder();
- assertNotNull(builder);
+ assertThat(builder).isNotNull();
builder.withSources(testSource);
Config config = builder.build();
- assertNotNull(config);
- assertTrue(config.getPropertyNames().iterator().hasNext());
- assertTrue(config.getConfigSources().iterator().hasNext());
- assertNotNull(config.getValue("timestamp", String.class));
+ assertThat(config).isNotNull();
+ assertThat(config.getPropertyNames().iterator().hasNext()).isTrue();
+ assertThat(config.getConfigSources().iterator().hasNext()).isTrue();
+ assertThat(config.getValue("timestamp", String.class)).isNotNull();
ConfigSource src = config.getConfigSources().iterator().next();
- assertNotNull(src);
- assertEquals(src, testSource);
+ assertThat(src).isNotNull();
+ assertThat(src).isEqualTo(testSource);
}
@Test
public void testBuildDefaultConfig(){
ConfigBuilder builder = ConfigProviderResolver.instance().getBuilder();
- assertNotNull(builder);
+ assertThat(builder).isNotNull();
builder.addDefaultSources();
Config config = builder.build();
- assertNotNull(config);
- assertTrue(config.getPropertyNames().iterator().hasNext());
- assertTrue(config.getConfigSources().iterator().hasNext());
- assertNotNull(config.getValue("java.home", String.class));
+ assertThat(config).isNotNull();
+ assertThat(config.getPropertyNames().iterator().hasNext()).isTrue();
+ assertThat(config.getConfigSources().iterator().hasNext()).isTrue();
+ assertThat(config.getValue("java.home", String.class)).isNotNull();
ConfigSource src = config.getConfigSources().iterator().next();
- assertNotNull(src);
+ assertThat(src).isNotNull();
}
@Test
@@ -112,7 +111,7 @@
.map(ConfigSource::getName)
.collect(Collectors.toList());
- Assertions.assertThat(name).hasSize(4)
+ assertThat(name).hasSize(4)
.containsExactlyInAnyOrder("paris",
"SystemPropertySource",
"environment-properties",
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderResolverTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderResolverTest.java
index 7c43bdc..5c8681c 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderResolverTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderResolverTest.java
@@ -25,7 +25,7 @@
import java.net.URL;
import java.net.URLClassLoader;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
/**
* Created by atsticks on 24.03.17.
@@ -34,39 +34,39 @@
@Test
public void testInstance(){
- assertNotNull(ConfigProviderResolver.instance());
+ assertThat(ConfigProviderResolver.instance()).isNotNull();
}
@Test
public void testGetBuilder(){
- assertNotNull(ConfigProviderResolver.instance().getBuilder());
+ assertThat(ConfigProviderResolver.instance().getBuilder()).isNotNull();
}
@Test
public void testGetConfig(){
- assertNotNull(ConfigProviderResolver.instance().getConfig());
+ assertThat(ConfigProviderResolver.instance().getConfig()).isNotNull();
}
@Test
public void testGetConfig_CL(){
- assertNotNull(ConfigProviderResolver.instance().getConfig(ClassLoader.getSystemClassLoader()));
+ assertThat(ConfigProviderResolver.instance().getConfig(ClassLoader.getSystemClassLoader())).isNotNull();
}
@Test
public void testRegisterAndReleaseConfig(){
ClassLoader cl = new URLClassLoader(new URL[]{});
Config emptyConfig = ConfigProviderResolver.instance().getBuilder().build();
- assertNotNull(emptyConfig);
+ assertThat(emptyConfig).isNotNull();
Config cfg = ConfigProviderResolver.instance().getConfig(cl);
- assertNotNull(cfg);
+ assertThat(cfg).isNotNull();
ConfigProviderResolver.instance().registerConfig(emptyConfig, cl);
cfg = ConfigProviderResolver.instance().getConfig(cl);
- assertNotNull(cfg);
- assertEquals(cfg, emptyConfig);
+ assertThat(cfg).isNotNull();
+ assertThat(cfg).isEqualTo(emptyConfig);
ConfigProviderResolver.instance().releaseConfig(emptyConfig);
cfg = ConfigProviderResolver.instance().getConfig(cl);
- assertNotNull(cfg);
- assertNotSame(cfg, emptyConfig);
+ assertThat(cfg).isNotNull();
+ assertThat(cfg).isNotSameAs(emptyConfig);
}
}
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderTest.java
index c69af54..b2c9243 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigProviderTest.java
@@ -24,8 +24,7 @@
import javax.config.Config;
import javax.config.ConfigProvider;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by atsticks on 24.03.17.
@@ -35,9 +34,9 @@
@Test
public void testDefaultConfigAccess(){
Config config = ConfigProvider.getConfig();
- assertNotNull(config);
+ assertThat(config).isNotNull();
Iterable<String> names = config.getPropertyNames();
- assertNotNull(names);
+ assertThat(names).isNotNull();
int count = 0;
for(String name:names){
count++;
@@ -47,20 +46,20 @@
for(String s:ConfigProvider.getConfig().getPropertyNames()){
cfgCount++;
}
- assertTrue(cfgCount <= count);
+ assertThat(cfgCount <= count).isTrue();
}
@Test
public void testClassloaderAccess(){
Config config = ConfigProvider.getConfig(Thread.currentThread().getContextClassLoader());
- assertNotNull(config);
+ assertThat(config).isNotNull();
Iterable<String> names = config.getPropertyNames();
- assertNotNull(names);
+ assertThat(names).isNotNull();
int count = 0;
for(String name:names){
count++;
}
- assertTrue(count>0);
+ assertThat(count > 0).isTrue();
}
}
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigSourceProviderTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigSourceProviderTest.java
index 3552a4a..6dffa6d 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigSourceProviderTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigSourceProviderTest.java
@@ -24,7 +24,7 @@
import javax.config.spi.ConfigSource;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
public class JavaConfigConfigSourceProviderTest {
@Test
@@ -35,11 +35,11 @@
.withSimpleProperty("a", "b").build())
.build();
JavaConfigSourceProvider provider = new JavaConfigSourceProvider(prov);
- assertNotNull(provider);
+ assertThat(provider).isNotNull();
Iterable<ConfigSource> configSources = provider.getConfigSources(null);
- assertNotNull(configSources);
- assertTrue(configSources.iterator().hasNext());
- assertEquals("b", configSources.iterator().next().getValue("a"));
+ assertThat(configSources).isNotNull();
+ assertThat(configSources.iterator().hasNext()).isTrue();
+ assertThat("b").isEqualTo(configSources.iterator().next().getValue("a"));
}
-}
\ No newline at end of file
+}
diff --git a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigTest.java b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigTest.java
index 06685e1..3e0d7ae 100644
--- a/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigTest.java
+++ b/configjsr/src/test/java/org/apache/tamaya/jsr382/JavaConfigConfigTest.java
@@ -26,7 +26,7 @@
import java.util.NoSuchElementException;
import java.util.Optional;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
/**
* Created by atsticks on 24.03.17.
@@ -41,7 +41,7 @@
for (ConfigSource cs : sources) {
count++;
}
- assertEquals(4, count);
+ assertThat(4).isEqualTo(count);
}
@Test
@@ -50,10 +50,10 @@
int count = 0;
for(String key:config.getPropertyNames()){
Optional<String> val = config.getOptionalValue(key, String.class);
- assertNotNull(val);
+ assertThat(val).isNotNull();
val = config.getOptionalValue(key + System.currentTimeMillis(), String.class);
- assertNotNull(val);
- assertFalse(val.isPresent());
+ assertThat(val).isNotNull();
+ assertThat(val.isPresent()).isFalse();
}
}
@@ -63,7 +63,7 @@
int count = 0;
for(String key:config.getPropertyNames()){
String val = config.getValue(key, String.class);
- assertNotNull(val);
+ assertThat(val).isNotNull();
}
}
@@ -83,13 +83,13 @@
public void testEmptySystemProperty(){
System.setProperty("my.empty.property", "");
Config config = ConfigProvider.getConfig();
- assertEquals("", config.getValue("my.empty.property", String.class));
+ assertThat("").isEqualTo(config.getValue("my.empty.property", String.class));
}
@Test
public void testEmptyConfigProperty(){
Config config = ConfigProvider.getConfig();
- assertEquals("", config.getValue("my.empty.property.in.config.file", String.class));
+ assertThat("").isEqualTo(config.getValue("my.empty.property.in.config.file", String.class));
}
}
diff --git a/documentation/pom.xml b/documentation/pom.xml
index 8ac628f..033b2c9 100644
--- a/documentation/pom.xml
+++ b/documentation/pom.xml
@@ -64,6 +64,11 @@
<artifactId>java-hamcrest</artifactId>
</dependency>
<dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
diff --git a/documentation/src/test/java/org/apache/tamaya/doc/ConfigDocumenterTest.java b/documentation/src/test/java/org/apache/tamaya/doc/ConfigDocumenterTest.java
index 1979e74..1012699 100644
--- a/documentation/src/test/java/org/apache/tamaya/doc/ConfigDocumenterTest.java
+++ b/documentation/src/test/java/org/apache/tamaya/doc/ConfigDocumenterTest.java
@@ -22,7 +22,7 @@
import org.apache.tamaya.doc.formats.TextDocFormat;
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
public class ConfigDocumenterTest {
@@ -31,7 +31,7 @@
ConfigDocumenter reader = new ConfigDocumenter();
reader.readClasses(AnnotatedDocConfigBean.class);
DocumentedConfiguration documentation = reader.getDocumentation();
- assertNotNull(documentation);
+ assertThat(documentation).isNotNull();
System.out.println(new TextDocFormat().apply(documentation));
}
@@ -40,7 +40,7 @@
ConfigDocumenter reader = new ConfigDocumenter();
reader.readClasses(AnnotBasedStandaloneConfigDocumentation.class);
DocumentedConfiguration documentation = reader.getDocumentation();
- assertNotNull(documentation);
+ assertThat(documentation).isNotNull();
System.out.println(new TextDocFormat().apply(documentation));
}
@@ -49,7 +49,7 @@
ConfigDocumenter reader = new ConfigDocumenter();
reader.readPackages("org.apache.tamaya.doc");
DocumentedConfiguration documentation = reader.getDocumentation();
- assertNotNull(documentation);
+ assertThat(documentation).isNotNull();
System.out.println(new TextDocFormat().apply(documentation));
}
@@ -58,7 +58,7 @@
ConfigDocumenter reader = new ConfigDocumenter();
reader.readPackages("org.apache.tamaya.doc");
DocumentedConfiguration documentation = reader.getDocumentation();
- assertNotNull(documentation);
+ assertThat(documentation).isNotNull();
System.out.println(new HtmlDocFormat().apply(documentation));
}
-}
\ No newline at end of file
+}
diff --git a/hjson/src/test/java/org/apache/tamaya/hjson/CommonHJSONTestCaseCollection.java b/hjson/src/test/java/org/apache/tamaya/hjson/CommonHJSONTestCaseCollection.java
index 8bc7c88..d2a4238 100644
--- a/hjson/src/test/java/org/apache/tamaya/hjson/CommonHJSONTestCaseCollection.java
+++ b/hjson/src/test/java/org/apache/tamaya/hjson/CommonHJSONTestCaseCollection.java
@@ -21,17 +21,12 @@
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertyValue;
import org.apache.tamaya.spisupport.PropertySourceComparator;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
import java.net.URL;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Class with a collection of common test cases each JSON processing
@@ -46,14 +41,14 @@
URL configURL = CommonHJSONTestCaseCollection.class
.getResource("/configs/valid/cyrillic.hjson");
- assertThat(configURL, Matchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource propertySource = getPropertiesFrom(configURL);
- assertThat(propertySource.get("name"), Matchers.notNullValue());
- assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440"));
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue());
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer"));
+ assertThat(propertySource.get("name")).isNotNull();
+ assertThat(propertySource.get("name").getValue()).isEqualTo("\u041e\u043b\u0438\u0432\u0435\u0440");
+ assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f")).isNotNull();
+ assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue()).isEqualTo("Fischer");
}
@Test
@@ -61,13 +56,13 @@
URL configURL = CommonHJSONTestCaseCollection.class
.getResource("/configs/valid/kanji.hjson");
- assertThat(configURL, Matchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource propertySource = getPropertiesFrom(configURL);
- assertThat(propertySource.get("onamae"), Matchers.notNullValue());
+ assertThat(propertySource.get("onamae")).isNotNull();
// 霊屋 = Tamaya
- assertThat(propertySource.get("onamae").getValue(), equalTo("\u970a\u5c4b"));
+ assertThat(propertySource.get("onamae").getValue()).isEqualTo("\u970a\u5c4b");
}
@Test
@@ -75,24 +70,24 @@
URL configURL = CommonHJSONTestCaseCollection.class
.getResource("/configs/valid/simple-nested-string-only-config-1.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
System.out.println("simple-nested-string-only-config-1.json -> " + properties.getProperties().values());
- assertTrue(properties.getProperties().keySet().size()>=5);
+ assertThat(properties.getProperties().keySet().size() >= 5).isTrue();
PropertyValue keyB = properties.get("b");
PropertyValue keyDO = properties.get("d.o");
PropertyValue keyDP = properties.get("d.p");
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), equalTo("B"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, Matchers.notNullValue());
- assertThat(keyDP.getValue(), is("P"));
+ assertThat(keyB).isNotNull();
+ assertThat(keyB.getValue()).isEqualTo("B");
+ assertThat(keyDO).isNotNull();
+ assertThat(keyDO.getValue()).isEqualTo("O");
+ assertThat(keyDP).isNotNull();
+ assertThat(keyDP.getValue()).isEqualTo("P");
}
@Test
@@ -101,32 +96,32 @@
URL configURL = CommonHJSONTestCaseCollection.class
.getResource("/configs/valid/simple-nested-string-only-config-2.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
- assertTrue(properties.getProperties().keySet().size()>=4);
+ assertThat(properties.getProperties().keySet().size() >= 4).isTrue();
PropertyValue keyA = properties.get("a");
PropertyValue keyDO = properties.get("b.o");
PropertyValue keyDP = properties.get("b.p");
PropertyValue keyC = properties.get("c");
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), is("A"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), equalTo("C"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, notNullValue());
- assertThat(keyDP.getValue(), is("P"));
+ assertThat(keyA).isNotNull();
+ assertThat(keyA.getValue()).isEqualTo("A");
+ assertThat(keyC).isNotNull();
+ assertThat(keyC.getValue()).isEqualTo("C");
+ assertThat(keyDO).isNotNull();
+ assertThat(keyDO.getValue()).isEqualTo("O");
+ assertThat(keyDP).isNotNull();
+ assertThat(keyDP.getValue()).isEqualTo("P");
}
@Test
public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/invalid/with-array.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
getPropertiesFrom(configURL).getProperties();
}
@@ -135,7 +130,7 @@
public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/invalid/only-opening-bracket.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
getPropertiesFrom(configURL).getProperties();
}
@@ -144,7 +139,7 @@
public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/invalid/empty-file.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
getPropertiesFrom(configURL).getProperties();
}
@@ -153,40 +148,40 @@
public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/valid/with-explicit-priority.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
- assertThat(PropertySourceComparator.getOrdinal(properties), is(16784));
+ assertThat(PropertySourceComparator.getOrdinal(properties)).isEqualTo(16784);
}
@Test
public void canReadFlatStringOnlyJSONConfigFile() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/valid/simple-flat-string-only-config.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
- assertEquals(3, properties.getProperties().size());
+ assertThat(3).isEqualTo(properties.getProperties().size());
PropertyValue keyA = properties.get("a");
PropertyValue keyB = properties.get("b");
PropertyValue keyC = properties.get("c");
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), equalTo("A"));
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), is("B"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), is("C"));
+ assertThat(keyA).isNotNull();
+ assertThat(keyA.getValue()).isEqualTo("A");
+ assertThat(keyB).isNotNull();
+ assertThat(keyB.getValue()).isEqualTo("B");
+ assertThat(keyC).isNotNull();
+ assertThat(keyC.getValue()).isEqualTo("C");
}
@Test
public void emptyJSONFileResultsInConfigException() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/invalid/empty-file.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
@@ -197,10 +192,10 @@
public void canHandleEmptyJSONObject() throws Exception {
URL configURL = CommonHJSONTestCaseCollection.class.getResource("/configs/valid/empty-object-config.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
PropertySource properties = getPropertiesFrom(configURL);
- assertTrue(properties.getProperties().keySet().size()>=0);
+ assertThat(properties.getProperties().keySet().size() >= 0).isTrue();
}
}
diff --git a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatIT.java b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatIT.java
index 976c781..6258fc5 100644
--- a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatIT.java
+++ b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatIT.java
@@ -24,8 +24,7 @@
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link HJSONFormat}.
@@ -43,6 +42,6 @@
break;
}
}
- assertThat(format, notNullValue());
+ assertThat(format).isNotNull();
}
}
diff --git a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatTest.java b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatTest.java
index 2713b0f..f008aad 100644
--- a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatTest.java
+++ b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONFormatTest.java
@@ -27,8 +27,7 @@
import java.io.InputStream;
import java.net.URL;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
+import static org.assertj.core.api.Assertions.assertThat;
public class HJSONFormatTest extends CommonHJSONTestCaseCollection {
private final HJSONFormat format = new HJSONFormat();
@@ -42,27 +41,27 @@
public void aNonJSONFileBasedURLIsNotAccepted() throws Exception {
URL url = new URL("file:///etc/service/conf.conf");
- assertThat(format.accepts(url), is(false));
+ assertThat(format.accepts(url)).isFalse();
}
@Test
public void aJSONFileBasedURLIsAccepted() throws Exception {
URL url = new URL("file:///etc/service/conf.hjson");
- assertThat(format.accepts(url), is(true));
+ assertThat(format.accepts(url)).isTrue();
}
@Test
public void aHTTPBasedURLIsNotAccepted() throws Exception {
URL url = new URL("http://nowhere.somewhere/conf.hjson");
- assertThat(format.accepts(url), is(true));
+ assertThat(format.accepts(url)).isTrue();
}
@Test
public void aFTPBasedURLIsNotAccepted() throws Exception {
URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.hjson");
- assertThat(format.accepts(url), is(true));
+ assertThat(format.accepts(url)).isTrue();
}
@Override
@@ -72,4 +71,4 @@
return new MappedConfigurationDataPropertySource(data);
}
}
-}
\ No newline at end of file
+}
diff --git a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONPropertySourceTest.java b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONPropertySourceTest.java
index 25c9f6d..52dacd3 100644
--- a/hjson/src/test/java/org/apache/tamaya/hjson/HJSONPropertySourceTest.java
+++ b/hjson/src/test/java/org/apache/tamaya/hjson/HJSONPropertySourceTest.java
@@ -19,13 +19,11 @@
package org.apache.tamaya.hjson;
import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
import java.net.URL;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class HJSONPropertySourceTest extends CommonHJSONTestCaseCollection {
@@ -33,17 +31,17 @@
public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception {
URL configURL = HJSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
HJSONPropertySource source = new HJSONPropertySource(configURL, 4);
- assertEquals(source.getOrdinal(), 16784);
+ assertThat(source.getOrdinal()).isEqualTo(16784);
}
@Test
public void testAcceptJsonArrays() throws Exception {
URL configURL = HJSONPropertySourceTest.class.getResource("/configs/invalid/array.hjson");
- assertThat(configURL, CoreMatchers.notNullValue());
+ assertThat(configURL).isNotNull();
new HJSONPropertySource(configURL);
}
diff --git a/hjson/src/test/java/org/apache/tamaya/hjson/PathBasedHJSONPropertySourceProviderTest.java b/hjson/src/test/java/org/apache/tamaya/hjson/PathBasedHJSONPropertySourceProviderTest.java
index ab9c5d2..b5def8a 100644
--- a/hjson/src/test/java/org/apache/tamaya/hjson/PathBasedHJSONPropertySourceProviderTest.java
+++ b/hjson/src/test/java/org/apache/tamaya/hjson/PathBasedHJSONPropertySourceProviderTest.java
@@ -20,8 +20,7 @@
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link PathBasedHJSONPropertySourceProvider}.
@@ -33,8 +32,8 @@
PathBasedHJSONPropertySourceProvider provider = new PathBasedHJSONPropertySourceProvider(
"configs/valid/*.hjson"
);
- assertNotNull(provider.getPropertySources());
- assertEquals(7, provider.getPropertySources().size());
+ assertThat(provider.getPropertySources()).isNotNull();
+ assertThat(7).isEqualTo(provider.getPropertySources().size());
}
@Test
@@ -42,8 +41,8 @@
PathBasedHJSONPropertySourceProvider provider = new PathBasedHJSONPropertySourceProvider(
"configs/valid/cyril*.hjson"
);
- assertNotNull(provider.getPropertySources());
- assertEquals(1, provider.getPropertySources().size());
+ assertThat(provider.getPropertySources()).isNotNull();
+ assertThat(1).isEqualTo(provider.getPropertySources().size());
}
@Test
@@ -51,8 +50,8 @@
PathBasedHJSONPropertySourceProvider provider = new PathBasedHJSONPropertySourceProvider(
"configs/valid/simple-*.hjson"
);
- assertNotNull(provider.getPropertySources());
- assertEquals(3, provider.getPropertySources().size());
+ assertThat(provider.getPropertySources()).isNotNull();
+ assertThat(3).isEqualTo(provider.getPropertySources().size());
}
@Test
@@ -60,7 +59,7 @@
PathBasedHJSONPropertySourceProvider provider = new PathBasedHJSONPropertySourceProvider(
"configs/valid/foo*.hjson", "configs/valid/*.HJSON"
);
- assertNotNull(provider.getPropertySources());
- assertEquals(0, provider.getPropertySources().size());
+ assertThat(provider.getPropertySources()).isNotNull();
+ assertThat(0).isEqualTo(provider.getPropertySources().size());
}
-}
\ No newline at end of file
+}
diff --git a/jodatime/pom.xml b/jodatime/pom.xml
index 7ffbf23..3596425 100644
--- a/jodatime/pom.xml
+++ b/jodatime/pom.xml
@@ -76,6 +76,10 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
<dependency>
<groupId>joda-time</groupId>
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
index 85e7b6f..8055e48 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterIT.java
@@ -26,9 +26,7 @@
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.assertj.core.api.Assertions.assertThat;
public class DateTimeConverterIT {
@Test
@@ -46,8 +44,8 @@
}
}
- assertThat("Converter not found via service context.", converter, notNullValue());
- assertThat(converter, instanceOf(DateTimeConverter.class));
+ assertThat(converter).isNotNull();
+ assertThat(converter).isInstanceOf(DateTimeConverter.class);
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
index 58b4587..f3c7a04 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeConverterTest.java
@@ -24,16 +24,8 @@
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Test;
-import org.mockito.Mockito;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
-import static org.mockito.Matchers.any;
+import static org.assertj.core.api.Assertions.assertThat;
public class DateTimeConverterTest {
/*
@@ -72,8 +64,8 @@
for (Object[] pair : inputResultPairs) {
DateTime date = converter.convert((String)pair[0], context);
- assertThat("Converter failed to convert input createValue " + pair[0], date, notNullValue());
- assertThat(date.isEqual((DateTime)pair[1]), is(true));
+ assertThat(date).isNotNull();
+ assertThat(date.isEqual((DateTime) pair[1])).isTrue();
}
}
@@ -87,7 +79,7 @@
for (String input : inputValues) {
DateTime date = converter.convert(input, context);
- assertThat(date, nullValue());
+ assertThat(date).isNull();
}
}
@@ -96,11 +88,11 @@
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(DateTime.class)).build();
converter.convert("2007-08-31T16+00:00", context);
- assertThat(context.getSupportedFormats(), hasSize(DateTimeConverter.PARSER_FORMATS.length));
+ assertThat(context.getSupportedFormats().size()).isEqualTo(DateTimeConverter.PARSER_FORMATS.length);
for (String format : DateTimeConverter.PARSER_FORMATS) {
String expected = format + " (" + DateTimeConverter.class.getSimpleName() + ")";
- assertThat(context.getSupportedFormats(), hasItem(expected));
+ assertThat(context.getSupportedFormats().contains(expected)).isTrue();
}
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
index 0963408..9a35f78 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterIT.java
@@ -26,9 +26,7 @@
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.assertj.core.api.Assertions.assertThat;
public class DateTimeZoneConverterIT {
@Test
@@ -45,8 +43,8 @@
}
}
- assertThat("Converter not found via service context.", converter, notNullValue());
- assertThat(converter, instanceOf(DateTimeZoneConverter.class));
+ assertThat(converter).isNotNull();
+ assertThat(converter).isInstanceOf(DateTimeZoneConverter.class);
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
index 7bc3adb..1ec307d 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DateTimeZoneConverterTest.java
@@ -25,13 +25,7 @@
import org.junit.Test;
import org.mockito.Mockito;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
+import static org.assertj.core.api.Assertions.assertThat;
public class DateTimeZoneConverterTest {
private DateTimeZoneConverter converter = new DateTimeZoneConverter();
@@ -59,8 +53,8 @@
for (Object[] pair : inputResultPairs) {
DateTimeZone zone = converter.convert((String) pair[0], context);
- assertThat("Converter failed to convert input createValue " + pair[0], zone, notNullValue());
- assertThat(zone, equalTo((DateTimeZone)pair[1]));
+ assertThat(zone).isNotNull();
+ assertThat(zone).isEqualTo((DateTimeZone)pair[1]);
}
}
@@ -78,7 +72,7 @@
for (String input : inputValues) {
DateTimeZone date = converter.convert(input, context);
- assertThat(date, nullValue());
+ assertThat(date).isNull();
}
}
@@ -90,10 +84,10 @@
ConversionContext context = new Builder(TypeLiteral.of(DateTimeZone.class)).build();
DateTimeZone result = converter.convert("+01:00", context);
- assertThat(result, notNullValue());
- assertThat(context.getSupportedFormats(), hasSize(2));
- assertThat(context.getSupportedFormats(), hasItem(firstFormat));
- assertThat(context.getSupportedFormats(), hasItem(secondFormat));
+ assertThat(result).isNotNull();
+ assertThat(context.getSupportedFormats().size()).isEqualTo(2);
+ assertThat(context.getSupportedFormats().contains(firstFormat)).isTrue();
+ assertThat(context.getSupportedFormats().contains(secondFormat)).isTrue();
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterIT.java
index 41288a8..c672b8b 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterIT.java
@@ -25,9 +25,7 @@
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.assertj.core.api.Assertions.assertThat;
public class DurationConverterIT {
@Test
@@ -44,8 +42,8 @@
}
}
- assertThat("Converter not found via service context.", converter, notNullValue());
- assertThat(converter, instanceOf(DurationConverter.class));
+ assertThat(converter).isNotNull();
+ assertThat(converter).isInstanceOf(DurationConverter.class);
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterTest.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterTest.java
index 7ddf6da..9b1c8a7 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/DurationConverterTest.java
@@ -26,12 +26,7 @@
import org.junit.Test;
import org.mockito.Mockito;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
+import static org.assertj.core.api.Assertions.assertThat;
public class DurationConverterTest {
@@ -62,8 +57,8 @@
for (Object[] pair : inputResultPairs) {
Duration duration = converter.convert((String) pair[0], context);
- assertThat("Converter failed to convert input createValue " + pair[0], duration, notNullValue());
- assertThat(duration, equalTo((Duration) pair[1]));
+ assertThat(duration).isNotNull();
+ assertThat(duration).isEqualTo((Duration) pair[1]);
}
}
@@ -80,7 +75,7 @@
for (String input : inputValues) {
Duration duration = converter.convert(input, context);
- assertThat(duration, nullValue());
+ assertThat(duration).isNull();
}
}
@@ -91,9 +86,9 @@
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Duration.class)).build();
converter.convert("P0DT0H0M0S", context);
- assertThat(context.getSupportedFormats(), hasSize(3));
- assertThat(context.getSupportedFormats(), hasItem("PdDThHmMsS (" + name + ")"));
- assertThat(context.getSupportedFormats(), hasItem("ddThh:mm:ss (" + name + ")"));
- assertThat(context.getSupportedFormats(), hasItem("PTa.bS (" + name + ")"));
+ assertThat(context.getSupportedFormats().size()).isEqualTo(3);
+ assertThat(context.getSupportedFormats().contains("PdDThHmMsS (" + name + ")")).isTrue();
+ assertThat(context.getSupportedFormats().contains("ddThh:mm:ss (" + name + ")")).isTrue();
+ assertThat(context.getSupportedFormats().contains("PTa.bS (" + name + ")")).isTrue();
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
index 85bc6ca..0f4a41d 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/FullStackIT.java
@@ -28,9 +28,7 @@
import java.util.Locale;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.joda.time.format.ISODateTimeFormat.dateTime;
public class FullStackIT {
@@ -43,10 +41,10 @@
String dateTimeString = configuration.get("dateTimeValue");
DateTime dateTimeValue = configuration.get("dateTimeValue", DateTime.class);
- assertThat(dateTimeString, notNullValue());
- assertThat(dateTimeString, equalTo("2010-08-08T14:00:15.5+10:00"));
- assertThat(dateTimeValue, notNullValue());
- assertThat(dateTimeValue.getMillis(), equalTo(dateTime().parseDateTime(dateTimeString).getMillis()));
+ assertThat(dateTimeString).isNotNull();
+ assertThat(dateTimeString).isEqualTo("2010-08-08T14:00:15.5+10:00");
+ assertThat(dateTimeValue).isNotNull();
+ assertThat(dateTimeValue.getMillis()).isEqualTo(dateTime().parseDateTime(dateTimeString).getMillis());
}
@Test
@@ -56,14 +54,14 @@
String zoneAAsString = configuration.get("dateTimeZoneValueA");
DateTimeZone zoneA = configuration.get("dateTimeZoneValueA", DateTimeZone.class);
- assertThat(zoneAAsString, equalTo("UTC"));
- assertThat(zoneA, equalTo(DateTimeZone.forID("UTC")));
+ assertThat(zoneAAsString).isEqualTo("UTC");
+ assertThat(zoneA).isEqualTo(DateTimeZone.forID("UTC"));
String zoneBAsString = configuration.get("dateTimeZoneValueB");
DateTimeZone zoneB = configuration.get("dateTimeZoneValueB", DateTimeZone.class);
- assertThat(zoneBAsString, equalTo("+01:00"));
- assertThat(zoneB, equalTo(DateTimeZone.forOffsetHours(1)));
+ assertThat(zoneBAsString).isEqualTo("+01:00");
+ assertThat(zoneB).isEqualTo(DateTimeZone.forOffsetHours(1));
}
@Test
@@ -78,7 +76,7 @@
String periodAsString = configuration.get("periodValueA");
Period period = configuration.get("periodValueA", Period.class);
- assertThat(periodAsString, equalTo("P1Y1M1W1DT1H1M1S"));
- assertThat(period, equalTo(referenceValue.toPeriod()));
+ assertThat(periodAsString).isEqualTo("P1Y1M1W1DT1H1M1S");
+ assertThat(period).isEqualTo(referenceValue.toPeriod());
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterIT.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterIT.java
index f110754..b70bfcb 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterIT.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterIT.java
@@ -25,9 +25,7 @@
import java.util.List;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.notNullValue;
+import static org.assertj.core.api.Assertions.assertThat;
public class PeriodConverterIT {
@Test
@@ -44,8 +42,8 @@
}
}
- assertThat("Converter not found via service context.", converter, notNullValue());
- assertThat(converter, instanceOf(PeriodConverter.class));
+ assertThat(converter).isNotNull();
+ assertThat(converter).isInstanceOf(PeriodConverter.class);
}
}
diff --git a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
index 9ed7724..058584e 100644
--- a/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
+++ b/jodatime/src/test/java/org/apache/tamaya/jodatime/PeriodConverterTest.java
@@ -26,12 +26,7 @@
import org.junit.Test;
import org.mockito.Mockito;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
+import static org.assertj.core.api.Assertions.assertThat;
public class PeriodConverterTest {
/*
@@ -66,8 +61,8 @@
for (Object[] pair : inputResultPairs) {
Period period = converter.convert((String) pair[0], context);
- assertThat("Converter failed to convert input createValue " + pair[0], period, notNullValue());
- assertThat(period, equalTo((Period)pair[1]));
+ assertThat(period).isNotNull();
+ assertThat(period).isEqualTo((Period) pair[1]);
}
}
@@ -83,7 +78,7 @@
for (String input : inputValues) {
Period period = converter.convert(input, context);
- assertThat(period, nullValue());
+ assertThat(period).isNull();
}
}
@@ -94,8 +89,8 @@
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Period.class)).build();
converter.convert("P7Y0M0W0DT0H0M0S", context);
- assertThat(context.getSupportedFormats(), hasSize(2));
- assertThat(context.getSupportedFormats(), hasItem("PyYmMwWdDThHmMsS (" + name + ")"));
- assertThat(context.getSupportedFormats(), hasItem("Pyyyy-mm-ddThh:mm:ss (" + name + ")"));
+ assertThat(context.getSupportedFormats().size()).isEqualTo(2);
+ assertThat(context.getSupportedFormats().contains("PyYmMwWdDThHmMsS (" + name + ")")).isTrue();
+ assertThat(context.getSupportedFormats().contains("Pyyyy-mm-ddThh:mm:ss (" + name + ")")).isTrue();
}
}
diff --git a/management/pom.xml b/management/pom.xml
index 81f64c9..f57233a 100644
--- a/management/pom.xml
+++ b/management/pom.xml
@@ -55,6 +55,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java b/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
index 5cbef7f..a8f5562 100644
--- a/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
+++ b/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
@@ -28,7 +28,7 @@
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
/**
* Created by Anatole on 20.08.2015.
@@ -40,26 +40,26 @@
@org.junit.Test
public void testGetJsonConfigurationInfo() throws Exception {
String info = bean.getJsonConfigurationInfo();
- assertNotNull(info);
- assertTrue(info.contains("java.version"));
+ assertThat(info).isNotNull();
+ assertThat(info.contains("java.version")).isTrue();
System.out.println(bean.getJsonConfigurationInfo());
}
@org.junit.Test
public void testGetXmlConfigurationInfo() throws Exception {
String info = bean.getXmlConfigurationInfo();
- assertNotNull(info);
- assertTrue(info.contains("java.version"));
- assertTrue(info.contains("<configuration>"));
+ assertThat(info).isNotNull();
+ assertThat(info.contains("java.version")).isTrue();
+ assertThat(info.contains("<configuration>")).isTrue();
System.out.println(bean.getXmlConfigurationInfo());
}
@org.junit.Test
public void testGetConfiguration() throws Exception {
Map<String,String> config = bean.getConfiguration();
- assertNotNull(config);
+ assertThat(config).isNotNull();
for(Map.Entry<Object, Object> en:System.getProperties().entrySet()){
- assertEquals(config.get(en.getKey()),en.getValue());
+ assertThat(config.get(en.getKey())).isEqualTo(en.getValue());
}
}
@@ -67,33 +67,33 @@
public void testGetConfigurationArea() throws Exception {
Map<String,String> cfg = bean.getSection("java", false);
for(Map.Entry<String,String> en:cfg.entrySet()){
- assertEquals(System.getProperty(en.getKey()), en.getValue());
+ assertThat(System.getProperty(en.getKey())).isEqualTo(en.getValue());
}
}
@org.junit.Test
public void testGetAreas() throws Exception {
Set<String> sections = (bean.getSections());
- assertNotNull(sections);
- assertTrue(sections.contains("java"));
- assertTrue(sections.contains("file"));
+ assertThat(sections).isNotNull();
+ assertThat(sections.contains("java")).isTrue();
+ assertThat(sections.contains("file")).isTrue();
}
@org.junit.Test
public void testGetTransitiveAreas() throws Exception {
Set<String> sections = (bean.getTransitiveSections());
Set<String> sectionsNT = (bean.getSections());
- assertNotNull(sections);
- assertTrue(sections.contains("java"));
- assertTrue(sections.contains("sun"));
- assertTrue(sections.contains("sun.os"));
- assertTrue(sectionsNT.size()<sections.size());
+ assertThat(sections).isNotNull();
+ assertThat(sections.contains("java")).isTrue();
+ assertThat(sections.contains("sun")).isTrue();
+ assertThat(sections.contains("sun.os")).isTrue();
+ assertThat(sectionsNT.size() < sections.size()).isTrue();
}
@org.junit.Test
public void testIsAreaExisting() throws Exception {
- assertTrue(bean.isAreaExisting("java"));
- assertFalse(bean.isAreaExisting("sd.fldsfl.erlwsf"));
+ assertThat(bean.isAreaExisting("java")).isTrue();
+ assertThat(bean.isAreaExisting("sd.fldsfl.erlwsf")).isFalse();
}
@org.junit.Test
@@ -102,7 +102,7 @@
ConfigManagementSupport.registerMBean();
// Lookup createObject name
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- assertTrue(mbs.getMBeanInfo(on)!=null);
+ assertThat(mbs.getMBeanInfo(on) != null).isTrue();
}
@org.junit.Test
@@ -112,7 +112,7 @@
ObjectName on2 = ConfigManagementSupport.registerMBean("SubContext2");
// Lookup createObject name
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- assertTrue(mbs.getMBeanInfo(on1)!=null);
- assertTrue(mbs.getMBeanInfo(on2)!=null);
+ assertThat(mbs.getMBeanInfo(on1) != null).isTrue();
+ assertThat(mbs.getMBeanInfo(on2) != null).isTrue();
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java
index bd73b11..0c144a8 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java
@@ -24,8 +24,7 @@
import java.util.Collections;
-import static org.junit.Assert.*;
-
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by atsticks on 18.04.17.
@@ -36,19 +35,19 @@
@Test
public void getName() throws Exception {
- assertEquals("CLI", f.getName());
+ assertThat("CLI").isEqualTo(f.getName());
}
@Test
public void create() throws Exception {
PropertySource ps = f.create(Collections.EMPTY_MAP);
- assertNotNull(ps);
- assertTrue(ps instanceof CLIPropertySource);
+ assertThat(ps).isNotNull();
+ assertThat(ps).isInstanceOf(CLIPropertySource.class);
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java
index 5193df7..5ac5886 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java
@@ -24,7 +24,7 @@
import java.util.Collections;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -36,19 +36,19 @@
@Test
public void getName() throws Exception {
- assertEquals("env-properties", f.getName());
+ assertThat("env-properties").isEqualTo(f.getName());
}
@Test
public void create() throws Exception {
PropertySource ps = f.create(Collections.EMPTY_MAP);
- assertNotNull(ps);
- assertTrue(ps instanceof EnvironmentPropertySource);
+ assertThat(ps).isNotNull();
+ assertThat(ps).isInstanceOf(EnvironmentPropertySource.class);
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java
index d91d279..1811372 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -37,7 +37,7 @@
@Test
public void getName() throws Exception {
- assertEquals("file", f.getName());
+ assertThat("file").isEqualTo(f.getName());
}
@Test
@@ -45,19 +45,19 @@
Map<String,String> params = new HashMap<>();
params.put("location", "src/test/resources/GLOBAL.properties");
PropertySource ps = f.create(params);
- assertNotNull(ps);
+ assertThat(ps).isNotNull();
}
@Test
public void create_Error() throws Exception {
Map<String,String> params = new HashMap<>();
PropertySource ps = f.create(Collections.<String, String>emptyMap());
- assertNull("Should throw error for missing location.", ps);
+ assertThat(ps).isNull();
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java
index bd6ee93..7608b95 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -37,7 +37,7 @@
@Test
public void getName() throws Exception {
- assertEquals("resource", f.getName());
+ assertThat("resource").isEqualTo(f.getName());
}
@Test
@@ -45,19 +45,19 @@
Map<String,String> params = new HashMap<>();
params.put("location", "GLOBAL.properties");
PropertySource ps = f.create(params);
- assertNotNull(ps);
+ assertThat(ps).isNotNull();
}
@Test
public void create_Error() throws Exception {
Map<String,String> params = new HashMap<>();
PropertySource ps = f.create(Collections.<String, String>emptyMap());
- assertNull("Should return null for missing location.", ps);
+ assertThat(ps).isNull();
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java
index edc0d95..f1e7d70 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java
@@ -26,7 +26,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -38,7 +38,7 @@
@Test
public void getName() throws Exception {
- assertEquals("resources", f.getName());
+ assertThat("resources").isEqualTo(f.getName());
}
@Test
@@ -46,19 +46,19 @@
Map<String,String> params = new HashMap<>();
params.put("location", "GLOBAL.properties");
PropertySourceProvider prov = f.create(params);
- assertNotNull(prov);
+ assertThat(prov).isNotNull();
}
@Test
public void create_Error() throws Exception {
Map<String,String> params = new HashMap<>();
PropertySourceProvider prov = f.create(Collections.<String, String>emptyMap());
- assertNull("Should return null for missing location.", prov);
+ assertThat(prov).isNull();
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySourceProvider.class, f.getType());
+ assertThat(PropertySourceProvider.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java
index 5d21811..07f9d8d 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java
@@ -24,7 +24,7 @@
import java.util.Collections;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -36,19 +36,19 @@
@Test
public void getName() throws Exception {
- assertEquals("sys-properties", f.getName());
+ assertThat("sys-properties").isEqualTo(f.getName());
}
@Test
public void create() throws Exception {
PropertySource ps = f.create(Collections.EMPTY_MAP);
- assertNotNull(ps);
- assertTrue(ps instanceof SystemPropertySource);
+ assertThat(ps).isNotNull();
+ assertThat(ps).isInstanceOf(SystemPropertySource.class);
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java
index f316417..3301ffe 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -37,7 +37,7 @@
@Test
public void getName() throws Exception {
- assertEquals("url", f.getName());
+ assertThat("url").isEqualTo(f.getName());
}
@Test
@@ -45,19 +45,19 @@
Map<String,String> params = new HashMap<>();
params.put("location", "http://apache.org");
PropertySource ps = f.create(params);
- assertNotNull(ps);
+ assertThat(ps).isNotNull();
}
@Test
public void create_Error() throws Exception {
Map<String,String> params = new HashMap<>();
PropertySource ps = f.create(Collections.<String, String>emptyMap());
- assertNull("Should return null for missing location.", ps);
+ assertThat(ps).isNull();
}
@Test
public void getType() throws Exception {
- assertEquals(PropertySource.class, f.getType());
+ assertThat(PropertySource.class).isEqualTo(f.getType());
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/JavaResolverTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/JavaResolverTest.java
index 93ccd56..3292601 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/JavaResolverTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/JavaResolverTest.java
@@ -21,7 +21,7 @@
import org.apache.tamaya.metamodel.MetaContext;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -35,43 +35,43 @@
@Test
public void getResolverId() throws Exception {
- assertEquals(r.getResolverId(), "java");
+ assertThat(r.getResolverId()).isEqualTo("java");
}
@Test
public void evaluateDirect() throws Exception {
- assertEquals("createValue", r.evaluate("\"createValue\""));
- assertEquals("1.1", r.evaluate("1.1"));
- assertEquals("1", r.evaluate("1"));
+ assertThat("createValue").isEqualTo(r.evaluate("\"createValue\""));
+ assertThat("1.1").isEqualTo(r.evaluate("1.1"));
+ assertThat("1").isEqualTo(r.evaluate("1"));
}
@Test
public void evaluateProperties() throws Exception {
- assertEquals(System.getProperty("java.version"), r.evaluate("sys(\"java.version\")"));
+ assertThat(System.getProperty("java.version")).isEqualTo(r.evaluate("sys(\"java.version\")"));
String key = System.getenv().keySet().iterator().next();
- assertEquals(System.getenv(key), r.evaluate("env(\""+key+"\")"));
+ assertThat(System.getenv(key)).isEqualTo(r.evaluate("env(\""+key+"\")"));
MetaContext.getInstance().setProperty("foo", "bar");
- assertEquals("bar", r.evaluate("context(\"foo\")"));
+ assertThat("bar").isEqualTo(r.evaluate("context(\"foo\")"));
}
@Test
public void evaluateExpression() throws Exception {
- assertEquals("true", r.evaluate("env(\"STAGE\") == null"));
- assertEquals("true", r.evaluate("sys(\"STAGE\") == null"));
+ assertThat("true").isEqualTo(r.evaluate("env(\"STAGE\") == null"));
+ assertThat("true").isEqualTo(r.evaluate("sys(\"STAGE\") == null"));
System.setProperty("STAGE", "DEV2");
- assertEquals("false", r.evaluate("sys(\"STAGE\") == null"));
+ assertThat("false").isEqualTo(r.evaluate("sys(\"STAGE\") == null"));
System.setProperty("STAGE", "DEV2");
- assertEquals("DEV2", r.evaluate("sys(\"STAGE\") == null?env(\"STAGE\"):sys(\"STAGE\")"));
- assertEquals("DEV2", r.evaluate("if(sys(\"STAGE\") == null)return env(\"STAGE\"); else return sys(\"STAGE\");"));
+ assertThat("DEV2").isEqualTo(r.evaluate("sys(\"STAGE\") == null?env(\"STAGE\"):sys(\"STAGE\")"));
+ assertThat("DEV2").isEqualTo(r.evaluate("if(sys(\"STAGE\") == null)return env(\"STAGE\"); else return sys(\"STAGE\");"));
System.getProperties().remove("STAGE");
- assertEquals("foo", r.evaluate("if(sys(\"STAGE\") == null)return \"foo\"; else return sys(\"STAGE\");"));
+ assertThat("foo").isEqualTo(r.evaluate("if(sys(\"STAGE\") == null)return \"foo\"; else return sys(\"STAGE\");"));
}
@Test
public void evaluateSimple() throws Exception {
- assertEquals(TEST, r.evaluate("org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest.TEST"));
- assertEquals(TEST, r.evaluate("new org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest().getTest1()"));
- assertEquals(TEST, r.evaluate("org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest.getTest2()"));
+ assertThat(TEST).isEqualTo(r.evaluate("org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest.TEST"));
+ assertThat(TEST).isEqualTo(r.evaluate("new org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest().getTest1()"));
+ assertThat(TEST).isEqualTo(r.evaluate("org.apache.tamaya.metamodel.internal.resolver.JavaResolverTest.getTest2()"));
}
public String getTest1(){
@@ -82,4 +82,4 @@
return TEST;
}
-}
\ No newline at end of file
+}
diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/PropertiesResolverTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/PropertiesResolverTest.java
index 988c224..b92cfb7 100644
--- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/PropertiesResolverTest.java
+++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/PropertiesResolverTest.java
@@ -22,7 +22,7 @@
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -34,19 +34,19 @@
@Test
public void getResolverId() throws Exception {
- assertEquals(r.getResolverId(), "properties");
+ assertThat(r.getResolverId()).isEqualTo("properties");
}
@Test
public void evaluate() throws Exception {
for(Map.Entry<String,String> en: System.getenv().entrySet()){
- assertEquals(en.getValue(), r.evaluate("env:"+en.getKey()));
+ assertThat(en.getValue()).isEqualTo(r.evaluate("env:"+en.getKey()));
}
- assertEquals("foo", r.evaluate("env:fsdifoisfo?default=foo"));
+ assertThat("foo").isEqualTo(r.evaluate("env:fsdifoisfo?default=foo"));
for(Map.Entry en: System.getProperties().entrySet()){
- assertEquals(en.getValue(), r.evaluate("system:"+en.getKey()));
+ assertThat(en.getValue()).isEqualTo(r.evaluate("system:"+en.getKey()));
}
- assertEquals("foo", r.evaluate("system:fsdifoisfo?default=foo"));
+ assertThat("foo").isEqualTo(r.evaluate("system:fsdifoisfo?default=foo"));
}
-}
\ No newline at end of file
+}
diff --git a/propertysources/pom.xml b/propertysources/pom.xml
index e9d64ac..7119f09 100644
--- a/propertysources/pom.xml
+++ b/propertysources/pom.xml
@@ -61,6 +61,10 @@
<artifactId>tamaya-formats</artifactId>
<version>${project.parent.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java b/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java
index fecfff7..e407706 100644
--- a/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java
+++ b/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java
@@ -20,7 +20,7 @@
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by atsticks on 30.10.16.
@@ -30,8 +30,8 @@
@Test
public void getPropertySources_Default() throws Exception {
MetainfConfigPropertySourceProvider provider = new MetainfConfigPropertySourceProvider();
- assertNotNull(provider.getPropertySources());
+ assertThat(provider.getPropertySources()).isNotNull();
// TODO addNode test for containing property sources.
}
-}
\ No newline at end of file
+}
diff --git a/server/pom.xml b/server/pom.xml
index 6a37194..c2ed26d 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -86,9 +86,8 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
</dependency>
</dependencies>
diff --git a/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java b/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java
index 18bc0ba..1243223 100644
--- a/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java
+++ b/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java
@@ -18,16 +18,13 @@
*/
package org.apache.tamaya.server;
-import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
public class VersionPropertiesTest {
@@ -38,9 +35,11 @@
Properties properties = new Properties();
properties.load(resource);
- assertThat(VersionProperties.getVersion(), not(Matchers.isEmptyOrNullString()));
- assertThat(VersionProperties.getVersion(), equalTo(properties.get("server.version")));
- assertThat(VersionProperties.getProduct(), not(Matchers.isEmptyOrNullString()));
- assertThat(VersionProperties.getProduct(), equalTo(properties.get("server.product")));
+ assertThat(VersionProperties.getVersion()).isNotNull();
+ assertThat(VersionProperties.getVersion()).isNotEqualTo("");
+ assertThat(VersionProperties.getVersion()).isEqualTo(properties.get("server.version"));
+ assertThat(VersionProperties.getProduct()).isNotNull();
+ assertThat(VersionProperties.getProduce()).isNotEqualTo("");
+ assertThat(VersionProperties.getProduct()).isEqualTo(properties.get("server.product"));
}
}
diff --git a/uom/pom.xml b/uom/pom.xml
index 8b29c85..42281da 100644
--- a/uom/pom.xml
+++ b/uom/pom.xml
@@ -61,6 +61,11 @@
</dependency>
<dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.measure</groupId>
<artifactId>unit-api</artifactId>
<version>${jsr363.version}</version>
diff --git a/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java b/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java
index 7852693..f09a0ea 100644
--- a/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java
+++ b/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java
@@ -18,17 +18,15 @@
*/
package org.apache.tamaya.uom;
+import javax.measure.Unit;
+
import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.junit.Test;
import tec.units.ri.unit.Units;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.*;
-
-import javax.measure.Unit;
+import static org.assertj.core.api.Assertions.assertThat;
public class UnitConverterTest {
private UnitConverter converter = new UnitConverter();
@@ -39,8 +37,8 @@
ConversionContext context = new ConversionContext.Builder(TypeLiteral.of(Unit.class)).build();
Unit<?> unit = converter.convert("m", context);
- assertThat("Converter failed to convert input createValue " + unit, notNullValue());
- assertEquals(unit, Units.METRE);
+ assertThat(unit).isNotNull();
+ assertThat(unit).isEqualTo(Units.METRE);
}
}
diff --git a/usagetracker/pom.xml b/usagetracker/pom.xml
index c1d2d14..00afc0a 100644
--- a/usagetracker/pom.xml
+++ b/usagetracker/pom.xml
@@ -83,6 +83,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/usagetracker/src/test/java/org/apache/tamaya/model/ConfigUsageTest.java b/usagetracker/src/test/java/org/apache/tamaya/model/ConfigUsageTest.java
index d424ab7..5b9bb35 100644
--- a/usagetracker/src/test/java/org/apache/tamaya/model/ConfigUsageTest.java
+++ b/usagetracker/src/test/java/org/apache/tamaya/model/ConfigUsageTest.java
@@ -23,7 +23,7 @@
import org.junit.Test;
import test.model.TestConfigAccessor;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by Anatole on 09.08.2015.
@@ -36,8 +36,8 @@
TestConfigAccessor.readConfiguration();
Configuration config = Configuration.current();
String info = ConfigUsage.getInstance().getInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
+ assertThat(info.contains("java.version")).isFalse();
+ assertThat(info).isNotNull();
config = TestConfigAccessor.readConfiguration();
config.getProperties();
TestConfigAccessor.readProperty(config, "java.locale");
@@ -46,8 +46,8 @@
config.get("java.version");
info = ConfigUsage.getInstance().getInfo();
System.out.println(info);
- assertTrue(info.contains("java.version"));
- assertNotNull(info);
+ assertThat(info.contains("java.version")).isTrue();
+ assertThat(info).isNotNull();
ConfigUsage.getInstance().enableUsageTracking(false);
}
@@ -58,8 +58,8 @@
TestConfigAccessor.readConfiguration();
Configuration config = Configuration.current();
String info = ConfigUsage.getInstance().getInfo();
- assertNotNull(info);
- assertFalse(info.contains("java.version"));
+ assertThat(info).isNotNull();
+ assertThat(info.contains("java.version")).isFalse();
config = TestConfigAccessor.readConfiguration();
config.getProperties();
TestConfigAccessor.readProperty(config, "java.locale");
@@ -67,8 +67,8 @@
TestConfigAccessor.readProperty(config, "java.version");
config.get("java.version");
info = ConfigUsage.getInstance().getInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
+ assertThat(info.contains("java.version")).isFalse();
+ assertThat(info).isNotNull();
ConfigUsage.getInstance().enableUsageTracking(false);
}
}