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