| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 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 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (37) | Complexity: 4 | Complexity Density: 0.12 |  | 
  
  
    | 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 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (3) | Complexity: 1 | Complexity Density: 0.33 | 1
    PASS |  | 
  
  
    | 32 | 1 |  @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 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (6) | Complexity: 1 | Complexity Density: 0.17 | 1
    PASS |  | 
  
  
    | 39 | 1 |  @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 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (12) | Complexity: 1 | Complexity Density: 0.08 | 1
    PASS |  | 
  
  
    | 49 | 1 |  @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 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (12) | Complexity: 1 | Complexity Density: 0.08 | 1
    PASS |  | 
  
  
    | 65 | 1 |  @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 |  | } |