All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.oodt.commons.ConfiguredTestCase Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.oodt.commons;

import java.io.BufferedInputStream;
import junit.framework.TestCase;
import org.xml.sax.InputSource;
import java.io.InputStream;
import java.io.IOException;
import java.io.StringReader;

/**
 * Base test case for tests that need the Configuration object.
 *
 * @author Kelly
 */ 
public abstract class ConfiguredTestCase extends TestCase {
	/**
	 * Creates a new {@link ConfiguredTestCase} instance.
	 *
	 * @param caseName Case name.
	 */
	protected ConfiguredTestCase(String caseName) {
		super(caseName);
	}
	
	/**
	 * Set up a test Configuration object.
	 *
	 * @throws Exception if an error occurs.
	 */
	protected void setUp() throws Exception {
		super.setUp();
		if (Configuration.configuration == null) {
			try {
				StringReader reader = new StringReader(TSTDOC);
				InputSource is = new InputSource(reader);
				is.setEncoding("UTF-8");
				is.setPublicId("-//JPL//XML EDM Test Configuration 0.0.0//EN");
				is.setSystemId("internal:test-edarc.xml");
				Configuration.configuration = new Configuration(is);
				reader.close();
			} catch (IOException ex) {
				ex.printStackTrace();
				throw new IllegalStateException("Unexpected IOException: " + ex.getMessage());
			}
		}
	}

	/** Test configuration, as a document. */
	private static final String TSTDOC = "\n\n"
		+ "www.jpl.nasa.gov81/non/existent/htdocs"
		+ "1oodt.jpl.nasa.gov82"
		+ "StandardNS/NameServer%2DPOA/_test"
		+ "ldap.jpl.nasa.gov83cn=GeorgeTestostoles,dc=test,dc=zone"
		+ "h1ghly;s3cr3tcrimson"
		+ "/non/existent/htdocs/xml/non/existent/htdocs/dtd"
		+ "84global1override2"
		+ "TestServerurn:eda:rmi:TestObject"
		+ "oodt.jpl.nasa.govlocal3override4"
		+ "TestClientlocal5"
		+ "override6";
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy