2 * Copyright (c) 2018. Developed by Hedgecode.
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.
17 package org.hedgecode.chess;
21 import org.apache.commons.configuration.XMLConfiguration;
23 import org.junit.Assert;
24 import org.junit.Test;
27 * Abstract Test class with input params from XML file.
29 * @author Dmitry Samoshin aka gotty
31 public abstract class AbstractXMLConfigTest extends Assert {
33 private static final String RESOURCES_ROOT = "/";
34 private static final String XML_EXT = ".xml";
36 protected static final String CONFIG = "config";
37 protected static final String TESTS = "tests.test";
40 public void testXML() throws Exception {
41 XMLConfiguration xmlConfig = getXMLConfig();
43 CONFIG.equals(xmlConfig.getRoot().getName())
46 xmlConfig.configurationsAt(TESTS).size() > 0
50 protected abstract String getConfigName();
52 protected XMLConfiguration getXMLConfig() throws Exception {
53 String xmlConfigName = getConfigName() + XML_EXT;
54 return new XMLConfiguration(
61 protected XMLConfiguration getDefXMLConfig() throws Exception {
62 return new XMLConfiguration(
64 getClass().getSimpleName() + XML_EXT
69 private File getResourceFile(String name) throws Exception {
70 if (getClass().getResource(name) != null)
72 getClass().getResource(name).toURI()
75 getClass().getResource(RESOURCES_ROOT).getPath() + name