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"));
36 assertEquals("routerconfig", config.getId().getId());
40 public void testDocumentType() {
41 DocumentType type1 = mock(DocumentType.class);
42 when(type1.getId()).thenReturn(new Id<DocumentType>("type1"));
43 DocumentType type2 = mock(DocumentType.class);
44 when(type2.getId()).thenReturn(new Id<DocumentType>("type2"));
46 config.documentTypeConfig().add(type1);
47 config.documentTypeConfig().add(type2);
49 assertEquals(2, config.documentTypeConfig().values().size());
50 assertTrue(config.documentTypeConfig().values().get(0) instanceof RobustDocumentType);
54 public void testTransformation() {
55 Transformation transformation1 = mock(Transformation.class);
56 when(transformation1.getId()).thenReturn(new Id<Transformation>("t1"));
57 Transformation transformation2 = mock(Transformation.class);
58 when(transformation2.getId()).thenReturn(new Id<Transformation>("t2"));
60 config.transformationConfig().add(transformation1);
62 config.transformationConfig().add(transformation2);
64 assertEquals(2, config.transformationConfig().values().size());
65 assertTrue(config.transformationConfig().values().get(0) instanceof RobustTransformation);
69 public void testFilter() {
70 Filter filter1 = mock(Filter.class);
71 when(filter1.getId()).thenReturn(new Id<Filter>("f1"));
72 Filter filter2 = mock(Filter.class);
73 when(filter2.getId()).thenReturn(new Id<Filter>("f2"));
75 config.filterConfig().add(filter1);
77 config.filterConfig().add(filter2);
79 assertEquals(2, config.filterConfig().values().size());
80 assertTrue(config.filterConfig().values().get(0) instanceof RobustFilter);