Renamed Solr to Central search

Former-commit-id: b8bdca6be89497f9baf29c8762803b4652e4974b
This commit is contained in:
Will Stranathan
2014-11-08 10:53:17 -05:00
parent 64e32061ab
commit 17d7d47b9a
6 changed files with 56 additions and 41 deletions

View File

@@ -1,6 +1,5 @@
package org.owasp.dependencycheck.data.solr;
package org.owasp.dependencycheck.data.central;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.owasp.dependencycheck.BaseTest;
@@ -9,23 +8,23 @@ import org.owasp.dependencycheck.utils.Settings;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.List;
import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;
/**
* Created by colezlaw on 10/13/14.
*/
public class SolrSearchTest extends BaseTest {
private static final Logger LOGGER = Logger.getLogger(SolrSearchTest.class.getName());
private SolrSearch searcher;
public class CentralSearchTest extends BaseTest {
private static final Logger LOGGER = Logger.getLogger(CentralSearchTest.class.getName());
private CentralSearch searcher;
@Before
public void setUp() throws Exception {
String solrUrl = Settings.getString(Settings.KEYS.ANALYZER_SOLR_URL);
LOGGER.fine(solrUrl);
searcher = new SolrSearch(new URL(solrUrl));
searcher = new CentralSearch(new URL(solrUrl));
}
@Test(expected = IllegalArgumentException.class)
@@ -41,10 +40,10 @@ public class SolrSearchTest extends BaseTest {
// test it anyway
@Test
public void testValidSha1() throws Exception {
MavenArtifact ma = searcher.searchSha1("9977a8d04e75609cf01badc4eb6a9c7198c4c5ea");
assertEquals("Incorrect group", "org.apache.maven.plugins", ma.getGroupId());
assertEquals("Incorrect artifact", "maven-compiler-plugin", ma.getArtifactId());
assertEquals("Incorrect version", "3.1", ma.getVersion());
List<MavenArtifact> ma = searcher.searchSha1("9977a8d04e75609cf01badc4eb6a9c7198c4c5ea");
assertEquals("Incorrect group", "org.apache.maven.plugins", ma.get(0).getGroupId());
assertEquals("Incorrect artifact", "maven-compiler-plugin", ma.get(0).getArtifactId());
assertEquals("Incorrect version", "3.1", ma.get(0).getVersion());
}
// This test does generate network traffic and communicates with a host
@@ -54,4 +53,11 @@ public class SolrSearchTest extends BaseTest {
public void testMissingSha1() throws Exception {
searcher.searchSha1("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}
// This test should give us multiple results back from Solr
@Test
public void testMultipleReturns() throws Exception {
List<MavenArtifact> ma = searcher.searchSha1("94A9CE681A42D0352B3AD22659F67835E560D107");
assertTrue(ma.size() > 1);
}
}