1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.utility;
17  
18  import static org.junit.Assert.fail;
19  
20  import java.io.File;
21  
22  import org.apache.commons.logging.Log;
23  import org.junit.After;
24  import org.junit.Before;
25  import org.junit.Test;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  
29  
30  
31  
32  
33  
34  
35  public class CompressUtils_UT {
36  
37      public static final Logger LOG = LoggerFactory.getLogger(CompressUtils_UT.class);
38  
39      private CompressUtils fileUtil = new CompressUtils();
40  
41      @Before
42      public void setUp() throws Exception {
43      }
44  
45      @After
46      public void tearDown() throws Exception {
47      }
48  
49      
50  
51  
52  
53  
54      @Test
55      public void testCreateZippedBagFile() throws Exception {
56          try {
57              File dir = new File(getClass().getResource("license").toURI());
58              File bagFile = fileUtil.createZippedBagFile(dir);
59              LOG.info("Bag File: " + bagFile);
60          } catch (Exception e) {
61              e.printStackTrace();
62              fail("Fialed in creating bag: ");
63              throw e;
64          }
65      }
66  
67      
68  
69  
70  
71  
72      @Test
73      public void testExtractZippedBagFile() throws Exception {
74  
75          try {
76              File dir = new File(getClass().getResource("license").toURI());
77              File bagFile = fileUtil.createZippedBagFile(dir);
78              LOG.info("Extracted to location :  " + fileUtil.extractZippedBagFile(bagFile.getAbsolutePath(), null).getAbsolutePath());
79          } catch (Exception e) {
80              e.printStackTrace();
81              fail("Fialed in extracting bag: ");
82              throw e;
83          }
84      }
85  
86  }