cvs commit: spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/tests MockComponent.java MockSearchService.java MockComponentRepository.java
Mike Hogan <[email protected]>
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
hogie 03/10/28 11:36:06
Modified: sandbox/repository/componenthaus/src/tests/org/componenthaus/tests
MockComponentRepository.java
Added: sandbox/repository/componenthaus/src/tests/org/componenthaus/tests
MockComponent.java MockSearchService.java
Log:
Some test cases for search use case. Incomplete.
Revision Changes Path
1.2 +6 -1 spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/tests/MockComponentRepository.java
Index: MockComponentRepository.java
===================================================================
RCS file: /cvsroot/spice/spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/tests/MockComponentRepository.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockComponentRepository.java 26 Oct 2003 19:01:22 -0000 1.1
+++ MockComponentRepository.java 28 Oct 2003 19:36:06 -0000 1.2
@@ -11,6 +11,7 @@
public class MockComponentRepository implements ComponentRepository {
private Map downloadables = new HashMap();
+ private Map components = new HashMap();
public String add(Component component) {
return null;
@@ -21,7 +22,7 @@
}
public Component getComponent(String id) {
- return null;
+ return (Component) components.get(id);
}
public void registerDownloadable(String componentId, File downloadable) {
@@ -37,5 +38,9 @@
public void setupDownloadable(String id,File file) {
downloadables.put(id,file);
+ }
+
+ public void setupComponent(Component component) {
+ components.put(component.getId(),component);
}
}
1.1 spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/tests/MockComponent.java
Index: MockComponent.java
===================================================================
package org.componenthaus.tests;
import org.componenthaus.repository.api.Component;
import org.componenthaus.repository.api.ServiceImplementation;
import java.util.Collection;
import java.util.List;
public class MockComponent implements Component {
private String componentId = null;
public MockComponent(String componentId) {
this.componentId = componentId;
}
public String getId() {
return null;
}
public void setId(String id) {
}
public Collection getImplementations() {
return null;
}
public void addImplementation(ServiceImplementation impl) {
}
public String getServiceInterface() {
return null;
}
public String getName() {
return null;
}
public String getVersion() {
return null;
}
public String getFullyQualifiedName() {
return null;
}
public String getAuthorsCSV() {
return null;
}
public List getAuthors() {
return null;
}
public String getOneLineDescription() {
return null;
}
public String getFullDescription() {
return null;
}
}
1.1 spice/sandbox/repository/componenthaus/src/tests/org/componenthaus/tests/MockSearchService.java
Index: MockSearchService.java
===================================================================
package org.componenthaus.tests;
import org.componenthaus.search.SearchService;
import java.util.List;
import junit.framework.Assert;
public class MockSearchService implements SearchService {
private SearchService.Exception toBeThrown = null;
private List mockResults = null;
private String expectedQuery;
private int expectedBeginIndex;
private int expectedEndIndex;
private String actualQuery;
private int actualBeginIndex;
private int actualEndIndex;
public void setToBeThrown(SearchService.Exception toBeThrown) {
this.toBeThrown = toBeThrown;
}
public void index(String componentId, String componentDescription) throws SearchService.Exception {
}
public int search(String query, int beginIndex, int endIndex, List collector) throws SearchService.Exception {
if ( toBeThrown != null ) {
throw toBeThrown;
}
collector.addAll(mockResults);
actualBeginIndex = beginIndex;
actualEndIndex = endIndex;
actualQuery = query;
return mockResults.size();
}
public void setupResults(List list) {
this.mockResults = list;
}
public void setupExpectedQueryParams(String query, int beginIndex, int endIndex) {
expectedQuery = query;
expectedBeginIndex = beginIndex;
expectedEndIndex = endIndex;
}
public void verify() {
Assert.assertEquals("Did not get expected query",expectedQuery,actualQuery);
Assert.assertEquals("Did not get expected beginIndex",expectedBeginIndex,actualBeginIndex);
Assert.assertEquals("Did not get expected endIndex",expectedEndIndex,actualEndIndex);
}
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/