git://wamblee.org
/
xmlrouter
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
XMLRouterConfigService test added.
[xmlrouter]
/
impl
/
src
/
test
/
java
/
org
/
wamblee
/
xmlrouter
/
impl
/
XMLRouterTest.java
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java
index 2746253de58653f31b04a21d63ef990f89680b44..ae40327050f34eae08805923a65397fc5096d0a1 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java
@@
-20,6
+20,7
@@
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Arrays;
import java.util.Collection;
+import java.util.UUID;
import java.util.logging.Level;
import javax.xml.transform.dom.DOMSource;
import java.util.logging.Level;
import javax.xml.transform.dom.DOMSource;
@@
-102,7
+103,7
@@
public class XMLRouterTest {
@Test
public void testMisBehavingDocumentType() {
@Test
public void testMisBehavingDocumentType() {
- DocumentType type = mock
(DocumentType.class
);
+ DocumentType type = mock
Document("docid"
);
doThrow(new RuntimeException("x")).when(type).isInstance(
any(DOMSource.class));
routerConfig.documentTypeConfig().add(type);
doThrow(new RuntimeException("x")).when(type).isInstance(
any(DOMSource.class));
routerConfig.documentTypeConfig().add(type);
@@
-111,10
+112,16
@@
public class XMLRouterTest {
// no exception should occur.
}
// no exception should occur.
}
+ private DocumentType mockDocument(String docid) {
+ DocumentType type = mock(DocumentType.class);
+ when(type.getId()).thenReturn(new Id<DocumentType>(docid));
+ return type;
+ }
+
@Test
public void testMisBehavingFilter() {
registerDocumentType("any");
@Test
public void testMisBehavingFilter() {
registerDocumentType("any");
- Filter filter = mock
(Filter.class
);
+ Filter filter = mock
Filter("filterid"
);
doThrow(new RuntimeException("x")).when(filter).isAllowed(anyString(),
any(DOMSource.class));
routerConfig.filterConfig().add(filter);
doThrow(new RuntimeException("x")).when(filter).isAllowed(anyString(),
any(DOMSource.class));
routerConfig.filterConfig().add(filter);
@@
-123,6
+130,12
@@
public class XMLRouterTest {
// no exception should occur.
}
// no exception should occur.
}
+ private Filter mockFilter(String filterId) {
+ Filter filter = mock(Filter.class);
+ when(filter.getId()).thenReturn(new Id<Filter>(filterId));
+ return filter;
+ }
+
@Test
public void testOneDestinationNoTransformationSuccess() {
destinationSpy = registerDestination(true, "any");
@Test
public void testOneDestinationNoTransformationSuccess() {
destinationSpy = registerDestination(true, "any");
@@
-147,7
+160,7
@@
public class XMLRouterTest {
}
private void registerDocumentType(String aType) {
}
private void registerDocumentType(String aType) {
- DocumentType type = mock
(DocumentType.class
);
+ DocumentType type = mock
Document(UUID.randomUUID().toString()
);
when(type.isInstance(any(DOMSource.class))).thenReturn(true);
when(type.getName()).thenReturn(aType);
routerConfig.documentTypeConfig().add(type);
when(type.isInstance(any(DOMSource.class))).thenReturn(true);
when(type.getName()).thenReturn(aType);
routerConfig.documentTypeConfig().add(type);
@@
-157,6
+170,7
@@
public class XMLRouterTest {
DocumentType type = mock(DocumentType.class);
when(type.isInstance(same(aSource))).thenReturn(true);
when(type.getName()).thenReturn(aType);
DocumentType type = mock(DocumentType.class);
when(type.isInstance(same(aSource))).thenReturn(true);
when(type.getName()).thenReturn(aType);
+ when(type.getId()).thenReturn(new Id<DocumentType>(aType));
routerConfig.documentTypeConfig().add(type);
}
routerConfig.documentTypeConfig().add(type);
}