11/*
2- * Copyright 2012-2016 the original author or authors.
2+ * Copyright 2012-2017 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -74,15 +74,19 @@ public void skipsUrls() throws Exception {
7474
7575 @ Test
7676 public void urlsFromJarClassPathAreConsidered () throws Exception {
77- URL projectCore = makeUrl ("project-core" );
78- URL projectWeb = makeUrl ("project-web" );
7977 File relative = this .temporaryFolder .newFolder ();
78+ File jarWithClassPath = makeJarFileWithUrlsInManifestClassPath (
79+ "project-core/target/classes/" , "project-web/target/classes/" ,
80+ "does-not-exist/target/classes" , relative .getName () + "/" );
81+ new File (jarWithClassPath .getParentFile (), "project-core/target/classes" )
82+ .mkdirs ();
83+ new File (jarWithClassPath .getParentFile (), "project-web/target/classes" ).mkdirs ();
8084 ChangeableUrls urls = ChangeableUrls
8185 .fromUrlClassLoader (new URLClassLoader (new URL [] {
82- makeJarFileWithUrlsInManifestClassPath ( projectCore , projectWeb ,
83- relative . getName () + "/" ),
84- makeJarFileWithNoManifest () }));
85- assertThat ( urls . toList ()). containsExactly ( projectCore , projectWeb ,
86+ jarWithClassPath . toURI (). toURL (), makeJarFileWithNoManifest () }));
87+ assertThat ( urls . toList ()). containsExactly (
88+ new URL ( jarWithClassPath . toURI (). toURL (), "project-core/target/classes/" ),
89+ new URL ( jarWithClassPath . toURI (). toURL (), "project-web/target/classes/" ) ,
8690 relative .toURI ().toURL ());
8791 }
8892
@@ -95,15 +99,15 @@ private URL makeUrl(String name) throws IOException {
9599 return file .toURI ().toURL ();
96100 }
97101
98- private URL makeJarFileWithUrlsInManifestClassPath (Object ... urls ) throws Exception {
102+ private File makeJarFileWithUrlsInManifestClassPath (Object ... urls ) throws Exception {
99103 File classpathJar = this .temporaryFolder .newFile ("classpath.jar" );
100104 Manifest manifest = new Manifest ();
101105 manifest .getMainAttributes ().putValue (Attributes .Name .MANIFEST_VERSION .toString (),
102106 "1.0" );
103107 manifest .getMainAttributes ().putValue (Attributes .Name .CLASS_PATH .toString (),
104108 StringUtils .arrayToDelimitedString (urls , " " ));
105109 new JarOutputStream (new FileOutputStream (classpathJar ), manifest ).close ();
106- return classpathJar . toURI (). toURL () ;
110+ return classpathJar ;
107111 }
108112
109113 private URL makeJarFileWithNoManifest () throws Exception {
0 commit comments