1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
21
21
import java .net .URLConnection ;
22
22
import java .net .URLStreamHandler ;
23
23
24
- import junit .framework .TestCase ;
24
+ import org .junit .Test ;
25
+
26
+ import static org .junit .Assert .*;
25
27
26
28
/**
27
29
* @author Juergen Hoeller
28
30
*/
29
- public class ResourceUtilsTests extends TestCase {
31
+ public class ResourceUtilsTests {
30
32
31
- public void testIsJarURL () throws Exception {
33
+ @ Test
34
+ public void isJarURL () throws Exception {
32
35
assertTrue (ResourceUtils .isJarURL (new URL ("jar:file:myjar.jar!/mypath" )));
33
36
assertTrue (ResourceUtils .isJarURL (new URL (null , "zip:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
34
37
assertTrue (ResourceUtils .isJarURL (new URL (null , "wsjar:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
38
+ assertTrue (ResourceUtils .isJarURL (new URL (null , "jar:war:file:mywar.war*/myjar.jar!/mypath" , new DummyURLStreamHandler ())));
35
39
assertFalse (ResourceUtils .isJarURL (new URL ("file:myjar.jar" )));
36
40
assertFalse (ResourceUtils .isJarURL (new URL ("http:myserver/myjar.jar" )));
37
41
}
38
42
39
- public void testExtractJarFileURL () throws Exception {
43
+ @ Test
44
+ public void extractJarFileURL () throws Exception {
40
45
assertEquals (new URL ("file:myjar.jar" ),
41
46
ResourceUtils .extractJarFileURL (new URL ("jar:file:myjar.jar!/mypath" )));
42
47
assertEquals (new URL ("file:/myjar.jar" ),
@@ -45,14 +50,40 @@ public void testExtractJarFileURL() throws Exception {
45
50
ResourceUtils .extractJarFileURL (new URL (null , "zip:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
46
51
assertEquals (new URL ("file:myjar.jar" ),
47
52
ResourceUtils .extractJarFileURL (new URL (null , "wsjar:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
53
+
54
+ assertEquals (new URL ("file:myjar.jar" ),
55
+ ResourceUtils .extractJarFileURL (new URL ("file:myjar.jar" )));
48
56
assertEquals (new URL ("file:myjar.jar" ),
49
57
ResourceUtils .extractJarFileURL (new URL ("jar:file:myjar.jar!/" )));
50
58
assertEquals (new URL ("file:myjar.jar" ),
51
59
ResourceUtils .extractJarFileURL (new URL (null , "zip:file:myjar.jar!/" , new DummyURLStreamHandler ())));
52
60
assertEquals (new URL ("file:myjar.jar" ),
53
61
ResourceUtils .extractJarFileURL (new URL (null , "wsjar:file:myjar.jar!/" , new DummyURLStreamHandler ())));
62
+ }
63
+
64
+ @ Test
65
+ public void extractArchiveURL () throws Exception {
54
66
assertEquals (new URL ("file:myjar.jar" ),
55
- ResourceUtils .extractJarFileURL (new URL ("file:myjar.jar" )));
67
+ ResourceUtils .extractArchiveURL (new URL ("jar:file:myjar.jar!/mypath" )));
68
+ assertEquals (new URL ("file:/myjar.jar" ),
69
+ ResourceUtils .extractArchiveURL (new URL (null , "jar:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
70
+ assertEquals (new URL ("file:myjar.jar" ),
71
+ ResourceUtils .extractArchiveURL (new URL (null , "zip:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
72
+ assertEquals (new URL ("file:myjar.jar" ),
73
+ ResourceUtils .extractArchiveURL (new URL (null , "wsjar:file:myjar.jar!/mypath" , new DummyURLStreamHandler ())));
74
+ assertEquals (new URL ("file:mywar.war" ),
75
+ ResourceUtils .extractArchiveURL (new URL (null , "jar:war:file:mywar.war*/myjar.jar!/mypath" , new DummyURLStreamHandler ())));
76
+
77
+ assertEquals (new URL ("file:myjar.jar" ),
78
+ ResourceUtils .extractArchiveURL (new URL ("file:myjar.jar" )));
79
+ assertEquals (new URL ("file:myjar.jar" ),
80
+ ResourceUtils .extractArchiveURL (new URL ("jar:file:myjar.jar!/" )));
81
+ assertEquals (new URL ("file:myjar.jar" ),
82
+ ResourceUtils .extractArchiveURL (new URL (null , "zip:file:myjar.jar!/" , new DummyURLStreamHandler ())));
83
+ assertEquals (new URL ("file:myjar.jar" ),
84
+ ResourceUtils .extractArchiveURL (new URL (null , "wsjar:file:myjar.jar!/" , new DummyURLStreamHandler ())));
85
+ assertEquals (new URL ("file:mywar.war" ),
86
+ ResourceUtils .extractArchiveURL (new URL (null , "jar:war:file:mywar.war*/myjar.jar!/" , new DummyURLStreamHandler ())));
56
87
}
57
88
58
89
0 commit comments