2 * Copyright 2005-2011 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.xmlrouter.impl;
18 import static junit.framework.Assert.*;
19 import static org.mockito.Mockito.*;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.wamblee.xmlrouter.common.Id;
24 import org.wamblee.xmlrouter.config.DocumentType;
25 import org.wamblee.xmlrouter.config.Filter;
26 import org.wamblee.xmlrouter.config.RouterConfig;
27 import org.wamblee.xmlrouter.config.Transformation;
29 public class SingleRouterConfigTest {
31 private ExtendedRouterConfig config;
35 config = new SingleRouterConfig(new Id<RouterConfig>("routerconfig"));
39 public void testDocumentType() {
40 DocumentType type1 = mock(DocumentType.class);
41 when(type1.getId()).thenReturn(new Id<DocumentType>("type1"));
42 DocumentType type2 = mock(DocumentType.class);
43 when(type1.getId()).thenReturn(new Id<DocumentType>("type2"));
45 config.documentTypeConfig().add(type1);
46 config.documentTypeConfig().add(type2);
48 assertEquals(2, config.documentTypeConfig().values().size());
49 assertTrue(config.documentTypeConfig().values().get(0) instanceof RobustDocumentType);
53 public void testTransformation() {
54 Transformation transformation1 = mock(Transformation.class);
55 when(transformation1.getId()).thenReturn(new Id<Transformation>("t1"));
56 Transformation transformation2 = mock(Transformation.class);
57 when(transformation1.getId()).thenReturn(new Id<Transformation>("t2"));
59 config.transformationConfig().add(transformation1);
61 config.transformationConfig().add(transformation2);
63 assertEquals(2, config.transformationConfig().values().size());
64 assertTrue(config.transformationConfig().values().get(0) instanceof RobustTransformation);
68 public void testFilter() {
69 Filter filter1 = mock(Filter.class);
70 when(filter1.getId()).thenReturn(new Id<Filter>("f1"));
71 Filter filter2 = mock(Filter.class);
72 when(filter1.getId()).thenReturn(new Id<Filter>("f2"));
74 config.filterConfig().add(filter1);
76 config.filterConfig().add(filter2);
78 assertEquals(2, config.filterConfig().values().size());
79 assertTrue(config.filterConfig().values().get(0) instanceof RobustFilter);