mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-15 16:23:37 +01:00
cleanup and spelling fixes
Former-commit-id: 9c44ae88606f12728bc424d566ef11194c5c399b
This commit is contained in:
@@ -44,8 +44,8 @@ public class JarAnalyzerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of insepct method, of class JarAnalyzer.
|
||||
* @throws Exception is thrown when an excpetion occurs.
|
||||
* Test of inspect method, of class JarAnalyzer.
|
||||
* @throws Exception is thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testAnalyze() throws Exception {
|
||||
|
||||
@@ -13,26 +13,23 @@ import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.queryparser.classic.ParseException;
|
||||
import org.codesecure.dependencycheck.dependency.Dependency;
|
||||
import org.codesecure.dependencycheck.analyzer.JarAnalyzer;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeremy
|
||||
*/
|
||||
public class CPEAnalyzerTest extends BaseIndexTestCase {
|
||||
public class CPEAnalyzerTest {
|
||||
|
||||
public CPEAnalyzerTest(String testName) {
|
||||
super(testName);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,19 +54,19 @@ public class CPEAnalyzerTest extends BaseIndexTestCase {
|
||||
|
||||
String queryText = instance.buildSearch(vendor, product, version, null, null);
|
||||
String expResult = " product:( struts 2 core ) AND vendor:( apache software foundation ) AND version:(2.1.2^0.7 )";
|
||||
assertTrue(expResult.equals(queryText));
|
||||
Assert.assertTrue(expResult.equals(queryText));
|
||||
|
||||
queryText = instance.buildSearch(vendor, product, version, null, productWeightings);
|
||||
expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache software foundation ) AND version:(2.1.2^0.2 )";
|
||||
assertTrue(expResult.equals(queryText));
|
||||
Assert.assertTrue(expResult.equals(queryText));
|
||||
|
||||
queryText = instance.buildSearch(vendor, product, version, vendorWeightings, null);
|
||||
expResult = " product:( struts 2 core ) AND vendor:( apache^5 software foundation ) AND version:(2.1.2^0.2 )";
|
||||
assertTrue(expResult.equals(queryText));
|
||||
Assert.assertTrue(expResult.equals(queryText));
|
||||
|
||||
queryText = instance.buildSearch(vendor, product, version, vendorWeightings, productWeightings);
|
||||
expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache^5 software foundation ) AND version:(2.1.2^0.2 )";
|
||||
assertTrue(expResult.equals(queryText));
|
||||
Assert.assertTrue(expResult.equals(queryText));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,11 +77,11 @@ public class CPEAnalyzerTest extends BaseIndexTestCase {
|
||||
public void testOpen() throws Exception {
|
||||
System.out.println("open");
|
||||
CPEAnalyzer instance = new CPEAnalyzer();
|
||||
assertFalse(instance.isOpen());
|
||||
Assert.assertFalse(instance.isOpen());
|
||||
instance.open();
|
||||
assertTrue(instance.isOpen());
|
||||
Assert.assertTrue(instance.isOpen());
|
||||
instance.close();
|
||||
assertFalse(instance.isOpen());
|
||||
Assert.assertFalse(instance.isOpen());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,11 +113,11 @@ public class CPEAnalyzerTest extends BaseIndexTestCase {
|
||||
instance.determineCPE(spring);
|
||||
instance.determineCPE(spring3);
|
||||
instance.close();
|
||||
assertTrue("Incorrect match size - struts", depends.getIdentifiers().size() == 1);
|
||||
assertTrue("Incorrect match - struts", depends.getIdentifiers().get(0).getValue().equals(expResult));
|
||||
assertTrue("Incorrect match size - spring", spring.getIdentifiers().size() == 1);
|
||||
assertTrue("Incorrect match - spring", spring.getIdentifiers().get(0).getValue().equals(expResultSpring));
|
||||
assertTrue("Incorrect match size - spring3 - " + spring3.getIdentifiers().size(), spring3.getIdentifiers().size() >= 1);
|
||||
Assert.assertTrue("Incorrect match size - struts", depends.getIdentifiers().size() == 1);
|
||||
Assert.assertTrue("Incorrect match - struts", depends.getIdentifiers().get(0).getValue().equals(expResult));
|
||||
Assert.assertTrue("Incorrect match size - spring", spring.getIdentifiers().size() == 1);
|
||||
Assert.assertTrue("Incorrect match - spring", spring.getIdentifiers().get(0).getValue().equals(expResultSpring));
|
||||
Assert.assertTrue("Incorrect match size - spring3 - " + spring3.getIdentifiers().size(), spring3.getIdentifiers().size() >= 1);
|
||||
//assertTrue("Incorrect match - spring3", spring3.getIdentifiers().get(0).getValue().equals(expResultSpring3));
|
||||
}
|
||||
|
||||
@@ -148,7 +145,7 @@ public class CPEAnalyzerTest extends BaseIndexTestCase {
|
||||
vendorWeightings.add("apache");
|
||||
|
||||
List<Entry> result = instance.searchCPE(vendor, product, version, productWeightings, vendorWeightings);
|
||||
assertEquals(expResult, result.get(0).getName());
|
||||
Assert.assertEquals(expResult, result.get(0).getName());
|
||||
|
||||
|
||||
instance.close();
|
||||
|
||||
@@ -18,11 +18,7 @@ import static org.junit.Assert.*;
|
||||
*
|
||||
* @author Jeremy Long (jeremy.long@gmail.com)
|
||||
*/
|
||||
public class IndexIntegrationTest extends BaseIndexTestCase {
|
||||
|
||||
public IndexIntegrationTest(String testCase) {
|
||||
super(testCase);
|
||||
}
|
||||
public class IndexIntegrationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
|
||||
@@ -7,22 +7,15 @@ package org.codesecure.dependencycheck.data.cpe;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long (jeremy.long@gmail.com)
|
||||
*/
|
||||
public class IndexTest extends BaseIndexTestCase {
|
||||
|
||||
public IndexTest(String testCase) {
|
||||
super(testCase);
|
||||
}
|
||||
public class IndexTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
@@ -50,7 +43,7 @@ public class IndexTest extends BaseIndexTestCase {
|
||||
try {
|
||||
instance.open();
|
||||
} catch (IOException ex) {
|
||||
fail(ex.getMessage());
|
||||
Assert.fail(ex.getMessage());
|
||||
}
|
||||
instance.close();
|
||||
}
|
||||
@@ -65,6 +58,6 @@ public class IndexTest extends BaseIndexTestCase {
|
||||
Directory result = index.getDirectory();
|
||||
|
||||
String exp = File.separatorChar + "target" + File.separatorChar + "data" + File.separatorChar + "cpe";
|
||||
assertTrue(result.toString().contains(exp));
|
||||
Assert.assertTrue(result.toString().contains(exp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CweDBTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to serlize the CWE HashMap. This is not used in
|
||||
* Method to serialize the CWE HashMap. This is not used in
|
||||
* production; this is only used once during dev to create
|
||||
* the serialized hashmap.
|
||||
*/
|
||||
|
||||
@@ -15,11 +15,7 @@ import org.junit.Test;
|
||||
*
|
||||
* @author Jeremy Long (jeremy.long@gmail.com)
|
||||
*/
|
||||
public class ReportGeneratorTest extends BaseIndexTestCase {
|
||||
|
||||
public ReportGeneratorTest(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
public class ReportGeneratorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
@@ -30,12 +26,10 @@ public class ReportGeneratorTest extends BaseIndexTestCase {
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
@Override
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
|
||||
@@ -8,26 +8,23 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeremy
|
||||
*/
|
||||
public class ChecksumTest extends TestCase {
|
||||
public class ChecksumTest {
|
||||
|
||||
public ChecksumTest(String testName) {
|
||||
super(testName);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,14 +44,14 @@ public class ChecksumTest extends TestCase {
|
||||
arraysAreEqual = result[i] == expResult[i];
|
||||
}
|
||||
} else {
|
||||
fail("Checksum results do not match expected results.");
|
||||
Assert.fail("Checksum results do not match expected results.");
|
||||
}
|
||||
assertTrue(arraysAreEqual);
|
||||
Assert.assertTrue(arraysAreEqual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getChecksum method, of class Checksum. This checks that an
|
||||
* excpetion is thrown when an invalid path is specified.
|
||||
* exception is thrown when an invalid path is specified.
|
||||
*
|
||||
* @throws Exception is thrown when an exception occurs.
|
||||
*/
|
||||
@@ -69,7 +66,7 @@ public class ChecksumTest extends TestCase {
|
||||
} catch (IOException ex) {
|
||||
exceptionThrown = true;
|
||||
}
|
||||
assertTrue(exceptionThrown);
|
||||
Assert.assertTrue(exceptionThrown);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +86,7 @@ public class ChecksumTest extends TestCase {
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
exceptionThrown = true;
|
||||
}
|
||||
assertTrue(exceptionThrown);
|
||||
Assert.assertTrue(exceptionThrown);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +99,7 @@ public class ChecksumTest extends TestCase {
|
||||
File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath());
|
||||
String expResult = "F0915C5F46B8CFA283E5AD67A09B3793";
|
||||
String result = Checksum.getMD5Checksum(file);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +112,7 @@ public class ChecksumTest extends TestCase {
|
||||
File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath());
|
||||
String expResult = "B8A9FF28B21BCB1D0B50E24A5243D8B51766851A";
|
||||
String result = Checksum.getSHA1Checksum(file);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +124,6 @@ public class ChecksumTest extends TestCase {
|
||||
byte[] raw = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
|
||||
String expResult = "000102030405060708090A0B0C0D0E0F10";
|
||||
String result = Checksum.getHex(raw);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,31 +11,28 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeremy
|
||||
*/
|
||||
public class CliParserTest extends TestCase {
|
||||
public class CliParserTest {
|
||||
|
||||
public CliParserTest(String testName) {
|
||||
super(testName);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
@@ -50,14 +47,14 @@ public class CliParserTest extends TestCase {
|
||||
CliParser instance = new CliParser();
|
||||
instance.parse(args);
|
||||
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with help arg, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_help() throws Exception {
|
||||
@@ -69,14 +66,14 @@ public class CliParserTest extends TestCase {
|
||||
CliParser instance = new CliParser();
|
||||
instance.parse(args);
|
||||
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertTrue(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertTrue(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with version arg, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_version() throws Exception {
|
||||
@@ -86,15 +83,15 @@ public class CliParserTest extends TestCase {
|
||||
|
||||
CliParser instance = new CliParser();
|
||||
instance.parse(args);
|
||||
assertTrue(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertTrue(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with jar and cpe args, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_unknown() throws Exception {
|
||||
@@ -114,16 +111,16 @@ public class CliParserTest extends TestCase {
|
||||
try {
|
||||
instance.parse(args);
|
||||
} catch (ParseException ex) {
|
||||
assertTrue(ex.getMessage().contains("Unrecognized option"));
|
||||
Assert.assertTrue(ex.getMessage().contains("Unrecognized option"));
|
||||
}
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with scan arg, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_scan() throws Exception {
|
||||
@@ -136,17 +133,17 @@ public class CliParserTest extends TestCase {
|
||||
try {
|
||||
instance.parse(args);
|
||||
} catch (ParseException ex) {
|
||||
assertTrue(ex.getMessage().contains("Missing argument"));
|
||||
Assert.assertTrue(ex.getMessage().contains("Missing argument"));
|
||||
}
|
||||
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with jar arg, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_scan_unknownFile() throws Exception {
|
||||
@@ -158,17 +155,17 @@ public class CliParserTest extends TestCase {
|
||||
try {
|
||||
instance.parse(args);
|
||||
} catch (FileNotFoundException ex) {
|
||||
assertTrue(ex.getMessage().contains("Invalid file argument"));
|
||||
Assert.assertTrue(ex.getMessage().contains("Invalid file argument"));
|
||||
}
|
||||
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertFalse(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertFalse(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of parse method with jar arg, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_scan_withFileExists() throws Exception {
|
||||
@@ -179,16 +176,16 @@ public class CliParserTest extends TestCase {
|
||||
CliParser instance = new CliParser();
|
||||
instance.parse(args);
|
||||
|
||||
assertEquals(path.getCanonicalPath(), instance.getScanFiles()[0]);
|
||||
Assert.assertEquals(path.getCanonicalPath(), instance.getScanFiles()[0]);
|
||||
|
||||
assertFalse(instance.isGetVersion());
|
||||
assertFalse(instance.isGetHelp());
|
||||
assertTrue(instance.isRunScan());
|
||||
Assert.assertFalse(instance.isGetVersion());
|
||||
Assert.assertFalse(instance.isGetHelp());
|
||||
Assert.assertTrue(instance.isRunScan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of printVersionInfo, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_printVersionInfo() throws Exception {
|
||||
@@ -204,12 +201,12 @@ public class CliParserTest extends TestCase {
|
||||
baos.flush();
|
||||
String text = (new String(baos.toByteArray())).toLowerCase();
|
||||
String[] lines = text.split(System.getProperty("line.separator"));
|
||||
assertEquals(1, lines.length);
|
||||
assertTrue(text.contains("version"));
|
||||
assertTrue(!text.contains("unknown"));
|
||||
Assert.assertEquals(1, lines.length);
|
||||
Assert.assertTrue(text.contains("version"));
|
||||
Assert.assertTrue(!text.contains("unknown"));
|
||||
} catch (IOException ex) {
|
||||
System.setOut(out);
|
||||
fail("CliParser.printVersionInfo did not write anything to system.out.");
|
||||
Assert.fail("CliParser.printVersionInfo did not write anything to system.out.");
|
||||
} finally {
|
||||
System.setOut(out);
|
||||
}
|
||||
@@ -217,7 +214,7 @@ public class CliParserTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test of printHelp, of class CliParser.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParse_printHelp() throws Exception {
|
||||
@@ -238,11 +235,11 @@ public class CliParserTest extends TestCase {
|
||||
baos.flush();
|
||||
String text = (new String(baos.toByteArray()));
|
||||
String[] lines = text.split(System.getProperty("line.separator"));
|
||||
assertTrue(lines[0].startsWith("usage: "));
|
||||
assertTrue((lines.length > 2));
|
||||
Assert.assertTrue(lines[0].startsWith("usage: "));
|
||||
Assert.assertTrue((lines.length > 2));
|
||||
} catch (IOException ex) {
|
||||
System.setOut(out);
|
||||
fail("CliParser.printVersionInfo did not write anything to system.out.");
|
||||
Assert.fail("CliParser.printVersionInfo did not write anything to system.out.");
|
||||
} finally {
|
||||
System.setOut(out);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DownloaderIntegrationTest {
|
||||
|
||||
/**
|
||||
* Test of fetchFile method, of class Downloader.
|
||||
* @throws Exception thrown when an excpetion occurs.
|
||||
* @throws Exception thrown when an exception occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testFetchFile() throws Exception {
|
||||
|
||||
@@ -8,26 +8,23 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeremy
|
||||
*/
|
||||
public class SettingsTest extends TestCase {
|
||||
public class SettingsTest {
|
||||
|
||||
public SettingsTest(String testName) {
|
||||
super(testName);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +36,7 @@ public class SettingsTest extends TestCase {
|
||||
String key = Settings.KEYS.CPE_INDEX;
|
||||
String expResult = "target/data/cpe";
|
||||
String result = Settings.getString(key);
|
||||
assertTrue(result.endsWith(expResult));
|
||||
Assert.assertTrue(result.endsWith(expResult));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +51,7 @@ public class SettingsTest extends TestCase {
|
||||
//InputStream in = this.getClass().getClassLoader().getResourceAsStream("test.properties");
|
||||
Settings.mergeProperties(f.getAbsolutePath());
|
||||
String result = Settings.getString(key);
|
||||
assertTrue("setting didn't change?", (expResult == null && result != null) || !expResult.equals(result));
|
||||
Assert.assertTrue("setting didn't change?", (expResult == null && result != null) || !expResult.equals(result));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +64,7 @@ public class SettingsTest extends TestCase {
|
||||
String value = "someValue";
|
||||
Settings.setString(key, value);
|
||||
String expResults = Settings.getString(key);
|
||||
assertEquals(expResults, value);
|
||||
Assert.assertEquals(expResults, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,9 +77,9 @@ public class SettingsTest extends TestCase {
|
||||
String defaultValue = "blue bunny";
|
||||
String expResult = "blue bunny";
|
||||
String result = Settings.getString(key);
|
||||
assertTrue(result == null);
|
||||
Assert.assertTrue(result == null);
|
||||
result = Settings.getString(key, defaultValue);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +90,7 @@ public class SettingsTest extends TestCase {
|
||||
System.out.println("getString");
|
||||
String key = Settings.KEYS.CONNECTION_TIMEOUT;
|
||||
String result = Settings.getString(key);
|
||||
assertTrue(result == null);
|
||||
Assert.assertTrue(result == null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +103,7 @@ public class SettingsTest extends TestCase {
|
||||
int expResult = 85;
|
||||
Settings.setString(key, "85");
|
||||
int result = Settings.getInt(key);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +116,7 @@ public class SettingsTest extends TestCase {
|
||||
long expResult = 300L;
|
||||
Settings.setString(key, "300");
|
||||
long result = Settings.getLong(key);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +129,6 @@ public class SettingsTest extends TestCase {
|
||||
Settings.setString(key, "false");
|
||||
boolean expResult = false;
|
||||
boolean result = Settings.getBoolean(key);
|
||||
assertEquals(expResult, result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user