File System ARP Repository test was failing. Now catching Runtime exception when...
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Feb 2003 05:47:25 +0000 (05:47 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 19 Feb 2003 05:47:25 +0000 (05:47 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@479 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java
src/edu/internet2/middleware/shibboleth/aa/arp/provider/FileSystemArpRepository.java
src/edu/internet2/middleware/shibboleth/common/ShibResource.java

index a7e4805..f0ebf4d 100755 (executable)
@@ -50,6 +50,7 @@
 package edu.internet2.middleware.shibboleth.aa.arp;
 
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
@@ -468,7 +469,7 @@ public class ArpTests extends TestCase {
                        "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository");
                props.setProperty(
                        "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path",
-                       "data");
+                       new File("data/").toURI().toString());
                props.setProperty(
                        "edu.internet2.middleware.shibboleth.aa.arp.BaseArpRepository.ArpTTL",
                        "65535");
@@ -476,7 +477,7 @@ public class ArpTests extends TestCase {
                try {
                        repository = ArpRepositoryFactory.getInstance(props);
                } catch (ArpRepositoryException e) {
-                       fail("Failed to create file-based Arp Repository" + e);
+                       fail("Failed to create file-based Arp Repository" + e.getMessage());
                }
                assertNotNull(
                        "Failed to create file-based Arp Repository: Factory returned null.",
index cff05b6..71253b3 100755 (executable)
@@ -50,7 +50,6 @@
 package edu.internet2.middleware.shibboleth.aa.arp.provider;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -83,7 +82,10 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
 
        public FileSystemArpRepository(Properties props) throws ArpRepositoryException {
                super(props);
-               if (props.getProperty("edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path", null)
+               if (props
+                       .getProperty(
+                               "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path",
+                               null)
                        == null) {
                        log.error(
                                "Cannot initialize FileSystemArpRepository: attribute (edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path) not specified");
@@ -107,21 +109,22 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
                        }
 
                        dataStorePath =
-                               props.getProperty("edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path");
+                               props.getProperty(
+                                       "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path");
                        if (!dataStorePath.endsWith("/")) {
                                dataStorePath += "/";
                        }
                        log.info("Initializing File System Arp Repository with a root of (" + dataStorePath + ").");
-               } catch (IOException e) {
+               } catch (Exception e) {
                        log.error(
                                "Cannot initialize FileSystemArpRepository: error accessing path: ("
                                        + props.getProperty(
                                                "edu.internet2.middleware.shibboleth.aa.arp.provider.FileSystemArpRepository.Path")
-                                       + ").");
+                                       + "): "
+                                       + e);
                        throw new ArpRepositoryException("Cannot initialize FileSystemArpRepository");
                }
        }
-
        /**
         * @see edu.internet2.middleware.shibboleth.aa.arp.ArpRepository#remove(Arp)
         */
@@ -155,7 +158,7 @@ public class FileSystemArpRepository extends BaseArpRepository implements ArpRep
                        return null;
                }
 
-               InputStream inStream = new FileInputStream(fileName);
+               InputStream inStream = new ShibResource(fileName).getInputStream();
                DOMParser parser = new DOMParser();
                parser.parse(new InputSource(inStream));
                return parser.getDocument().getDocumentElement();
index c7ef9b9..d122170 100755 (executable)
@@ -98,6 +98,8 @@ public class ShibResource {
                        return file;
                } catch (URISyntaxException e) {
                        throw new ResourceNotAvailableException("File could not be loaded from specified resource: " + e);
+               } catch (IllegalArgumentException e) {
+                       throw new ResourceNotAvailableException("File could not be loaded from specified resource: " + e);
                }
        }