Polish and revive disabled tests
This commit revives some previously disabled tests and converts some usage of @Disabled to @EnabledForTestGroups(...).
This commit is contained in:
parent
35b967a801
commit
591995ecc8
|
|
@ -21,6 +21,7 @@ import java.util.ServiceLoader;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
|
|
@ -33,12 +34,15 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class ServiceLoaderTests {
|
class ServiceLoaderTests {
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void assumeDocumentBuilderFactoryCanBeLoaded() {
|
||||||
|
assumeTrue(ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServiceLoaderFactoryBean() {
|
void testServiceLoaderFactoryBean() {
|
||||||
assumeTrue(ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext());
|
|
||||||
|
|
||||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||||
RootBeanDefinition bd = new RootBeanDefinition(ServiceLoaderFactoryBean.class);
|
RootBeanDefinition bd = new RootBeanDefinition(ServiceLoaderFactoryBean.class);
|
||||||
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
||||||
|
|
@ -49,9 +53,7 @@ public class ServiceLoaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServiceFactoryBean() {
|
void testServiceFactoryBean() {
|
||||||
assumeTrue(ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext());
|
|
||||||
|
|
||||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||||
RootBeanDefinition bd = new RootBeanDefinition(ServiceFactoryBean.class);
|
RootBeanDefinition bd = new RootBeanDefinition(ServiceFactoryBean.class);
|
||||||
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
||||||
|
|
@ -61,9 +63,7 @@ public class ServiceLoaderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServiceListFactoryBean() {
|
void testServiceListFactoryBean() {
|
||||||
assumeTrue(ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext());
|
|
||||||
|
|
||||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||||
RootBeanDefinition bd = new RootBeanDefinition(ServiceListFactoryBean.class);
|
RootBeanDefinition bd = new RootBeanDefinition(ServiceListFactoryBean.class);
|
||||||
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package org.springframework.context.support;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.beans.MutablePropertyValues;
|
import org.springframework.beans.MutablePropertyValues;
|
||||||
|
|
@ -31,6 +30,7 @@ import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.tests.sample.beans.TestBean;
|
import org.springframework.tests.sample.beans.TestBean;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
* as opposed to using only a BeanFactory during testing.
|
* as opposed to using only a BeanFactory during testing.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
|
* @author Sam Brannen
|
||||||
* @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests
|
* @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests
|
||||||
*/
|
*/
|
||||||
public class PropertyResourceConfigurerIntegrationTests {
|
public class PropertyResourceConfigurerIntegrationTests {
|
||||||
|
|
@ -54,8 +55,8 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs.add("location", "${user.dir}/test");
|
pvs.add("location", "${user.dir}/test");
|
||||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
String userDir = getUserDir();
|
String userDir = getUserDir();
|
||||||
assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(
|
assertThatExceptionOfType(BeanInitializationException.class)
|
||||||
ac::refresh)
|
.isThrownBy(ac::refresh)
|
||||||
.withCauseInstanceOf(FileNotFoundException.class)
|
.withCauseInstanceOf(FileNotFoundException.class)
|
||||||
.withMessageContaining(userDir);
|
.withMessageContaining(userDir);
|
||||||
}
|
}
|
||||||
|
|
@ -70,8 +71,8 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs.add("location", "${user.dir}/test/${user.dir}");
|
pvs.add("location", "${user.dir}/test/${user.dir}");
|
||||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
String userDir = getUserDir();
|
String userDir = getUserDir();
|
||||||
assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(
|
assertThatExceptionOfType(BeanInitializationException.class)
|
||||||
ac::refresh)
|
.isThrownBy(ac::refresh)
|
||||||
.withCauseInstanceOf(FileNotFoundException.class)
|
.withCauseInstanceOf(FileNotFoundException.class)
|
||||||
.matches(ex -> ex.getMessage().contains(userDir + "/test/" + userDir) ||
|
.matches(ex -> ex.getMessage().contains(userDir + "/test/" + userDir) ||
|
||||||
ex.getMessage().contains(userDir + "/test//" + userDir));
|
ex.getMessage().contains(userDir + "/test//" + userDir));
|
||||||
|
|
@ -95,8 +96,8 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs = new MutablePropertyValues();
|
pvs = new MutablePropertyValues();
|
||||||
pvs.add("location", "${myprop}/test/${myprop}");
|
pvs.add("location", "${myprop}/test/${myprop}");
|
||||||
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(
|
assertThatExceptionOfType(BeanInitializationException.class)
|
||||||
ac::refresh)
|
.isThrownBy(ac::refresh)
|
||||||
.withMessageContaining("myprop");
|
.withMessageContaining("myprop");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,8 +110,7 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs = new MutablePropertyValues();
|
pvs = new MutablePropertyValues();
|
||||||
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${var}");
|
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${var}");
|
||||||
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(
|
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(ac::refresh);
|
||||||
ac::refresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -122,8 +122,7 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs = new MutablePropertyValues();
|
pvs = new MutablePropertyValues();
|
||||||
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
|
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m}");
|
||||||
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(
|
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(ac::refresh);
|
||||||
ac::refresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -135,31 +134,35 @@ public class PropertyResourceConfigurerIntegrationTests {
|
||||||
pvs = new MutablePropertyValues();
|
pvs = new MutablePropertyValues();
|
||||||
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m2}");
|
pvs.add("properties", "var=${m}var\nm=${var2}\nvar2=${m2}");
|
||||||
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
ac.registerSingleton("configurer1", PropertyPlaceholderConfigurer.class, pvs);
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(
|
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(ac::refresh);
|
||||||
ac::refresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled // this test was breaking after the 3.0 repackaging
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithAutowireByType() {
|
public void testPropertyPlaceholderConfigurerWithValueFromSystemProperty() {
|
||||||
// StaticApplicationContext ac = new StaticApplicationContext();
|
final String propertyName = getClass().getName() + ".test";
|
||||||
// MutablePropertyValues pvs = new MutablePropertyValues();
|
|
||||||
// pvs.addPropertyValue("touchy", "${test}");
|
try {
|
||||||
// ac.registerSingleton("tb", TestBean.class, pvs);
|
System.setProperty(propertyName, "mytest");
|
||||||
// pvs = new MutablePropertyValues();
|
|
||||||
// pvs.addPropertyValue("target", new RuntimeBeanReference("tb"));
|
StaticApplicationContext context = new StaticApplicationContext();
|
||||||
// // uncomment when fixing this test
|
|
||||||
// // ac.registerSingleton("tbProxy", org.springframework.aop.framework.ProxyFactoryBean.class, pvs);
|
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||||
// pvs = new MutablePropertyValues();
|
pvs.addPropertyValue("touchy", "${" + propertyName + "}");
|
||||||
// Properties props = new Properties();
|
context.registerSingleton("tb", TestBean.class, pvs);
|
||||||
// props.put("test", "mytest");
|
|
||||||
// pvs.addPropertyValue("properties", new Properties(props));
|
pvs = new MutablePropertyValues();
|
||||||
// RootBeanDefinition ppcDef = new RootBeanDefinition(PropertyPlaceholderConfigurer.class, pvs);
|
pvs.addPropertyValue("target", new RuntimeBeanReference("tb"));
|
||||||
// ppcDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
|
context.registerSingleton("tbProxy", org.springframework.aop.framework.ProxyFactoryBean.class, pvs);
|
||||||
// ac.registerBeanDefinition("configurer", ppcDef);
|
|
||||||
// ac.refresh();
|
context.registerSingleton("configurer", PropertyPlaceholderConfigurer.class);
|
||||||
// TestBean tb = (TestBean) ac.getBean("tb");
|
context.refresh();
|
||||||
// assertEquals("mytest", tb.getTouchy());
|
|
||||||
|
TestBean testBean = context.getBean("tb", TestBean.class);
|
||||||
|
assertThat(testBean.getTouchy()).isEqualTo("mytest");
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
System.clearProperty(propertyName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import java.util.concurrent.RejectedExecutionHandler;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.core.task.NoOpRunnable;
|
import org.springframework.core.task.NoOpRunnable;
|
||||||
|
|
@ -142,8 +141,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
verify(runnable, atLeast(2)).run();
|
verify(runnable, atLeast(2)).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Test
|
@Test
|
||||||
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
Runnable runnable = mock(Runnable.class);
|
Runnable runnable = mock(Runnable.class);
|
||||||
|
|
||||||
|
|
@ -162,8 +161,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
verify(runnable, never()).run();
|
verify(runnable, never()).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
|
||||||
@Test
|
@Test
|
||||||
|
@EnabledForTestGroups(PERFORMANCE)
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||||
Runnable runnable = mock(Runnable.class);
|
Runnable runnable = mock(Runnable.class);
|
||||||
willThrow(new IllegalStateException()).given(runnable).run();
|
willThrow(new IllegalStateException()).given(runnable).run();
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,14 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.tests.EnabledForTestGroups;
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
import static org.springframework.tests.TestGroup.CI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for various {@link Resource} implementations.
|
* Unit tests for various {@link Resource} implementations.
|
||||||
|
|
@ -218,10 +219,10 @@ class ResourceTests {
|
||||||
assertThat(relative).isEqualTo(new UrlResource("file:dir/subdir"));
|
assertThat(relative).isEqualTo(new UrlResource("file:dir/subdir"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
@Test
|
||||||
@Test // this test is quite slow. TODO: re-enable with JUnit categories
|
@EnabledForTestGroups(CI)
|
||||||
void testNonFileResourceExists() throws Exception {
|
void testNonFileResourceExists() throws Exception {
|
||||||
Resource resource = new UrlResource("https://www.springframework.org");
|
Resource resource = new UrlResource("https://spring.io/");
|
||||||
assertThat(resource.exists()).isTrue();
|
assertThat(resource.exists()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ public class PersistenceXmlParsingTests {
|
||||||
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse();
|
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled // not doing schema parsing anymore for JPA 2.0 compatibility
|
@Disabled("not doing schema parsing anymore for JPA 2.0 compatibility")
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidPersistence() throws Exception {
|
public void testInvalidPersistence() throws Exception {
|
||||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||||
|
|
@ -264,7 +264,7 @@ public class PersistenceXmlParsingTests {
|
||||||
reader.readPersistenceUnitInfos(resource));
|
reader.readPersistenceUnitInfos(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled // not doing schema parsing anymore for JPA 2.0 compatibility
|
@Disabled("not doing schema parsing anymore for JPA 2.0 compatibility")
|
||||||
@Test
|
@Test
|
||||||
public void testNoSchemaPersistence() throws Exception {
|
public void testNoSchemaPersistence() throws Exception {
|
||||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ import javax.persistence.PersistenceContextType;
|
||||||
import javax.persistence.PersistenceProperty;
|
import javax.persistence.PersistenceProperty;
|
||||||
import javax.persistence.PersistenceUnit;
|
import javax.persistence.PersistenceUnit;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
@ -337,7 +336,6 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled
|
|
||||||
public void testPersistenceUnitsFromJndi() {
|
public void testPersistenceUnitsFromJndi() {
|
||||||
EntityManager mockEm = mock(EntityManager.class);
|
EntityManager mockEm = mock(EntityManager.class);
|
||||||
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
||||||
|
|
|
||||||
|
|
@ -300,8 +300,9 @@ public class UrlPathHelperTests {
|
||||||
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/");
|
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Disabled
|
||||||
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
|
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
|
||||||
@Test @Disabled
|
@Test
|
||||||
public void tomcatCasualServletRootWithMissingSlash() throws Exception {
|
public void tomcatCasualServletRootWithMissingSlash() throws Exception {
|
||||||
request.setContextPath("/test");
|
request.setContextPath("/test");
|
||||||
request.setPathInfo(null);
|
request.setPathInfo(null);
|
||||||
|
|
@ -348,8 +349,8 @@ public class UrlPathHelperTests {
|
||||||
tomcatCasualServletRoot();
|
tomcatCasualServletRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
|
|
||||||
@Disabled
|
@Disabled
|
||||||
|
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
|
||||||
@Test
|
@Test
|
||||||
public void wasCasualServletRootWithMissingSlash() throws Exception {
|
public void wasCasualServletRootWithMissingSlash() throws Exception {
|
||||||
request.setContextPath("/test");
|
request.setContextPath("/test");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue