Commit 2bfc8ec5 authored by Brian Major's avatar Brian Major
Browse files

s1970 - set config dir to src/test/resources

parent 562faadb
......@@ -68,10 +68,10 @@
*/
package ca.nrc.cadc.ac.xml;
import ca.nrc.cadc.ac.Group;
import ca.nrc.cadc.ac.WriterException;
import org.apache.log4j.Logger;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
......@@ -79,10 +79,14 @@ import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.Group;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -92,6 +96,18 @@ public class GroupListReaderWriterTest
{
private static Logger log = Logger.getLogger(GroupListReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......@@ -104,7 +120,7 @@ public class GroupListReaderWriterTest
fail("null String should throw IllegalArgumentException");
}
catch (IllegalArgumentException e) {}
try
{
InputStream in = null;
......@@ -113,7 +129,7 @@ public class GroupListReaderWriterTest
fail("null InputStream should throw IOException");
}
catch (IOException e) {}
try
{
Reader r = null;
......@@ -123,7 +139,7 @@ public class GroupListReaderWriterTest
}
catch (IllegalArgumentException e) {}
}
@Test
public void testWriterExceptions()
throws Exception
......@@ -136,15 +152,15 @@ public class GroupListReaderWriterTest
}
catch (WriterException e) {}
}
@Test
public void testMinimalReadWrite()
throws Exception
{
{
List<Group> expected = new ArrayList<Group>();
expected.add(new Group("group1"));
expected.add(new Group("group2"));
StringBuilder xml = new StringBuilder();
GroupListWriter groupListWriter = new GroupListWriter();
groupListWriter.write(expected, xml);
......
......@@ -68,16 +68,22 @@
*/
package ca.nrc.cadc.ac.xml;
import ca.nrc.cadc.ac.GroupProperty;
import ca.nrc.cadc.ac.ReaderException;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.util.Log4jInit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import ca.nrc.cadc.ac.GroupProperty;
import ca.nrc.cadc.ac.ReaderException;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -87,6 +93,18 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(GroupPropertyReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@BeforeClass
public static void setUpClass()
{
......@@ -104,7 +122,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
fail("null element should throw ReaderException");
}
catch (ReaderException e) {}
element = new Element("foo");
try
{
......@@ -112,7 +130,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
fail("element not named 'property' should throw ReaderException");
}
catch (ReaderException e) {}
element = new Element("property");
try
{
......@@ -120,7 +138,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
fail("element without 'key' attribute should throw ReaderException");
}
catch (ReaderException e) {}
element.setAttribute("key", "foo");
try
{
......@@ -128,7 +146,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
fail("element without 'type' attribute should throw ReaderException");
}
catch (ReaderException e) {}
element.setAttribute("type", "Double");
try
{
......@@ -137,7 +155,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
}
catch (ReaderException e) {}
}
@Test
public void testWriterExceptions()
throws Exception
......@@ -149,7 +167,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
fail("null GroupProperty should throw WriterException");
}
catch (WriterException e) {}
GroupProperty groupProperty = new GroupProperty("key", new Double(1.0), true);
try
{
......@@ -158,7 +176,7 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
}
catch (IllegalArgumentException e) {}
}
@Test
public void testReadWrite()
throws Exception
......@@ -167,21 +185,21 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
GroupProperty expected = new GroupProperty("key", "value", true);
Element element = getElement(expected);
assertNotNull(element);
GroupProperty actual = getGroupProperty(element);
assertNotNull(actual);
assertEquals(expected, actual);
// Integer tuype
expected = new GroupProperty("key", new Integer(1), false);
element = getElement(expected);
assertNotNull(element);
actual = getGroupProperty(element);
assertNotNull(actual);
assertEquals(expected, actual);
}
}
......@@ -85,6 +85,8 @@ import java.util.UUID;
import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.Group;
......@@ -96,6 +98,7 @@ import ca.nrc.cadc.ac.TestUtil;
import ca.nrc.cadc.ac.User;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -105,6 +108,18 @@ public class GroupReaderWriterTest
{
private static Logger log = Logger.getLogger(GroupReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......
......@@ -68,23 +68,28 @@
*/
package ca.nrc.cadc.ac.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.security.Principal;
import java.util.UUID;
import javax.management.remote.JMXPrincipal;
import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.ReaderException;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.auth.OpenIdPrincipal;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.Test;
import javax.management.remote.JMXPrincipal;
import javax.security.auth.x500.X500Principal;
import java.security.Principal;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -94,6 +99,18 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(IdentityReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......@@ -105,7 +122,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
fail("null element should throw ReaderException");
}
catch (ReaderException e) {}
element = new Element("foo");
try
{
......@@ -113,7 +130,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
fail("element not named 'identity' should throw ReaderException");
}
catch (ReaderException e) {}
element = new Element("identity");
try
{
......@@ -121,7 +138,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
fail("element without 'type' attribute should throw ReaderException");
}
catch (ReaderException e) {}
element.setAttribute("type", "foo");
try
{
......@@ -130,7 +147,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
}
catch (ReaderException e) {}
}
@Test
public void testWriterExceptions()
throws Exception
......@@ -142,7 +159,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
fail("null Identity should throw WriterException");
}
catch (WriterException e) {}
p = new JMXPrincipal("foo");
try
{
......@@ -151,7 +168,7 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
}
catch (IllegalArgumentException e) {}
}
@Test
public void testReadWrite()
throws Exception
......@@ -160,41 +177,41 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
Principal expected = new X500Principal("cn=foo,o=bar");
Element element = getElement(expected);
assertNotNull(element);
Principal actual = getPrincipal(element);
assertNotNull(actual);
assertEquals(expected, actual);
// CADC
expected = new NumericPrincipal(UUID.randomUUID());
element = getElement(expected);
assertNotNull(element);
actual = getPrincipal(element);
assertNotNull(actual);
assertEquals(expected, actual);
// OpenID
expected = new OpenIdPrincipal("bar");
element = getElement(expected);
assertNotNull(element);
actual = getPrincipal(element);
assertNotNull(actual);
assertEquals(expected, actual);
// HTTP
expected = new HttpPrincipal("baz");
element = getElement(expected);
assertNotNull(element);
actual = getPrincipal(element);
assertNotNull(actual);
assertEquals(expected, actual);
}
}
......@@ -68,17 +68,21 @@
*/
package ca.nrc.cadc.ac.xml;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.PosixDetails;
import ca.nrc.cadc.ac.ReaderException;
import ca.nrc.cadc.ac.WriterException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.PosixDetails;
import ca.nrc.cadc.ac.ReaderException;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -88,6 +92,18 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(UserDetailsReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......@@ -99,7 +115,7 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
fail("null element should throw ReaderException");
}
catch (ReaderException e) {}
element = new Element("foo");
try
{
......@@ -124,7 +140,7 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
}
catch (ReaderException e) {}
}
@Test
public void testWriterExceptions()
throws Exception
......@@ -145,7 +161,7 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
}
catch (WriterException e) {}
}
@Test
public void testReadWritePersonalDetails()
throws Exception
......@@ -158,7 +174,7 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
expected.institute = "institute";
Element element = getElement(expected);
assertNotNull(element);
PersonalDetails actual = getPersonalDetails(element);
assertNotNull(actual);
assertEquals(expected, actual);
......@@ -168,7 +184,7 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
assertEquals(expected.email, actual.email);
assertEquals(expected.institute, actual.institute);
}
@Test
public void testReadWritePosixDetails()
throws Exception
......@@ -176,10 +192,10 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
PosixDetails expected = new PosixDetails("username", 123l, 456, "/dev/null");
Element element = getElement(expected);
assertNotNull(element);
PosixDetails actual = getPosixDetails(element);
assertNotNull(actual);
assertEquals(expected, actual);
}
}
......@@ -14,6 +14,8 @@ import java.util.List;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.InternalID;
......@@ -21,11 +23,24 @@ import ca.nrc.cadc.ac.TestUtil;
import ca.nrc.cadc.ac.User;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.util.PropertiesReader;
public class UserListReaderWriterTest
{
private static Logger log = Logger.getLogger(UserListReaderWriterTest.class);
@BeforeClass
public void setup()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public void teardown()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......
......@@ -68,14 +68,10 @@
*/
package ca.nrc.cadc.ac.xml;
import ca.nrc.cadc.ac.InternalID;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.TestUtil;
import ca.nrc.cadc.ac.User;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.auth.NumericPrincipal;
import org.apache.log4j.Logger;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
......@@ -83,10 +79,18 @@ import java.io.Reader;
import java.net.URI;
import java.util.UUID;
import