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) 2013 Jeremy Long. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.dependency;
19  
20  import org.junit.After;
21  import org.junit.AfterClass;
22  import static org.junit.Assert.assertEquals;
23  import org.junit.Before;
24  import org.junit.BeforeClass;
25  import org.junit.Test;
26  
27  /**
28   *
29   * @author Jeremy Long
30   */
31  public class VulnerableSoftwareTest {
32  
33      public VulnerableSoftwareTest() {
34      }
35  
36      @BeforeClass
37      public static void setUpClass() throws Exception {
38      }
39  
40      @AfterClass
41      public static void tearDownClass() throws Exception {
42      }
43  
44      @Before
45      public void setUp() {
46      }
47  
48      @After
49      public void tearDown() {
50      }
51  
52      /**
53       * Test of equals method, of class VulnerableSoftware.
54       */
55      @Test
56      public void testEquals() {
57          VulnerableSoftware obj = new VulnerableSoftware();
58          obj.setCpe("cpe:/a:mortbay:jetty:6.1.0");
59          VulnerableSoftware instance = new VulnerableSoftware();
60          instance.setCpe("cpe:/a:mortbay:jetty:6.1");
61          boolean expResult = false;
62          boolean result = instance.equals(obj);
63          assertEquals(expResult, result);
64      }
65  
66      /**
67       * Test of hashCode method, of class VulnerableSoftware.
68       */
69      @Test
70      public void testHashCode() {
71          VulnerableSoftware instance = new VulnerableSoftware();
72          instance.setCpe("cpe:/a:mortbay:jetty:6.1");
73          int expResult = 1849413912;
74          int result = instance.hashCode();
75          assertEquals(expResult, result);
76      }
77  
78      /**
79       * Test of compareTo method, of class VulnerableSoftware.
80       */
81      @Test
82      public void testCompareTo() {
83          VulnerableSoftware vs = new VulnerableSoftware();
84          vs.setCpe("cpe:/a:mortbay:jetty:6.1.0");
85          VulnerableSoftware instance = new VulnerableSoftware();
86          instance.setCpe("cpe:/a:mortbay:jetty:6.1");
87          int expResult = -2;
88          int result = instance.compareTo(vs);
89          assertEquals(expResult, result);
90  
91          vs = new VulnerableSoftware();
92          vs.setCpe("cpe:/a:yahoo:toolbar:3.1.0.20130813024103");
93          instance = new VulnerableSoftware();
94          instance.setCpe("cpe:/a:yahoo:toolbar:3.1.0.20130813024104");
95          expResult = 1;
96          result = instance.compareTo(vs);
97          assertEquals(expResult, result);
98      }
99  }