View Javadoc
1   /*
2    * Copyright 2015 OWASP.
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.owasp.dependencycheck;
17  
18  import org.junit.After;
19  import org.junit.AfterClass;
20  import org.junit.Before;
21  import org.junit.BeforeClass;
22  import org.junit.Test;
23  import static org.junit.Assert.*;
24  
25  /**
26   *
27   * @author jeremy
28   */
29  public class AppTest {
30  
31      public AppTest() {
32      }
33  
34      @BeforeClass
35      public static void setUpClass() {
36      }
37  
38      @AfterClass
39      public static void tearDownClass() {
40      }
41  
42      @Before
43      public void setUp() {
44      }
45  
46      @After
47      public void tearDown() {
48      }
49  
50      /**
51       * Test of ensureCanonicalPath method, of class App.
52       */
53      @Test
54      public void testEnsureCanonicalPath() {
55          String file = "../*.jar";
56          App instance = new App();
57          String result = instance.ensureCanonicalPath(file);
58          assertFalse(result.contains(".."));
59          assertTrue(result.endsWith("*.jar"));
60      }
61  
62      /**
63       * Test of ensureCanonicalPath method, of class App.
64       */
65      @Test
66      public void testEnsureCanonicalPath2() {
67          String file = "../some/skip/../path/file.txt";
68          App instance = new App();
69          String expResult = "/some/path/file.txt";
70          String result = instance.ensureCanonicalPath(file);
71          assertTrue("result=" + result, result.endsWith(expResult));
72      }
73  }