1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.config;
21
22 import org.apache.myfaces.test.base.AbstractJsfTestCase;
23
24 import java.net.URL;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 public class LogMetaInfUtilsTestCase extends AbstractJsfTestCase
30 {
31
32 public LogMetaInfUtilsTestCase(String name)
33 {
34 super(name);
35 }
36
37 public void testVersionNumber() throws Exception
38 {
39
40
41
42
43
44
45
46 Map<String, List<LogMetaInfUtils.JarInfo>> libs = new HashMap<String, List<LogMetaInfUtils.JarInfo>>(30);
47 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/C:/.../WEB-INF/lib/myfaces-api-1.2.11-SNAPSHOT.jar!/META-INF/MANIFEST.MF"));
48 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/C:/.../WEB-INF/lib/myfaces-api-2.jar!/META-INF/MANIFEST.MF"));
49 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/C:/.../WEB-INF/lib/tomahawk12-1.1.10-SNAPSHOT.jar!/META-INF/MANIFEST.MF"));
50 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/G:/.../WEB-INF/lib/tomahawk-facelets-taglib-1.0.jar!/META-INF/MANIFEST.MF"));
51 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/C:/.../WEB-INF/lib/tomahawk-sandbox12-1.1.10.jar!/META-INF/MANIFEST.MF"));
52 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/home/.../tobago-core/1.5.0-alpha-3-SNAPSHOT/tobago-core-1.5.0-alpha-3-SNAPSHOT.jar!/META-INF/MANIFEST.MF"));
53 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/home/.../tobago-core/1.0.35/tobago-core-1.0.35.jar!/META-INF/MANIFEST.MF"));
54 LogMetaInfUtils.addJarInfo(libs, new URL("jar:file:/home/.../other/1.0/other-1.0.jar!/META-INF/MANIFEST.MF"));
55 LogMetaInfUtils.addJarInfo(libs, new URL("file:/opt/project/tobago/tobago-example/tobago-example-demo/target/tobago-example-demo/WEB-INF/lib/slf4j-log4j12-1.6.1.jar"));
56
57 final List<LogMetaInfUtils.JarInfo> mf = libs.get("myfaces-api");
58 assertEquals(2, mf.size());
59 assertEquals("1.2.11-SNAPSHOT", mf.get(0).getVersion());
60 assertEquals("2", mf.get(1).getVersion());
61
62 final List<LogMetaInfUtils.JarInfo> tk12 = libs.get("tomahawk12");
63 assertEquals(1, tk12.size());
64 assertEquals("1.1.10-SNAPSHOT", tk12.get(0).getVersion());
65
66 final List<LogMetaInfUtils.JarInfo> tksb = libs.get("tomahawk-sandbox12");
67 assertEquals(1, tksb.size());
68 assertEquals("1.1.10", tksb.get(0).getVersion());
69
70 final List<LogMetaInfUtils.JarInfo> tobago = libs.get("tobago-core");
71 assertEquals(2, tobago.size());
72 assertEquals("1.5.0-alpha-3-SNAPSHOT", tobago.get(0).getVersion());
73 assertEquals("1.0.35", tobago.get(1).getVersion());
74
75 final List<LogMetaInfUtils.JarInfo> other = libs.get("other");
76 assertNull(other);
77
78 final List<LogMetaInfUtils.JarInfo> slf = libs.get("slf4j-log4j12");
79 assertNull(slf);
80 }
81 }