* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/net/jmob/jsconf/core/impl/BeanDefinition.java b/src/main/java/net/jmob/jsconf/core/impl/BeanDefinition.java index b756a80..90bed30 100644 --- a/src/main/java/net/jmob/jsconf/core/impl/BeanDefinition.java +++ b/src/main/java/net/jmob/jsconf/core/impl/BeanDefinition.java @@ -1,16 +1,16 @@ package net.jmob.jsconf.core.impl; -import static org.springframework.util.StringUtils.isEmpty; +import static org.springframework.util.StringUtils.hasText; /** * Copyright 2015 Yves Galante - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,10 +26,10 @@ public class BeanDefinition { private boolean reloading; public String getId() { - if (isEmpty(id)) { - return this.key; + if (hasText(id)) { + return id; } - return id; + return this.key; } public BeanDefinition withId(String id) { diff --git a/src/main/java/net/jmob/jsconf/core/impl/BeanFactory.java b/src/main/java/net/jmob/jsconf/core/impl/BeanFactory.java index d40b0a3..c0751b4 100644 --- a/src/main/java/net/jmob/jsconf/core/impl/BeanFactory.java +++ b/src/main/java/net/jmob/jsconf/core/impl/BeanFactory.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Yves Galante - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,15 +16,9 @@ package net.jmob.jsconf.core.impl; -import static java.lang.String.format; -import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - +import com.typesafe.config.Config; +import com.typesafe.config.ConfigException; +import com.typesafe.config.ConfigValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanCreationException; @@ -33,10 +27,14 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.context.ApplicationContext; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigException; -import com.typesafe.config.ConfigValue; +import static java.lang.String.format; +import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; public class BeanFactory { @@ -77,25 +75,25 @@ public boolean isReloading() { } public String registerBean() { - final BeanDefinitionBuilder beanDefinition; + final BeanDefinitionBuilder bd; final String beanId = this.beanDefinition.getId(); this.log.debug("Initialize bean id : {}", beanId); if (this.beanDefinition.isAInterface()) { - beanDefinition = buildBeanFromInterface(); + bd = buildBeanFromInterface(); } else { - beanDefinition = buildBeanFromClass(); + bd = buildBeanFromClass(); } this.log.debug("Register bean id : {}", beanId); AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory(); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory; - registry.registerBeanDefinition(beanId, beanDefinition.getBeanDefinition()); + registry.registerBeanDefinition(beanId, bd.getBeanDefinition()); return beanId; } private BeanDefinitionBuilder buildBeanFromClass() { try { - BeanDefinitionBuilder beanDefinition = genericBeanDefinition(Class.forName(this.beanDefinition.getClassName())); - return addPropertiesValue(beanDefinition, buildProperties(beanDefinition)); + BeanDefinitionBuilder bd = genericBeanDefinition(Class.forName(this.beanDefinition.getClassName())); + return addPropertiesValue(bd, buildProperties(bd)); } catch (ClassNotFoundException e) { throw new BeanCreationException(format("Class not found : %s", this.beanDefinition.getClassName()), e); } diff --git a/src/main/java/net/jmob/jsconf/core/impl/BeanValidator.java b/src/main/java/net/jmob/jsconf/core/impl/BeanValidator.java index 50ed576..6d74b0e 100644 --- a/src/main/java/net/jmob/jsconf/core/impl/BeanValidator.java +++ b/src/main/java/net/jmob/jsconf/core/impl/BeanValidator.java @@ -1,12 +1,12 @@ /** * Copyright 2015 Yves Galante - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,6 +33,8 @@ class BeanValidator { private static final Logger log = LoggerFactory.getLogger(BeanValidator.class); private static final ValidatorFactory factory; + private BeanValidator() { + } static { ValidatorFactory f = null; diff --git a/src/main/java/net/jmob/jsconf/core/impl/ProxyPostProcessor.java b/src/main/java/net/jmob/jsconf/core/impl/ProxyPostProcessor.java index d8b5b56..a226dab 100644 --- a/src/main/java/net/jmob/jsconf/core/impl/ProxyPostProcessor.java +++ b/src/main/java/net/jmob/jsconf/core/impl/ProxyPostProcessor.java @@ -1,12 +1,12 @@ /** * Copyright 2013 Yves Galante - * + *
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *
* http://www.apache.org/licenses/LICENSE-2.0 - * + *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,11 +23,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static java.lang.String.format;
@@ -43,16 +39,13 @@ public ProxyPostProcessor(ApplicationContext context) {
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean.getClass().getInterfaces().length > 0) {
- BeanProxy proxy = this.proxyRef.get(beanName);
- if (proxy == null) {
+ BeanProxy proxy = this.proxyRef.computeIfAbsent(beanName, key -> {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
- List
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -57,7 +57,7 @@ public static
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,30 +16,31 @@
package net.jmob.jsconf.core.sample;
-import org.apache.commons.dbcp.BasicDataSource;
import net.jmob.jsconf.core.ConfigurationFactory;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import javax.sql.DataSource;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample01 {
+class Sample01 {
@Autowired
private DataSource datasource;
@Test
- public void test() {
+ void test() {
BasicDataSource basic = (BasicDataSource) this.datasource;
assertEquals("jdbc:mysql://localhost:3306/test", basic.getUrl());
assertEquals("com.mysql.jdbc.Driver", basic.getDriverClassName());
@@ -48,7 +49,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_01.conf") //
.withBean("datasource", BasicDataSource.class);
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample02.java b/src/test/java/net/jmob/jsconf/core/sample/Sample02.java
index d030323..ab088ca 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample02.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample02.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,28 +18,29 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample02 {
+class Sample02 {
@Autowired
// This interface not required implementation
private ConfigBean conf;
@Test
- public void test() {
+ void test() {
assertNotNull(this.conf);
assertEquals("Hello World", this.conf.getUrl());
assertEquals(12, this.conf.getPort());
@@ -53,7 +54,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_02")
.withScanPackage(ConfigBean.class.getPackage().getName());
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample03.java b/src/test/java/net/jmob/jsconf/core/sample/Sample03.java
index c66bc86..c8e3916 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample03.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample03.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,21 +19,22 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
import net.jmob.jsconf.core.sample.bean.SpringBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample03 {
+class Sample03 {
@Autowired
@Qualifier("node")
@@ -44,7 +45,7 @@ public class Sample03 {
private SpringBean node2;
@Test
- public void test() {
+ void test() {
assertNotNull(this.node1);
assertNotNull(this.node2);
assertNotSame(this.node1, this.node2);
@@ -60,7 +61,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_03.conf")
.withBean("node", SpringBean.class)
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample04.java b/src/test/java/net/jmob/jsconf/core/sample/Sample04.java
index 8f3dec4..d2d7d78 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample04.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample04.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,31 +17,32 @@
package net.jmob.jsconf.core.sample;
import net.jmob.jsconf.core.ConfigFormat;
-import org.apache.commons.dbcp.BasicDataSource;
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.Sequence;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample04 {
+class Sample04 {
@Autowired
private Sequence sequence;
@Test
- public void test() {
- Assert.assertNotNull(this.sequence);
+ void test() {
+ assertNotNull(this.sequence);
assertEquals("SEQ_NAME", this.sequence.getName());
assertEquals("org.apache.commons.dbcp.BasicDataSource", this.sequence.getDataSource()
.getClass().getName());
@@ -50,7 +51,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_04.conf")
.withFormat(ConfigFormat.CONF)
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample05.java b/src/test/java/net/jmob/jsconf/core/sample/Sample05.java
index a874be9..d6090d0 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample05.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample05.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,21 +18,22 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample05 {
+class Sample05 {
@Autowired
private ConfigBean conf;
@@ -42,14 +43,14 @@ public class Sample05 {
@Test
@Repeat(value = 4)
- public void test() {
+ void test() {
final Object ref = this.conf;
assertNotNull(this.conf);
assertEquals("https://localhost/Tic", this.conf.getUrl());
// Simulates configuration file change
this.factory.withResourceName("net/jmob/jsconf/core/sample/app_05_2").reload();
- assertTrue(ref == this.conf);
+ assertSame(ref, this.conf);
assertEquals("https://localhost/Tac", this.conf.getUrl());
this.factory.withResourceName("net/jmob/jsconf/core/sample/app_05").reload();
}
@@ -57,7 +58,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_05")
.withBean("simpleConf", ConfigBean.class, true);
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample06.java b/src/test/java/net/jmob/jsconf/core/sample/Sample06.java
index 82bff97..50b34b8 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample06.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample06.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,21 +18,22 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample06 {
+class Sample06 {
@Autowired
private ConfigBean conf;
@@ -42,7 +43,7 @@ public class Sample06 {
@Test
@Repeat(value = 4)
- public void test() {
+ void test() {
final Object ref = this.conf;
assertNotNull(this.conf);
assertEquals("https://localhost/Tic", this.conf.getUrl());
@@ -50,9 +51,9 @@ public void test() {
// Simulates configuration file change
this.factory.withResourceName("net/jmob/jsconf/core/sample/app_06_2").reload();
- assertTrue(ref == this.conf);
+ assertSame(ref, this.conf);
assertEquals("https://localhost/Tac", this.conf.getUrl());
- assertEquals(null, this.conf.getAMap());
+ assertNull(this.conf.getAMap());
this.factory.withResourceName("net/jmob/jsconf/core/sample/app_06").reload();
}
@@ -60,7 +61,7 @@ public void test() {
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_06.properties")
.withBean("simpleConf", ConfigBean.class, true);
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample07.java b/src/test/java/net/jmob/jsconf/core/sample/Sample07.java
index de73b19..39584d9 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample07.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample07.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,21 +18,24 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
@ActiveProfiles("PROD")
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample07 {
+class Sample07 {
@Autowired
private ConfigBean conf;
@@ -41,15 +44,15 @@ public class Sample07 {
private ConfigurationFactory factory;
@Test
- public void test() {
- Assert.assertEquals("Tac", this.conf.getUrl());
+ void test() {
+ assertEquals("Tac", this.conf.getUrl());
}
@Configuration
static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_07.conf")
.withBean("simpleConf", ConfigBean.class, true)
diff --git a/src/test/java/net/jmob/jsconf/core/sample/Sample08.java b/src/test/java/net/jmob/jsconf/core/sample/Sample08.java
index 88e6466..1701d42 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/Sample08.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/Sample08.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,20 +19,21 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
import net.jmob.jsconf.core.sample.bean.RootConfigBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class Sample08 {
+class Sample08 {
@Autowired
private RootConfigBean myConfig;
@@ -41,7 +42,7 @@ public class Sample08 {
private ConfigBean myConfigChild;
@Test
- public void testChild() {
+ void testChild() {
assertEquals("Tic", this.myConfig.getValue());
assertNotNull(this.myConfig.getChild());
assertEquals("https://localhost/Tic", this.myConfig.getChild().getUrl());
@@ -51,7 +52,7 @@ public void testChild() {
@Configuration
static class ContextConfiguration01 {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/sample/app_08")
.withBean("myRoot", RootConfigBean.class)
diff --git a/src/test/java/net/jmob/jsconf/core/sample/bean/ConfigBean.java b/src/test/java/net/jmob/jsconf/core/sample/bean/ConfigBean.java
index 6fc8ab7..21b622f 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/bean/ConfigBean.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/bean/ConfigBean.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/sample/bean/RootConfigBean.java b/src/test/java/net/jmob/jsconf/core/sample/bean/RootConfigBean.java
index 87e012f..e68cb8a 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/bean/RootConfigBean.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/bean/RootConfigBean.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/sample/bean/Sequence.java b/src/test/java/net/jmob/jsconf/core/sample/bean/Sequence.java
index 6be8a82..9e5bca7 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/bean/Sequence.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/bean/Sequence.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/sample/bean/SpringBean.java b/src/test/java/net/jmob/jsconf/core/sample/bean/SpringBean.java
index 6a3f9f3..a632aaa 100644
--- a/src/test/java/net/jmob/jsconf/core/sample/bean/SpringBean.java
+++ b/src/test/java/net/jmob/jsconf/core/sample/bean/SpringBean.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/test/AnnotationTest.java b/src/test/java/net/jmob/jsconf/core/test/AnnotationTest.java
index e29331e..6f53ed4 100644
--- a/src/test/java/net/jmob/jsconf/core/test/AnnotationTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/AnnotationTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,43 +16,47 @@
package net.jmob.jsconf.core.test;
-import net.jmob.jsconf.core.test.bean.MyConfig;
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.test.bean.ConfigAnnotated;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import net.jmob.jsconf.core.test.bean.MyConfig;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-@RunWith(SpringJUnit4ClassRunner.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class AnnotationTest {
+class AnnotationTest {
@Autowired
private ConfigAnnotated conf;
- @Test(expected = BeanInitializationException.class)
- public void testMissingAnnotation() {
- new ConfigurationFactory()
- .withResourceName("net/jmob/jsconf/core/test/app_annotated")
- .withBean(MyConfig.class);
+ @Test
+ void testMissingAnnotation() {
+ assertThrows(BeanInitializationException.class, () ->
+ new ConfigurationFactory()
+ .withResourceName("net/jmob/jsconf/core/test/app_annotated")
+ .withBean(MyConfig.class));
}
@Test
- public void testAnnotated() {
- Assert.assertEquals("Test", this.conf.getValue());
+ void testAnnotated() {
+ assertEquals("Test", this.conf.getValue());
}
@Configuration
- static class ContextConfiguration {
+ public static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/test/app_annotated.conf")
.withScanPackage(AnnotationTest.class.getPackage().getName());
diff --git a/src/test/java/net/jmob/jsconf/core/test/ChildTest.java b/src/test/java/net/jmob/jsconf/core/test/ChildTest.java
index b160fd6..28cd2c5 100644
--- a/src/test/java/net/jmob/jsconf/core/test/ChildTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/ChildTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,20 +18,21 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.test.bean.MyConfig;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class ChildTest {
+class ChildTest {
@Autowired
private MyConfig myConfig;
@@ -46,13 +47,13 @@ public class ChildTest {
private MyConfig myConfigChild2;
@Test
- public void testChild() {
+ void testChild() {
assertNotSame(this.myConfig, this.myConfig2);
assertNotSame(this.myConfigChild, this.myConfigChild2);
}
@Test
- public void testChild1() {
+ void testChild1() {
assertEquals("Tic", this.myConfig.getValue());
assertNotSame(this.myConfig, this.myConfig.getChild());
assertNotNull(this.myConfig.getChild());
@@ -61,7 +62,7 @@ public void testChild1() {
}
@Test
- public void testChild2() {
+ void testChild2() {
assertEquals("Tic", this.myConfig2.getValue());
assertNotSame(this.myConfig2, this.myConfig2.getChild());
assertNotNull(this.myConfig2.getChild());
@@ -70,9 +71,9 @@ public void testChild2() {
}
@Configuration
- static class ContextConfiguration01 {
+ public static class ContextConfiguration01 {
@Bean(name = "context")
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory().withResourceName("net/jmob/jsconf/core/test/app_child")
.withBean("myConfig", MyConfig.class)
.withBean("myConfig/child", MyConfig.class, "myConfigChild");
@@ -80,9 +81,9 @@ public static ConfigurationFactory configurationFactory() {
}
@Configuration
- static class ContextConfiguration02 {
+ public static class ContextConfiguration02 {
@Bean(name = "context2")
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory().withResourceName("net/jmob/jsconf/core/test/app_child2")
.withBean("myConfig", MyConfig.class, "myConfig2")
.withBean("myConfig/child", MyConfig.class, "myConfigChild2");
diff --git a/src/test/java/net/jmob/jsconf/core/test/ConfigTest.java b/src/test/java/net/jmob/jsconf/core/test/ConfigTest.java
index e1dd406..2d9114c 100644
--- a/src/test/java/net/jmob/jsconf/core/test/ConfigTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/ConfigTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,22 +20,23 @@
import net.jmob.jsconf.core.test.bean.MyConfig;
import net.jmob.jsconf.core.test.bean.ServiceSpringBean;
import net.jmob.jsconf.core.test.bean.SimpleBeanSpring;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class ConfigTest {
+class ConfigTest {
@Autowired()
@Qualifier(value = "test_2")
@@ -45,7 +46,7 @@ public class ConfigTest {
private ServiceSpringBean service;
@Test
- public void testServiceSpringBean() {
+ void testServiceSpringBean() {
MyConfig localConfig = this.service.getConfig();
assertNotNull(localConfig.getChild());
assertEquals("Hello World, I a spring bean!", this.service.getValue());
@@ -61,7 +62,7 @@ public void testServiceSpringBean() {
}
@Test
- public void testSimpleBeanSpring() {
+ void testSimpleBeanSpring() {
assertEquals("I am a child of springOnConf!", this.config.getValue());
assertEquals("Hello from child", this.config.getChildRef().getValue());
assertEquals(this.service.getConfig().getChild(), this.config.getChildRef());
@@ -69,7 +70,7 @@ public void testSimpleBeanSpring() {
@Configuration
@ComponentScan(basePackageClasses = {ServiceSpringBean.class})
- static class ContextConfiguration {
+ public static class ContextConfiguration {
@Bean
public static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
diff --git a/src/test/java/net/jmob/jsconf/core/test/ProfileTest.java b/src/test/java/net/jmob/jsconf/core/test/ProfileTest.java
index b68bde1..75fb6f4 100644
--- a/src/test/java/net/jmob/jsconf/core/test/ProfileTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/ProfileTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,21 +18,22 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
@ActiveProfiles("PROD")
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class ProfileTest {
+class ProfileTest {
@Autowired
private ConfigBean simpleConf;
@@ -47,19 +48,19 @@ public class ProfileTest {
private ConfigurationFactory context02;
@Test
- public void testProfile() {
- Assert.assertEquals("Tac", this.simpleConf.getUrl());
+ void testProfile() {
+ assertEquals("Tac", this.simpleConf.getUrl());
}
@Test
- public void testProfileConf() {
- Assert.assertEquals("Tac", this.simpleConf2.getUrl());
+ void testProfileConf() {
+ assertEquals("Tac", this.simpleConf2.getUrl());
}
@Configuration
- static class ContextConfiguration01 {
+ public static class ContextConfiguration01 {
@Bean(name = "context01")
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName("net/jmob/jsconf/core/test/app_profile")
.withBean("simpleConf", ConfigBean.class)
diff --git a/src/test/java/net/jmob/jsconf/core/test/RealReloadingTest.java b/src/test/java/net/jmob/jsconf/core/test/RealReloadingTest.java
index 6363474..355fffb 100644
--- a/src/test/java/net/jmob/jsconf/core/test/RealReloadingTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/RealReloadingTest.java
@@ -2,15 +2,16 @@
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.sample.bean.ConfigBean;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import java.io.File;
@@ -21,12 +22,14 @@
import java.nio.file.Paths;
import static java.lang.Thread.sleep;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+
// Test required to have put ${java.io.tmpdir} on ClassPath
-@RunWith(SpringJUnit4ClassRunner.class)
+@Disabled
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class RealReloadingTest {
+class RealReloadingTest {
private static final String TIC = "Tic";
private static final String TAC = "Tac";
@@ -37,31 +40,31 @@ public class RealReloadingTest {
@Autowired
private ConfigBean conf;
- @BeforeClass
- public static void init() throws IOException {
- tempDirectory = Files.createTempDirectory("jsconf-" .concat(Long.toString(System.nanoTime())));
+ @BeforeAll
+ static void init() throws IOException {
+ tempDirectory = Files.createTempDirectory("jsconf-".concat(Long.toString(System.nanoTime())));
tempFile = Files.createFile(Paths.get(tempDirectory.toString(), "app.conf"));
}
- @AfterClass
- public static void clean() throws IOException {
+ @AfterAll
+ static void clean() throws IOException {
Files.deleteIfExists(tempFile);
Files.deleteIfExists(tempDirectory);
}
@Test
- // Test required to have put ${java.io.tmpdir} on ClassPath
- public void testRealReloading() throws IOException, InterruptedException {
+ // Test required to have put ${java.io.tmpdir} on ClassPath
+ void testRealReloading() throws IOException, InterruptedException {
final Object ref = this.conf;
assertNotNull(this.conf);
- assertEquals(null, this.conf.getUrl());
+ assertNull(this.conf.getUrl());
write(TIC);
assertEquals(TIC, this.conf.getUrl());
write(TAC);
assertEquals(TAC, this.conf.getUrl());
- assertTrue(ref == this.conf);
+ assertSame(ref, this.conf);
Files.deleteIfExists(tempFile);
Files.createFile(Paths.get(tempDirectory.toString(), "app.conf"));
@@ -75,13 +78,13 @@ private void write(String value) throws IOException, InterruptedException {
fw.append("simpleConf : { url : \"").append(value).append("\" }");
fw.flush();
}
- sleep(5000);
+ sleep(10000);
}
@Configuration
- static class ContextConfiguration {
+ public static class ContextConfiguration {
@Bean
- public static ConfigurationFactory configurationFactory() {
+ static ConfigurationFactory configurationFactory() {
return new ConfigurationFactory()
.withResourceName(tempDirectory.getName(tempDirectory.getNameCount() - 1) + "/app.conf")//
.withBean("simpleConf", ConfigBean.class, "myBeanId", true);
diff --git a/src/test/java/net/jmob/jsconf/core/test/VirtualBeanTest.java b/src/test/java/net/jmob/jsconf/core/test/VirtualBeanTest.java
index 809c5bc..e96a42b 100644
--- a/src/test/java/net/jmob/jsconf/core/test/VirtualBeanTest.java
+++ b/src/test/java/net/jmob/jsconf/core/test/VirtualBeanTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,11 +16,11 @@
package net.jmob.jsconf.core.test;
-import net.jmob.jsconf.core.test.bean.ConfigByInterface;
import net.jmob.jsconf.core.ConfigurationFactory;
import net.jmob.jsconf.core.impl.VirtualBean;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import net.jmob.jsconf.core.test.bean.ConfigByInterface;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -29,16 +29,17 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.jmx.access.InvocationFailureException;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import java.util.HashMap;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
-public class VirtualBeanTest {
+class VirtualBeanTest {
@Autowired
@Qualifier("simpleConf")
@@ -51,7 +52,7 @@ public class VirtualBeanTest {
private ConfigByInterface conf3;
@Test
- public void testHashCode() {
+ void testHashCode() {
assertEquals(-1831264279, this.conf.hashCode());
assertEquals(this.conf.hashCode(), this.conf2.hashCode());
assertEquals(-1828017501, this.conf3.hashCode());
@@ -59,12 +60,12 @@ public void testHashCode() {
}
@Test
- public void testEquals() {
- assertNotEquals(this.conf, "");
- assertNotEquals(this.conf, null);
+ void testEquals() {
+ assertNotEquals("", this.conf);
+ assertNotNull(this.conf);
assertEquals(this.conf, this.conf);
assertEquals(new VirtualBean(null), new VirtualBean(null));
- assertEquals(new VirtualBean(new HashMap
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/test/bean/ConfigByInterface.java b/src/test/java/net/jmob/jsconf/core/test/bean/ConfigByInterface.java
index 9afba13..1e94ccd 100644
--- a/src/test/java/net/jmob/jsconf/core/test/bean/ConfigByInterface.java
+++ b/src/test/java/net/jmob/jsconf/core/test/bean/ConfigByInterface.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/test/bean/MyConfig.java b/src/test/java/net/jmob/jsconf/core/test/bean/MyConfig.java
index 4929281..c27710b 100644
--- a/src/test/java/net/jmob/jsconf/core/test/bean/MyConfig.java
+++ b/src/test/java/net/jmob/jsconf/core/test/bean/MyConfig.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/test/bean/ServiceSpringBean.java b/src/test/java/net/jmob/jsconf/core/test/bean/ServiceSpringBean.java
index 099d4c0..fb603d3 100644
--- a/src/test/java/net/jmob/jsconf/core/test/bean/ServiceSpringBean.java
+++ b/src/test/java/net/jmob/jsconf/core/test/bean/ServiceSpringBean.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/net/jmob/jsconf/core/test/bean/SimpleBeanSpring.java b/src/test/java/net/jmob/jsconf/core/test/bean/SimpleBeanSpring.java
index 82fa1e7..be13090 100644
--- a/src/test/java/net/jmob/jsconf/core/test/bean/SimpleBeanSpring.java
+++ b/src/test/java/net/jmob/jsconf/core/test/bean/SimpleBeanSpring.java
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/resources/net/jmob/jsconf/core/sample/app_06.properties b/src/test/resources/net/jmob/jsconf/core/sample/app_06.properties
index 3cff864..4cf17b5 100644
--- a/src/test/resources/net/jmob/jsconf/core/sample/app_06.properties
+++ b/src/test/resources/net/jmob/jsconf/core/sample/app_06.properties
@@ -1,3 +1,3 @@
-simpleConf.url = https://localhost/Tic
-simpleConf.aMap.key1= test1
-simpleConf.aMap.key2= test2
\ No newline at end of file
+simpleConf.url=https://localhost/Tic
+simpleConf.aMap.key1=test1
+simpleConf.aMap.key2=test2
\ No newline at end of file
diff --git a/src/test/resources/net/jmob/jsconf/core/sample/app_06_2.properties b/src/test/resources/net/jmob/jsconf/core/sample/app_06_2.properties
index a172321..564007a 100644
--- a/src/test/resources/net/jmob/jsconf/core/sample/app_06_2.properties
+++ b/src/test/resources/net/jmob/jsconf/core/sample/app_06_2.properties
@@ -1 +1 @@
-simpleConf.url = https://localhost/Tac
\ No newline at end of file
+simpleConf.url=https://localhost/Tac
\ No newline at end of file