View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Class CompressUtils_UT to test CompressUtils.
31   *
32   * @author Rajesh Chowdary K
33   * @created May 24, 2012
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       * Test method for {@link org.kuali.ole.utility.CompressUtils#createZippedBagFile(java.io.File)}.
51       *
52       * @throws Exception
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       * Test method for {@link org.kuali.ole.utility.CompressUtils#extractZippedBagFile(java.lang.String, java.lang.String)}.
69       *
70       * @throws Exception
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  }