Clover Coverage Report - Kuali Student 1.2-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Mar 3 2011 04:02:59 EST
33   81   4   8.25
0   57   0.12   4
4     1  
1    
 
  TestManifestInspector       Line # 26 33 0% 4 0 100% 1.0
 
  (4)
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.util;
17   
18    import java.util.jar.Attributes;
19    import java.util.jar.Manifest;
20   
21    import junit.framework.Assert;
22   
23    import org.apache.cxf.common.util.StringUtils;
24    import org.junit.Test;
25   
 
26    public class TestManifestInspector {
27    String name = "Kuali Student Embedded";
28    String version = "1.1.0-M8-SNAPSHOT";
29    String timestamp = "2010-08-10 21:35 EDT";
30    String buildNumber = "89";
31   
 
32  1 toggle @Test
33    public void testNullManifest() throws Exception {
34  1 ManifestInspector mi = new ManifestInspector();
35  1 BuildInformation bi = mi.getBuildInformation(null);
36  1 Assert.assertNull(bi);
37    }
38   
 
39  1 toggle @Test
40    public void testEmptyManifest() throws Exception {
41  1 ManifestInspector mi = new ManifestInspector();
42  1 Manifest manifest = new Manifest();
43  1 BuildInformation bi = mi.getBuildInformation(manifest);
44  1 Assert.assertTrue(mi.isNullOrEmpty(bi));
45  1 String s = mi.toString(bi);
46  1 Assert.assertEquals(s, ManifestInspector.NO_BUILD_INFORMATION_AVAILABLE);
47    }
48   
 
49  1 toggle @Test
50    public void testNoBuildNumberManifest() throws Exception {
51  1 ManifestInspector mi = new ManifestInspector();
52  1 Manifest manifest = new Manifest();
53  1 Attributes attributes = manifest.getMainAttributes();
54  1 attributes.putValue(ManifestInspector.BUNDLE_NAME, name);
55  1 attributes.putValue(ManifestInspector.BUNDLE_VERSION, version);
56  1 attributes.putValue(ManifestInspector.BUNDLE_TIMESTAMP, timestamp);
57  1 BuildInformation bi = mi.getBuildInformation(manifest);
58  1 Assert.assertFalse(mi.isNullOrEmpty(bi));
59  1 Assert.assertTrue(StringUtils.isEmpty(bi.getBuildNumber()));
60  1 String testString = name + " :: " + version + " :: " + timestamp;
61  1 String s = mi.toString(bi);
62  1 Assert.assertEquals(s, testString);
63    }
64   
 
65  1 toggle @Test
66    public void testFullBuildInfo() throws Exception {
67  1 ManifestInspector mi = new ManifestInspector();
68  1 Manifest manifest = new Manifest();
69  1 Attributes attributes = manifest.getMainAttributes();
70  1 attributes.putValue(ManifestInspector.BUNDLE_NAME, name);
71  1 attributes.putValue(ManifestInspector.BUNDLE_VERSION, version);
72  1 attributes.putValue(ManifestInspector.BUNDLE_BUILD_NUMBER, buildNumber);
73  1 attributes.putValue(ManifestInspector.BUNDLE_TIMESTAMP, timestamp);
74  1 BuildInformation bi = mi.getBuildInformation(manifest);
75  1 Assert.assertFalse(mi.isNullOrEmpty(bi));
76  1 String testString = name + " :: " + version + " :: #" + buildNumber + " :: " + timestamp;
77  1 String s = mi.toString(bi);
78  1 Assert.assertEquals(s, testString);
79    }
80   
81    }