/* * Copyright 2005-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wamblee.xmlrouter.impl; import static junit.framework.Assert.*; import static org.mockito.Mockito.*; import org.junit.Before; import org.junit.Test; import org.wamblee.xmlrouter.common.Id; import org.wamblee.xmlrouter.config.DocumentType; import org.wamblee.xmlrouter.config.Filter; import org.wamblee.xmlrouter.config.RouterConfig; import org.wamblee.xmlrouter.config.Transformation; public class SingleRouterConfigTest { private ExtendedRouterConfig config; @Before public void setUp() { config = new SingleRouterConfig(new Id("routerconfig")); } @Test public void testDocumentType() { DocumentType type1 = mock(DocumentType.class); when(type1.getId()).thenReturn(new Id("type1")); DocumentType type2 = mock(DocumentType.class); when(type2.getId()).thenReturn(new Id("type2")); config.documentTypeConfig().add(type1); config.documentTypeConfig().add(type2); assertEquals(2, config.documentTypeConfig().values().size()); assertTrue(config.documentTypeConfig().values().get(0) instanceof RobustDocumentType); } @Test public void testTransformation() { Transformation transformation1 = mock(Transformation.class); when(transformation1.getId()).thenReturn(new Id("t1")); Transformation transformation2 = mock(Transformation.class); when(transformation2.getId()).thenReturn(new Id("t2")); config.transformationConfig().add(transformation1); config.transformationConfig().add(transformation2); assertEquals(2, config.transformationConfig().values().size()); assertTrue(config.transformationConfig().values().get(0) instanceof RobustTransformation); } @Test public void testFilter() { Filter filter1 = mock(Filter.class); when(filter1.getId()).thenReturn(new Id("f1")); Filter filter2 = mock(Filter.class); when(filter2.getId()).thenReturn(new Id("f2")); config.filterConfig().add(filter1); config.filterConfig().add(filter2); assertEquals(2, config.filterConfig().values().size()); assertTrue(config.filterConfig().values().get(0) instanceof RobustFilter); } }