--- /dev/null
+package edu.internet2.middleware.shibboleth.serviceprovider;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+
+import junit.framework.TestCase;
+
+/**
+ * A base class that sets up Log4J. Real tests extend it.
+ */
+public class SPTestCase extends TestCase {
+
+ public SPTestCase() {
+ Logger root = Logger.getRootLogger();
+ Layout initLayout = new PatternLayout("%d{HH:mm} %-5p %m%n");
+ ConsoleAppender consoleAppender= new ConsoleAppender(initLayout,ConsoleAppender.SYSTEM_OUT);
+ root.addAppender(consoleAppender);
+ root.setLevel(Level.ERROR);
+ }
+
+}
--- /dev/null
+package edu.internet2.middleware.shibboleth.serviceprovider;
+
+import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
+
+public class TestContextInitializer extends SPTestCase {
+ private static ServiceProviderContext context = ServiceProviderContext.getInstance();
+
+ /**
+ * Load an SP configuration file.
+ * @param configFileName URL format string pointing to configuration file
+ * @throws ShibbolethConfigurationException
+ */
+ public void initServiceProvider(String configFileName) throws ShibbolethConfigurationException{
+ ServiceProviderConfig config = new ServiceProviderConfig();
+ context.setServiceProviderConfig(config);
+ config.loadConfigObjects(configFileName);
+ }
+
+ /**
+ * Load the typical sample configuration file from the usual place.
+ */
+ public void testStandardConfiguration() throws ShibbolethConfigurationException {
+ String configFileName = "file:///usr/local/shibboleth-sp/etc/sp.xml";
+ initServiceProvider(configFileName);
+ }
+
+ /**
+ * Try to load a URL that doesn't point to a file.
+ */
+ public void testBadConfigurationName() {
+ String configFileName = "file:///usr/local/shibboleth-sp/etc/spp.xml";
+ try {
+ initServiceProvider(configFileName);
+ fail();
+ } catch (ShibbolethConfigurationException e) {
+ // Expected result
+ }
+ }
+}