Fix some compile warnings

pull/276/head
Phillip Webb 11 years ago
parent 5a47360cb5
commit c1f8fd2bac

@ -121,6 +121,8 @@ public class PropertiesLauncher extends Launcher {
private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+"); private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+");
private static final URL[] EMPTY_URLS = {};
private final File home; private final File home;
private List<String> paths = new ArrayList<String>(DEFAULT_PATHS); private List<String> paths = new ArrayList<String>(DEFAULT_PATHS);
@ -493,9 +495,7 @@ public class PropertiesLauncher extends Launcher {
private void addParentClassLoaderEntries(List<Archive> lib) throws IOException, private void addParentClassLoaderEntries(List<Archive> lib) throws IOException,
URISyntaxException { URISyntaxException {
ClassLoader parentClassLoader = getClass().getClassLoader(); ClassLoader parentClassLoader = getClass().getClassLoader();
if (parentClassLoader instanceof URLClassLoader) { for (URL url : getURLs(parentClassLoader)) {
URLClassLoader urlClassLoader = (URLClassLoader) parentClassLoader;
for (URL url : urlClassLoader.getURLs()) {
if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) { if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) {
lib.add(0, new JarFileArchive(new File(url.toURI()))); lib.add(0, new JarFileArchive(new File(url.toURI())));
} }
@ -513,6 +513,12 @@ public class PropertiesLauncher extends Launcher {
} }
} }
} }
private URL[] getURLs(ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) {
return ((URLClassLoader) classLoader).getURLs();
}
return EMPTY_URLS;
} }
private String cleanupPath(String path) { private String cleanupPath(String path) {

@ -126,6 +126,7 @@ public class ExplodedArchiveTests {
} }
@Test @Test
@SuppressWarnings("resource")
public void getFilteredArchive() throws Exception { public void getFilteredArchive() throws Exception {
Archive filteredArchive = this.archive Archive filteredArchive = this.archive
.getFilteredArchive(new Archive.EntryRenameFilter() { .getFilteredArchive(new Archive.EntryRenameFilter() {

@ -281,6 +281,7 @@ public class RandomAccessJarFileTests {
} }
@Test @Test
@SuppressWarnings("resource")
public void verifySignedJar() throws Exception { public void verifySignedJar() throws Exception {
String classpath = System.getProperty("java.class.path"); String classpath = System.getProperty("java.class.path");
String[] entries = classpath.split(System.getProperty("path.separator")); String[] entries = classpath.split(System.getProperty("path.separator"));

@ -46,7 +46,6 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
* class and only creates a web application context if it is present. Non-web features, * class and only creates a web application context if it is present. Non-web features,
* like a repository layer, can be tested cleanly by simply <em>not</em> marking the test * like a repository layer, can be tested cleanly by simply <em>not</em> marking the test
* class <code>@WebAppConfiguration</code>. * class <code>@WebAppConfiguration</code>.
*
* <p> * <p>
* If <code>@ActiveProfiles</code> are provided in the test class they will be used to * If <code>@ActiveProfiles</code> are provided in the test class they will be used to
* create the application context. * create the application context.
@ -92,12 +91,9 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
} }
/** /**
* Detect the default configuration classes for the supplied test class. * Detect the default configuration classes for the supplied test class. By default
* * simply delegates to
* <p> * {@link AnnotationConfigContextLoaderUtils#detectDefaultConfigurationClasses} .
* The default implementation simply delegates to
* {@link AnnotationConfigContextLoaderUtils#detectDefaultConfigurationClasses(Class)}.
*
* @param declaringClass the test class that declared {@code @ContextConfiguration} * @param declaringClass the test class that declared {@code @ContextConfiguration}
* @return an array of default configuration classes, potentially empty but never * @return an array of default configuration classes, potentially empty but never
* {@code null} * {@code null}

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,6 +25,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
/** /**
* Tests for
* {@link SpringApplicationContextLoader#detectDefaultConfigurationClasses(Class)}
*
* @author Dave Syer * @author Dave Syer
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)

Loading…
Cancel
Save