diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java index 261ea34bd8..773291168f 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class CronTriggerTests { this.timeZone = timeZone; } - @Parameters + @Parameters(name = "date [{0}], time zone [{1}]") public static List getParameters() { List list = new ArrayList(); list.add(new Object[] { new Date(), TimeZone.getTimeZone("PST") }); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java index 39df5a823a..779f929894 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.AbstractTestExecutionListener; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; +import org.springframework.util.ClassUtils; import static org.junit.Assert.*; @@ -66,24 +67,24 @@ public class FailingBeforeAndAfterMethodsJUnitTests { protected final Class clazz; - public FailingBeforeAndAfterMethodsJUnitTests(final Class clazz) { - this.clazz = clazz; - } - - @Parameters + @Parameters(name = "{0}") public static Collection testData() { return Arrays.asList(new Object[][] {// // - { AlwaysFailingBeforeTestClassTestCase.class },// - { AlwaysFailingAfterTestClassTestCase.class },// - { AlwaysFailingPrepareTestInstanceTestCase.class },// - { AlwaysFailingBeforeTestMethodTestCase.class },// - { AlwaysFailingAfterTestMethodTestCase.class },// - { FailingBeforeTransactionTestCase.class },// - { FailingAfterTransactionTestCase.class } // + { AlwaysFailingBeforeTestClassTestCase.class.getSimpleName() },// + { AlwaysFailingAfterTestClassTestCase.class.getSimpleName() },// + { AlwaysFailingPrepareTestInstanceTestCase.class.getSimpleName() },// + { AlwaysFailingBeforeTestMethodTestCase.class.getSimpleName() },// + { AlwaysFailingAfterTestMethodTestCase.class.getSimpleName() },// + { FailingBeforeTransactionTestCase.class.getSimpleName() },// + { FailingAfterTransactionTestCase.class.getSimpleName() } // }); } + public FailingBeforeAndAfterMethodsJUnitTests(String testClassName) throws Exception { + this.clazz = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); + } + @Test public void runTestAndAssertCounters() throws Exception { final TrackingRunListener listener = new TrackingRunListener(); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java index bb2bccc3db..6ea6ce3016 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java @@ -34,6 +34,7 @@ import org.springframework.test.context.testng.AbstractTransactionalTestNGSpring import org.springframework.test.context.testng.TrackingTestNGTestListener; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; +import org.springframework.util.ClassUtils; import org.testng.TestNG; @@ -73,30 +74,29 @@ public class FailingBeforeAndAfterMethodsTestNGTests { protected final int expectedFailedConfigurationsCount; - public FailingBeforeAndAfterMethodsTestNGTests(final Class clazz, final int expectedTestStartCount, - final int expectedTestSuccessCount, final int expectedFailureCount, - final int expectedFailedConfigurationsCount) { - this.clazz = clazz; - this.expectedTestStartCount = expectedTestStartCount; - this.expectedTestSuccessCount = expectedTestSuccessCount; - this.expectedFailureCount = expectedFailureCount; - this.expectedFailedConfigurationsCount = expectedFailedConfigurationsCount; - } - - @Parameters + @Parameters(name = "{0}") public static Collection testData() { return Arrays.asList(new Object[][] {// // - { AlwaysFailingBeforeTestClassTestCase.class, 1, 0, 0, 1 },// - { AlwaysFailingAfterTestClassTestCase.class, 1, 1, 0, 1 },// - { AlwaysFailingPrepareTestInstanceTestCase.class, 1, 0, 0, 1 },// - { AlwaysFailingBeforeTestMethodTestCase.class, 1, 0, 0, 1 },// - { AlwaysFailingAfterTestMethodTestCase.class, 1, 1, 0, 1 },// - { FailingBeforeTransactionTestCase.class, 1, 0, 0, 1 },// - { FailingAfterTransactionTestCase.class, 1, 1, 0, 1 } // + { AlwaysFailingBeforeTestClassTestCase.class.getSimpleName(), 1, 0, 0, 1 },// + { AlwaysFailingAfterTestClassTestCase.class.getSimpleName(), 1, 1, 0, 1 },// + { AlwaysFailingPrepareTestInstanceTestCase.class.getSimpleName(), 1, 0, 0, 1 },// + { AlwaysFailingBeforeTestMethodTestCase.class.getSimpleName(), 1, 0, 0, 1 },// + { AlwaysFailingAfterTestMethodTestCase.class.getSimpleName(), 1, 1, 0, 1 },// + { FailingBeforeTransactionTestCase.class.getSimpleName(), 1, 0, 0, 1 },// + { FailingAfterTransactionTestCase.class.getSimpleName(), 1, 1, 0, 1 } // }); } + public FailingBeforeAndAfterMethodsTestNGTests(String testClassName, int expectedTestStartCount, + int expectedTestSuccessCount, int expectedFailureCount, int expectedFailedConfigurationsCount) throws Exception { + this.clazz = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); + this.expectedTestStartCount = expectedTestStartCount; + this.expectedTestSuccessCount = expectedTestSuccessCount; + this.expectedFailureCount = expectedFailureCount; + this.expectedFailedConfigurationsCount = expectedFailedConfigurationsCount; + } + @Test public void runTestAndAssertCounters() throws Exception { final TrackingTestNGTestListener listener = new TrackingTestNGTestListener(); diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java index 69d65db5b8..7d57eb1128 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ParameterizedDependencyInjectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; @@ -58,26 +59,22 @@ public class ParameterizedDependencyInjectionTests { private static final List employees = new ArrayList(); + private final TestContextManager testContextManager = new TestContextManager(getClass()); + @Autowired private ApplicationContext applicationContext; @Autowired private Pet pet; - private final String employeeBeanName; - private final String employeeName; - - private final TestContextManager testContextManager; + @Parameter(0) + public String employeeBeanName; + @Parameter(1) + public String employeeName; - public ParameterizedDependencyInjectionTests(final String employeeBeanName, final String employeeName) - throws Exception { - this.testContextManager = new TestContextManager(getClass()); - this.employeeBeanName = employeeBeanName; - this.employeeName = employeeName; - } - @Parameters + @Parameters(name = "bean [{0}], employee [{1}]") public static Collection employeeData() { return Arrays.asList(new String[][] { { "employee1", "John Smith" }, { "employee2", "Jane Smith" } }); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java index ebbda9125c..a910ce0721 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/RepeatedSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.test.annotation.Repeat; import org.springframework.test.annotation.Timed; import org.springframework.test.context.TestExecutionListeners; +import org.springframework.util.ClassUtils; import static org.junit.Assert.*; @@ -52,7 +53,7 @@ public class RepeatedSpringRunnerTests { private static final AtomicInteger invocationCount = new AtomicInteger(); - private final Class testClass; + private final Class testClass; private final int expectedFailureCount; @@ -63,28 +64,28 @@ public class RepeatedSpringRunnerTests { private final int expectedInvocationCount; - public RepeatedSpringRunnerTests(Class testClass, int expectedFailureCount, - int expectedTestStartedCount, int expectedTestFinishedCount, int expectedInvocationCount) { - this.testClass = testClass; - this.expectedFailureCount = expectedFailureCount; - this.expectedTestStartedCount = expectedTestStartedCount; - this.expectedTestFinishedCount = expectedTestFinishedCount; - this.expectedInvocationCount = expectedInvocationCount; - } - - @Parameters + @Parameters(name = "{0}") public static Collection repetitionData() { return Arrays.asList(new Object[][] {// // - { NonAnnotatedRepeatedTestCase.class, 0, 1, 1, 1 },// - { DefaultRepeatValueRepeatedTestCase.class, 0, 1, 1, 1 },// - { NegativeRepeatValueRepeatedTestCase.class, 0, 1, 1, 1 },// - { RepeatedFiveTimesRepeatedTestCase.class, 0, 1, 1, 5 },// - { RepeatedFiveTimesViaMetaAnnotationRepeatedTestCase.class, 0, 1, 1, 5 },// - { TimedRepeatedTestCase.class, 3, 4, 4, (5 + 1 + 4 + 10) } // + { NonAnnotatedRepeatedTestCase.class.getSimpleName(), 0, 1, 1, 1 },// + { DefaultRepeatValueRepeatedTestCase.class.getSimpleName(), 0, 1, 1, 1 },// + { NegativeRepeatValueRepeatedTestCase.class.getSimpleName(), 0, 1, 1, 1 },// + { RepeatedFiveTimesRepeatedTestCase.class.getSimpleName(), 0, 1, 1, 5 },// + { RepeatedFiveTimesViaMetaAnnotationRepeatedTestCase.class.getSimpleName(), 0, 1, 1, 5 },// + { TimedRepeatedTestCase.class.getSimpleName(), 3, 4, 4, (5 + 1 + 4 + 10) } // }); } + public RepeatedSpringRunnerTests(String testClassName, int expectedFailureCount, + int expectedTestStartedCount, int expectedTestFinishedCount, int expectedInvocationCount) throws Exception { + this.testClass = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); + this.expectedFailureCount = expectedFailureCount; + this.expectedTestStartedCount = expectedTestStartedCount; + this.expectedTestFinishedCount = expectedTestFinishedCount; + this.expectedInvocationCount = expectedInvocationCount; + } + @Test public void assertRepetitions() throws Exception { TrackingRunListener listener = new TrackingRunListener(); diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java index 2427f83f91..afd9590392 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - import org.springframework.core.annotation.AnnotationUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; +import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import static org.junit.Assert.*; @@ -55,12 +55,7 @@ public class GenericXmlContextLoaderResourceLocationsTests { protected final String[] expectedLocations; - public GenericXmlContextLoaderResourceLocationsTests(final Class testClass, final String[] expectedLocations) { - this.testClass = testClass; - this.expectedLocations = expectedLocations; - } - - @Parameters + @Parameters(name = "{0}") public static Collection contextConfigurationLocationsData() { @ContextConfiguration class ClasspathNonExistentDefaultLocationsTestCase { @@ -93,25 +88,25 @@ public class GenericXmlContextLoaderResourceLocationsTests { return Arrays.asList(new Object[][] { - { ClasspathNonExistentDefaultLocationsTestCase.class, new String[] {} }, + { ClasspathNonExistentDefaultLocationsTestCase.class.getSimpleName(), new String[] {} }, { - ClasspathExistentDefaultLocationsTestCase.class, + ClasspathExistentDefaultLocationsTestCase.class.getSimpleName(), new String[] { "classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$1ClasspathExistentDefaultLocationsTestCase-context.xml" } }, { - ImplicitClasspathLocationsTestCase.class, + ImplicitClasspathLocationsTestCase.class.getSimpleName(), new String[] { "classpath:/org/springframework/test/context/support/context1.xml", "classpath:/org/springframework/test/context/support/context2.xml" } }, - { ExplicitClasspathLocationsTestCase.class, new String[] { "classpath:context.xml" } }, + { ExplicitClasspathLocationsTestCase.class.getSimpleName(), new String[] { "classpath:context.xml" } }, - { ExplicitFileLocationsTestCase.class, new String[] { "file:/testing/directory/context.xml" } }, + { ExplicitFileLocationsTestCase.class.getSimpleName(), new String[] { "file:/testing/directory/context.xml" } }, - { ExplicitUrlLocationsTestCase.class, new String[] { "http://example.com/context.xml" } }, + { ExplicitUrlLocationsTestCase.class.getSimpleName(), new String[] { "http://example.com/context.xml" } }, { - ExplicitMixedPathTypesLocationsTestCase.class, + ExplicitMixedPathTypesLocationsTestCase.class.getSimpleName(), new String[] { "classpath:/org/springframework/test/context/support/context1.xml", "classpath:context2.xml", "classpath:/context3.xml", "file:/testing/directory/context.xml", "http://example.com/context.xml" } } @@ -119,6 +114,11 @@ public class GenericXmlContextLoaderResourceLocationsTests { }); } + public GenericXmlContextLoaderResourceLocationsTests(final String testClassName, final String[] expectedLocations) throws Exception { + this.testClass = ClassUtils.forName(getClass().getName() + "$1" + testClassName, getClass().getClassLoader()); + this.expectedLocations = expectedLocations; + } + @Test public void assertContextConfigurationLocations() throws Exception { diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java index 7121a8bfe8..b60aebb744 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java @@ -16,8 +16,6 @@ package org.springframework.web.context.request; -import static org.junit.Assert.*; - import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; @@ -27,11 +25,14 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; +import static org.junit.Assert.*; + /** * Parameterized tests for ServletWebRequest * @author Juergen Hoeller @@ -49,9 +50,10 @@ public class ServletWebRequestHttpMethodsTests { private ServletWebRequest request; - private String method; + @Parameter + public String method; - @Parameters + @Parameters(name = "{0}") static public Iterable safeMethods() { return Arrays.asList(new Object[][] { {"GET"}, @@ -59,10 +61,6 @@ public class ServletWebRequestHttpMethodsTests { }); } - public ServletWebRequestHttpMethodsTests(String method) { - this.method = method; - } - @Before public void setUp() { dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java index a0695ffa94..76ef4a63a5 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java @@ -16,9 +16,6 @@ package org.springframework.web.socket; - -import static org.junit.Assert.*; - import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -29,6 +26,8 @@ import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -41,6 +40,7 @@ import org.springframework.web.socket.handler.AbstractWebSocketHandler; import org.springframework.web.socket.handler.TextWebSocketHandler; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; +import static org.junit.Assert.*; /** * Client and server-side WebSocket integration tests. @@ -50,7 +50,7 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler; @RunWith(Parameterized.class) public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { - @Parameterized.Parameters + @Parameters(name = "server [{0}], client [{1}]") public static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java index 88d407b42c..1a66397b7b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ import static org.junit.Assert.*; @RunWith(Parameterized.class) public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTests { - @Parameters + @Parameters(name = "server [{0}], client [{1}]") public static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java index 55d9003829..8637f45971 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.* @RunWith(Parameterized.class) public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { - @Parameters + @Parameters(name = "server [{0}], client [{1}]") public static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()},