View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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          // tests single digits
41          // tests more digits
42          // tests alpha
43          // tests SNAPSHOT
44          // tests digits in artifact names
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  }