/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* 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 de.odysseus.calyxo.panels.conf.impl;
import java.net.URL;
import java.util.Locale;
import de.odysseus.calyxo.base.ModuleContext;
import de.odysseus.calyxo.base.test.TestModuleContext;
import de.odysseus.calyxo.panels.conf.PanelConfig;
import de.odysseus.calyxo.panels.conf.PanelsRootConfig;
import junit.framework.TestCase;
/**
*
* @author beck
*/
public class PanelsRootConfigParserTest extends TestCase {
/**
* Constructor for PanelConfigImplTest.
* @param name
*/
public PanelsRootConfigParserTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PanelsRootConfigParserTest.class);
}
public void test1() throws Exception {
String xml = "/" + getClass().getName().replace('.', '/') + "1.xml";
URL url = getClass().getResource(xml);
ModuleContext context = new TestModuleContext("test");
PanelsRootConfigParser parser = new PanelsRootConfigParser(context);
PanelsRootConfig root = parser.parse(new URL[]{url});
// System.out.println(root);
PanelConfig foo = root.findPanelConfig("foo", null);
assertNotNull(foo);
}
public void test2() throws Exception {
String xml1 = "/" + getClass().getName().replace('.', '/') + "1.xml";
URL url1 = getClass().getResource(xml1);
String xml2 = "/" + getClass().getName().replace('.', '/') + "2.xml";
URL url2 = getClass().getResource(xml2);
ModuleContext context = new TestModuleContext("test");
PanelsRootConfigParser parser = new PanelsRootConfigParser(context);
PanelsRootConfig root = parser.parse(new URL[]{url1,url2});
// System.out.println(root);
PanelConfig foo = root.findPanelConfig("foo", null);
assertNotNull(foo);
PanelConfig bar = root.findPanelConfig("bar", null);
assertNotNull(bar);
}
public void test3() throws Exception {
String xml1 = "/" + getClass().getName().replace('.', '/') + "1.xml";
URL url1 = getClass().getResource(xml1);
String xml2 = "/" + getClass().getName().replace('.', '/') + "2.xml";
URL url2 = getClass().getResource(xml2);
String xml3 = "/" + getClass().getName().replace('.', '/') + "3.xml";
URL url3 = getClass().getResource(xml3);
ModuleContext context = new TestModuleContext("test");
PanelsRootConfigParser parser = new PanelsRootConfigParser(context);
PanelsRootConfig root = parser.parse(new URL[]{url1,url2,url3});
// System.out.println(root);
PanelConfig foo = root.findPanelConfig("foo", null);
assertNotNull(foo);
PanelConfig bar = root.findPanelConfig("bar", null);
assertNotNull(bar);
PanelConfig foo_de = root.findPanelConfig("foo", Locale.GERMAN);
assertNotNull(foo_de);
assertNotSame(foo, foo_de);
}
}