/** * Copyright 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.bricket.web; import java.lang.reflect.Field; import java.util.Collection; import java.util.HashMap; import java.util.Map; import junit.framework.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; /** * @author Ingo Renner * @author Henning Teek */ @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/test.xml" }) public class BricketPageParameterDefinitionTest extends AbstractJUnit4SpringContextTests { private final Logger log = LoggerFactory.getLogger(BricketPageParameterDefinitionTest.class); @Autowired Map<String, BricketPageParameterDefinition> beans; @Test public void testBricketPageParameterDefinition() throws Exception { Map<Object, String> params = new HashMap<Object, String>(); log.info("testing {} page parameter definitions: {}", beans.keySet().size(), beans.values().toString()); Collection<BricketPageParameterDefinition> defs = beans.values(); for (Object def : defs) { Field[] fields = def.getClass().getFields(); for (Field field : fields) { Object value = field.get(def); String name = def.getClass().getName(); String duplicate = params.put(value, name); Assert.assertNull("Page parameter definition: " + value + " of class: " + name + " is already registered by class: " + duplicate, duplicate); } } } }