diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTestCase.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTestCase.java index 68fe8cf8fb0..2a5f9bf298c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTestCase.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTestCase.java @@ -74,7 +74,7 @@ class NestedTestsWithSpringAndJUnitJupiterTestCase { // ------------------------------------------------------------------------- @Configuration - public static class TopLevelConfig { + static class TopLevelConfig { @Bean String foo() { diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java index 5bf4f6b9e9f..3037b4f0f46 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java @@ -108,6 +108,11 @@ abstract class AbstractContextConfigurationUtilsTests { assertEquals(expectedInitializerClasses, mergedConfig.getContextInitializerClasses()); } + @SafeVarargs + static T[] array(T... objects) { + return objects; + } + static class Enigma { } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java index b499c257a84..2cc0dc4b87c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -76,7 +76,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur assertMergedConfig( mergedConfig, testClass, - new String[] { "classpath:org/springframework/test/context/support/AbstractContextConfigurationUtilsTests$BareAnnotations-context.xml" }, + array("classpath:org/springframework/test/context/support/AbstractContextConfigurationUtilsTests$BareAnnotations-context.xml"), EMPTY_CLASS_ARRAY, DelegatingSmartContextLoader.class); } @@ -85,7 +85,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur Class testClass = LocationsFoo.class; MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, new String[] { "classpath:/foo.xml" }, EMPTY_CLASS_ARRAY, + assertMergedConfig(mergedConfig, testClass, array("classpath:/foo.xml"), EMPTY_CLASS_ARRAY, DelegatingSmartContextLoader.class); } @@ -94,7 +94,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur Class testClass = MetaLocationsFoo.class; MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, new String[] { "classpath:/foo.xml" }, EMPTY_CLASS_ARRAY, + assertMergedConfig(mergedConfig, testClass, array("classpath:/foo.xml"), EMPTY_CLASS_ARRAY, DelegatingSmartContextLoader.class); } @@ -107,8 +107,8 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur private void buildMergedConfigWithMetaAnnotationAndClasses(Class testClass) { MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, new Class[] { FooConfig.class, - BarConfig.class }, DelegatingSmartContextLoader.class); + assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, array(FooConfig.class, + BarConfig.class), DelegatingSmartContextLoader.class); } @Test @@ -116,7 +116,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur Class testClass = ClassesFoo.class; MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, new Class[] { FooConfig.class }, + assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, array(FooConfig.class), DelegatingSmartContextLoader.class); } @@ -136,10 +136,10 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur assertNotEquals(standardMergedConfig, webMergedConfig); assertNotEquals(webMergedConfig, standardMergedConfig); - assertMergedConfig(webMergedConfig, webTestClass, EMPTY_STRING_ARRAY, new Class[] { FooConfig.class }, + assertMergedConfig(webMergedConfig, webTestClass, EMPTY_STRING_ARRAY, array(FooConfig.class), WebDelegatingSmartContextLoader.class); assertMergedConfig(standardMergedConfig, standardTestClass, EMPTY_STRING_ARRAY, - new Class[] { FooConfig.class }, DelegatingSmartContextLoader.class); + array(FooConfig.class), DelegatingSmartContextLoader.class); } @Test @@ -148,7 +148,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur Class expectedContextLoaderClass = GenericPropertiesContextLoader.class; MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, new String[] { "classpath:/foo.properties" }, EMPTY_CLASS_ARRAY, + assertMergedConfig(mergedConfig, testClass, array("classpath:/foo.properties"), EMPTY_CLASS_ARRAY, expectedContextLoaderClass); } @@ -158,14 +158,14 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur Class expectedContextLoaderClass = GenericPropertiesContextLoader.class; MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); - assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, new Class[] { FooConfig.class }, + assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, array(FooConfig.class), expectedContextLoaderClass); } @Test public void buildMergedConfigWithLocalAndInheritedAnnotationsAndLocations() { Class testClass = LocationsBar.class; - String[] expectedLocations = new String[] { "/foo.xml", "/bar.xml" }; + String[] expectedLocations = array("/foo.xml", "/bar.xml"); MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); assertMergedConfig(mergedConfig, testClass, expectedLocations, EMPTY_CLASS_ARRAY, @@ -175,7 +175,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur @Test public void buildMergedConfigWithLocalAndInheritedAnnotationsAndClasses() { Class testClass = ClassesBar.class; - Class[] expectedClasses = new Class[] { FooConfig.class, BarConfig.class }; + Class[] expectedClasses = array(FooConfig.class, BarConfig.class); MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, expectedClasses, @@ -185,7 +185,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur @Test public void buildMergedConfigWithAnnotationsAndOverriddenLocations() { Class testClass = OverriddenLocationsBar.class; - String[] expectedLocations = new String[] { "/bar.xml" }; + String[] expectedLocations = array("/bar.xml"); MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); assertMergedConfig(mergedConfig, testClass, expectedLocations, EMPTY_CLASS_ARRAY, @@ -195,7 +195,7 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur @Test public void buildMergedConfigWithAnnotationsAndOverriddenClasses() { Class testClass = OverriddenClassesBar.class; - Class[] expectedClasses = new Class[] { BarConfig.class }; + Class[] expectedClasses = array(BarConfig.class); MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, expectedClasses,