Commit b096967b authored by Brian Major's avatar Brian Major
Browse files

s1970 - more system property setting for local authority discovery

parent 3dfdf269
......@@ -68,21 +68,13 @@
package ca.nrc.cadc.ac.client;
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.json.JsonUserListWriter;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.util.Log4jInit;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -90,21 +82,41 @@ import java.util.UUID;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
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.json.JsonUserListWriter;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.PropertiesReader;
public class JsonUserListInputStreamWrapperTest
{
private static final Logger log = Logger.getLogger(JsonUserListInputStreamWrapperTest.class);
static
{
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
}
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void readInputStream() throws Exception
{
......@@ -131,7 +143,7 @@ public class JsonUserListInputStreamWrapperTest
userListWriter.write(users, writer);
String json = writer.toString();
log.debug("user:\n" + json);
final InputStream inputStream = new ByteArrayInputStream(json.getBytes());
testSubject.read(inputStream);
......
......@@ -81,7 +81,9 @@ import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.auth.HttpPrincipal;
......@@ -89,6 +91,7 @@ import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.PropertiesReader;
public class UserClientTest
......@@ -98,6 +101,18 @@ public class UserClientTest
private URI umsServiceURI;
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
public UserClientTest()
{
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
......
......@@ -89,6 +89,7 @@ import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
......@@ -103,6 +104,7 @@ import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.PropertiesReader;
/**
* @author jburke
......@@ -111,12 +113,23 @@ public class JsonGroupReaderWriterTest
{
private static Logger log = Logger.getLogger(JsonGroupReaderWriterTest.class);
@BeforeClass
public static void setUpClass()
static
{
Log4jInit.setLevel("ca.nrc.cadc.ac.json", Level.INFO);
}
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions() throws Exception
{
......
package ca.nrc.cadc.ac.json;
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;
import java.io.Reader;
import java.net.URI;
import java.util.UUID;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.InternalID;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.PosixDetails;
......@@ -7,21 +24,9 @@ import ca.nrc.cadc.ac.TestUtil;
import ca.nrc.cadc.ac.User;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.util.Log4jInit;
import org.json.JSONObject;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import java.io.*;
import java.net.URI;
import java.security.Principal;
import java.util.*;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import static org.junit.Assert.*;
import ca.nrc.cadc.util.PropertiesReader;
/**
......@@ -30,12 +35,24 @@ import static org.junit.Assert.*;
public class JsonUserListReaderWriterTest
{
private static final Logger log = Logger.getLogger(JsonUserListReaderWriterTest.class);
static
{
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
}
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......
......@@ -68,6 +68,22 @@
*/
package ca.nrc.cadc.ac.json;
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;
import java.io.Reader;
import java.net.URI;
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;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.PosixDetails;
......@@ -76,19 +92,7 @@ import ca.nrc.cadc.ac.User;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.auth.NumericPrincipal;
import org.apache.log4j.Logger;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.URI;
import java.util.UUID;
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 ca.nrc.cadc.util.PropertiesReader;
/**
*
......@@ -98,6 +102,18 @@ public class JsonUserReaderWriterTest
{
private static Logger log = Logger.getLogger(JsonUserReaderWriterTest.class);
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......@@ -110,7 +126,7 @@ public class JsonUserReaderWriterTest
fail("null String should throw IllegalArgumentException");
}
catch (IllegalArgumentException e) {}
try
{
InputStream in = null;
......@@ -119,7 +135,7 @@ public class JsonUserReaderWriterTest
fail("null InputStream should throw IOException");
}
catch (IOException e) {}
try
{
Reader r = null;
......@@ -129,7 +145,7 @@ public class JsonUserReaderWriterTest
}
catch (IllegalArgumentException e) {}
}
@Test
public void testWriterExceptions()
throws Exception
......@@ -142,7 +158,7 @@ public class JsonUserReaderWriterTest
}
catch (WriterException e) {}
}
@Test
public void testReadWrite()
throws Exception
......@@ -166,5 +182,5 @@ public class JsonUserReaderWriterTest
assertNotNull(actual);
assertEquals(expected, actual);
}
}
......@@ -67,6 +67,21 @@
*/
package ca.nrc.cadc.ac.json;
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;
import java.io.Reader;
import java.net.URI;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.InternalID;
import ca.nrc.cadc.ac.PersonalDetails;
import ca.nrc.cadc.ac.TestUtil;
......@@ -75,23 +90,24 @@ import ca.nrc.cadc.ac.UserRequest;
import ca.nrc.cadc.ac.WriterException;
import ca.nrc.cadc.ac.xml.AbstractReaderWriter;
import ca.nrc.cadc.auth.HttpPrincipal;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.URI;
import java.security.Principal;
import java.util.UUID;
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 ca.nrc.cadc.util.PropertiesReader;
public class JsonUserRequestReaderWriterTest
{
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
@Test
public void testReaderExceptions()
throws Exception
......
......@@ -80,8 +80,8 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.Group;
......@@ -96,14 +96,14 @@ public class GroupListReaderWriterTest
{
private static Logger log = Logger.getLogger(GroupListReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -75,8 +75,7 @@ import static org.junit.Assert.fail;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
......@@ -94,14 +93,14 @@ public class GroupPropertyReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(GroupPropertyReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -85,8 +85,8 @@ import java.util.UUID;
import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.Group;
......@@ -108,14 +108,14 @@ public class GroupReaderWriterTest
{
private static Logger log = Logger.getLogger(GroupReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -80,8 +80,8 @@ import javax.security.auth.x500.X500Principal;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.ReaderException;
......@@ -99,14 +99,14 @@ public class IdentityReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(IdentityReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -74,8 +74,8 @@ import static org.junit.Assert.fail;
import org.apache.log4j.Logger;
import org.jdom2.Element;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.PersonalDetails;
......@@ -92,14 +92,14 @@ public class UserDetailsReaderWriterTest extends AbstractReaderWriter
{
private static Logger log = Logger.getLogger(UserDetailsReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -14,8 +14,8 @@ import java.util.List;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.nrc.cadc.ac.InternalID;
......@@ -29,14 +29,14 @@ public class UserListReaderWriterTest
{
private static Logger log = Logger.getLogger(UserListReaderWriterTest.class);
@Before
public void setup()
@BeforeClass
public static void setupClass()
{
System.setProperty(PropertiesReader.class.getName() + ".dir", "src/test/resources");
}
@After
public void teardown()
@AfterClass
public static void teardownClass()
{
System.clearProperty(PropertiesReader.class.getName() + ".dir");
}
......
......@@ -79,9 +79,10 @@ import java.io.Reader;
import java.net.URI;
import java.util.UUID;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;