org.apache.oodt.commons.ConfiguredTestCase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oodt-commons Show documentation
Show all versions of oodt-commons Show documentation
Apache OODT Common Utilities Project
/*
* 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.gov 81 /non/existent/htdocs "
+ "1 oodt.jpl.nasa.gov 82 "
+ "StandardNS/NameServer%2DPOA/_test "
+ "ldap.jpl.nasa.gov 83 cn=GeorgeTestostoles,dc=test,dc=zone "
+ "h1ghly;s3cr3t crimson "
+ "/non/existent/htdocs/xml /non/existent/htdocs/dtd "
+ "84 global 1 override 2 "
+ "TestServer urn:eda:rmi:TestObject "
+ "oodt.jpl.nasa.gov local 3 override 4 "
+ "TestClient local 5 "
+ "override 6 ";
}