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.junit.After;
23 import org.junit.Before;
24 import org.junit.Test;
25
26 /**
27 * Class CompressUtils_UT to test CompressUtils.
28 *
29 * @author Rajesh Chowdary K
30 * @created May 24, 2012
31 */
32 public class CompressUtils_UT {
33
34 private CompressUtils fileUtil = new CompressUtils();
35
36 @Before
37 public void setUp() throws Exception {
38 }
39
40 @After
41 public void tearDown() throws Exception {
42 }
43
44 /**
45 * Test method for {@link org.kuali.ole.utility.CompressUtils#createZippedBagFile(java.io.File)}.
46 *
47 * @throws Exception
48 */
49 @Test
50 public void testCreateZippedBagFile() throws Exception {
51 try {
52 File dir = new File(getClass().getResource("license").toURI());
53 File bagFile = fileUtil.createZippedBagFile(dir);
54 System.out.println("Bag File: " + bagFile);
55 } catch (Exception e) {
56 e.printStackTrace();
57 fail("Fialed in creating bag: ");
58 throw e;
59 }
60 }
61
62 /**
63 * Test method for {@link org.kuali.ole.utility.CompressUtils#extractZippedBagFile(java.lang.String, java.lang.String)}.
64 *
65 * @throws Exception
66 */
67 @Test
68 public void testExtractZippedBagFile() throws Exception {
69
70 try {
71 File dir = new File(getClass().getResource("license").toURI());
72 File bagFile = fileUtil.createZippedBagFile(dir);
73 System.out.println("Extracted to location : " + fileUtil.extractZippedBagFile(bagFile.getAbsolutePath(), null).getAbsolutePath());
74 } catch (Exception e) {
75 e.printStackTrace();
76 fail("Fialed in extracting bag: ");
77 throw e;
78 }
79 }
80
81 }