Added some tests for the FileSystemArpRepository.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 28 Jan 2003 20:51:55 +0000 (20:51 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 28 Jan 2003 20:51:55 +0000 (20:51 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@431 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java

index 05384a2..7aff835 100755 (executable)
@@ -481,11 +481,44 @@ public class ArpTests extends TestCase {
                        repository);
 
                try {
-                       repository.getSitePolicy();
-                       repository.getUserPolicy(new AAPrincipal("test"));
-                       repository.getAllPolicies(new AAPrincipal("test"));
-               } catch (ArpRepositoryException e) {
-                       fail("Error retrieving ARP from Repository.");
+                       Arp siteArp = repository.getSitePolicy();
+
+                       InputStream inStream = new FileInputStream("data/arp.site.xml");
+                       parser.parse(new InputSource(inStream));
+                       ByteArrayOutputStream directXML = new ByteArrayOutputStream();
+                       new XMLSerializer(directXML, new OutputFormat()).serialize(
+                               parser.getDocument().getDocumentElement());
+
+                       ByteArrayOutputStream processedXML = new ByteArrayOutputStream();
+                       new XMLSerializer(processedXML, new OutputFormat()).serialize(siteArp.unmarshall());
+
+                       assertTrue(
+                               "File-based ARP Repository did not return the correct site ARP.",
+                               directXML.toString().replaceAll(">[\t\r\n ]+<", "><").equals(
+                                       processedXML.toString().replaceAll(">[\t\r\n ]+<", "><")));
+
+                       Arp userArp = repository.getUserPolicy(new AAPrincipal("test"));
+
+                       inStream = new FileInputStream("data/arp.user.test.xml");
+                       parser.parse(new InputSource(inStream));
+                       directXML = new ByteArrayOutputStream();
+                       new XMLSerializer(directXML, new OutputFormat()).serialize(
+                               parser.getDocument().getDocumentElement());
+
+                       processedXML = new ByteArrayOutputStream();
+                       new XMLSerializer(processedXML, new OutputFormat()).serialize(userArp.unmarshall());
+
+                       assertTrue(
+                               "File-based ARP Repository did not return the correct user ARP.",
+                               directXML.toString().replaceAll(">[\t\r\n ]+<", "><").equals(
+                                       processedXML.toString().replaceAll(">[\t\r\n ]+<", "><")));
+
+                       Arp[] allArps = repository.getAllPolicies(new AAPrincipal("test"));
+
+                       assertTrue("File-based ARP Repository did not return the correct number of ARPs.", (allArps.length == 2));
+               
+               } catch (Exception e) {
+                       fail("Error retrieving ARP from Repository: " + e);
                }
 
        }