Index: test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 4300)
+++ test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 4301)
@@ -26,15 +26,12 @@
 
 package edu.ucsb.nceas.metacattest;
 
+import edu.ucsb.nceas.MCTestCase;
 import edu.ucsb.nceas.metacat.service.PropertyService;
 import edu.ucsb.nceas.utilities.HttpMessage;
 import edu.ucsb.nceas.utilities.PropertyNotFoundException;
 import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
 import junit.framework.TestSuite;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import java.io.*;
 import java.net.*;
@@ -43,26 +40,25 @@
 /**
  * A JUnit test for testing Step class processing
  */
-public class MetaCatServletTest extends TestCase {
+public class MetaCatServletTest extends MCTestCase {
 	private static String metacatURL;
 	private String serialNumber;
-	private static final Log log = LogFactory
-			.getLog("edu.ucsb.nceas.metacattest.MetaCatServletTest");
-	/* Initialize properties*/
+
+	/* Initialize properties */
 	static {
 		try {
-			PropertyService.getInstance("build/tests");
 			metacatURL = PropertyService.getProperty("test.metacatUrl");
-		} catch (Exception e) {
-			System.err.println("Exception in initialize option in MetacatServletNetTest "
-					+ e.getMessage());
+		} catch (PropertyNotFoundException pnfe) {
+			System.err.println("Could not get property in static block: "
+					+ pnfe.getMessage());
 		}
 	}
 
 	/**
 	 * Constructor to build the test
-	 *
-	 * @param name the name of the test method
+	 * 
+	 * @param name
+	 *            the name of the test method
 	 */
 	public MetaCatServletTest(String name) {
 		super(name);
@@ -70,8 +66,9 @@
 
 	/**
 	 * Constructor to build the test
-	 *
-	 * @param name the name of the test method
+	 * 
+	 * @param name
+	 *            the name of the test method
 	 */
 	public MetaCatServletTest(String name, String serial) {
 		super(name);
@@ -105,14 +102,14 @@
 		suite.addTest(new MetaCatServletTest("testPiscoReferralLogin"));
 		suite.addTest(new MetaCatServletTest("testPiscoReferralLoginFail"));
 		suite.addTest(new MetaCatServletTest("testNCEASLoginFail"));
-		//Should put a login successfully at the end of login test
-		//So insert or update can have cookie.
+		// Should put a login successfully at the end of login test
+		// So insert or update can have cookie.
 		suite.addTest(new MetaCatServletTest("testNCEASLogin"));
 
-		//create random number for docid, so it can void repeat
+		// create random number for docid, so it can void repeat
 		number = Math.random() * 100000;
 		serial = Integer.toString(((new Double(number)).intValue()));
-		log.debug("serial: " + serial);
+		debug("serial: " + serial);
 		suite.addTest(new MetaCatServletTest("testInsertXMLDocument", serial));
 		suite.addTest(new MetaCatServletTest("testReadXMLDocumentXMLFormat", serial));
 		suite.addTest(new MetaCatServletTest("testUpdateXMLDocument", serial));
@@ -122,11 +119,11 @@
 
 		suite.addTest(new MetaCatServletTest("testDeleteXMLDocument", serial));
 
-		//insert invalid xml document
+		// insert invalid xml document
 		number = Math.random() * 100000;
 		serial = Integer.toString(((new Double(number)).intValue()));
 		suite.addTest(new MetaCatServletTest("testInsertInvalidateXMLDocument", serial));
-		//insert non well formed document
+		// insert non well formed document
 		number = Math.random() * 100000;
 		serial = Integer.toString(((new Double(number)).intValue()));
 		suite
@@ -139,8 +136,8 @@
 	}
 
 	/**
-	 * Run an initial test that always passes to check that the test
-	 * harness is working.
+	 * Run an initial test that always passes to check that the test harness is
+	 * working.
 	 */
 	public void initialize() {
 		assertTrue(1 == 1);
@@ -150,10 +147,11 @@
 	 * Test the login to neceas succesfully
 	 */
 	public void testNCEASLogin() {
+		debug("\nRunning: testNCEASLogin test");
 		String user = "uid=john,o=NCEAS,dc=ecoinformatics,dc=org";
 		String passwd = "123456";
 		assertTrue(logIn(user, passwd));
-		//assertTrue( withProtocol.getProtocol().equals("http"));
+		// assertTrue( withProtocol.getProtocol().equals("http"));
 	}
 
 	/**
@@ -160,6 +158,7 @@
 	 * Test the login to neceas failed
 	 */
 	public void testNCEASLoginFail() {
+		debug("\nRunning: testNCEASLoginFail test");
 		String user = "uid=john,o=NCEAS,dc=ecoinformatics,dc=org";
 		String passwd = "12345678";
 		assertTrue(!logIn(user, passwd));
@@ -170,6 +169,7 @@
 	 * Test the login to lter succesfully
 	 */
 	public void testLterReferralLogin() {
+		debug("\nRunning: testLterReferralLogin test");
 		String user = null;
 		String passwd = null;
 		try {
@@ -178,6 +178,8 @@
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
+
+		debug("Logging into lter: " + user + " : " + passwd);
 		assertTrue(logIn(user, passwd));
 
 	}
@@ -186,10 +188,11 @@
 	 * Test the login to lter failed
 	 */
 	public void testLterReferralLoginFail() {
+		debug("\nRunning: testLterReferralLoginFail test");
 		String user = "uid=jtao,o=LTER,dc=ecoinformatics,dc=org";
 		String passwd = "qVyGpveb";
 		assertTrue(!logIn(user, passwd));
-		//assertTrue( withProtocol.getProtocol().equals("http"));
+		// assertTrue( withProtocol.getProtocol().equals("http"));
 	}
 
 	/**
@@ -196,6 +199,7 @@
 	 * Test the login to pisco succesfully
 	 */
 	public void testPiscoReferralLogin() {
+		debug("\nRunning: testPiscoReferralLogin test");
 		String user = null;
 		String passwd = null;
 		try {
@@ -204,6 +208,7 @@
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
+		debug("logging in pisco user: " + user + ":" + passwd);
 		assertTrue(logIn(user, passwd));
 		// assertTrue( withProtocol.getProtocol().equals("http"));
 	}
@@ -212,10 +217,11 @@
 	 * Test the login to pisco failed
 	 */
 	public void testPiscoReferralLoginFail() {
+		debug("\nRunning: testPiscoReferralLoginFail test");
 		String user = "uid=tao,o=PISCO,dc=ecoinformatics,dc=org";
 		String passwd = "hello";
 		assertTrue(!logIn(user, passwd));
-		//assertTrue( withProtocol.getProtocol().equals("http"));
+		// assertTrue( withProtocol.getProtocol().equals("http"));
 	}
 
 	/**
@@ -222,14 +228,16 @@
 	 * Test insert a xml document successfully
 	 */
 	public void testInsertXMLDocument() {
+		debug("\nRunning: testInsertXMLDocument test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
 					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
-		log.debug("insert docid: " + name);
+		debug("insert docid: " + name);
 		String content = "<?xml version=\"1.0\"?>"
 				+ "<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
 				+ "eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
@@ -240,24 +248,26 @@
 				+ "<permission>all</permission>" + "</allow>" + "<allow>"
 				+ "<principal>public</principal>" + "<permission>read</permission>"
 				+ "</allow>" + "</acl>";
-		log.debug("xml document: " + content);
+		debug("xml document: " + content);
 		assertTrue(handleXMLDocument(content, name, "insert"));
 
 	}
 
 	/**
-	 * Test insert a invalidate xml document successfully
-	 * In the String, there is no <!Doctype ... Public/System/>
+	 * Test insert a invalidate xml document successfully In the String, there
+	 * is no <!Doctype ... Public/System/>
 	 */
 	public void testInsertInvalidateXMLDocument() {
+		debug("\nRunning: testInsertInvalidateXMLDocument test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "1";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
-		log.debug("insert docid: " + name);
+		debug("insert docid: " + name);
 		String content = "<?xml version=\"1.0\"?>"
 				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
 				+ "</identifier>" + "<allow>"
@@ -265,23 +275,25 @@
 				+ "<permission>all</permission>" + "</allow>" + "<allow>"
 				+ "<principal>public</principal>" + "<permission>read</permission>"
 				+ "</allow>" + "</acl>";
-		log.debug("xml document: " + content);
+		debug("xml document: " + content);
 		assertTrue(handleXMLDocument(content, name, "insert"));
 	}
 
 	/**
-	 * Test insert a non well-formed xml document successfully
-	 * There is no </acl> in this string
+	 * Test insert a non well-formed xml document successfully There is no
+	 * </acl> in this string
 	 */
 	public void testInsertNonWellFormedXMLDocument() {
+		debug("\nRunning: testInsertNonWellFormedXMLDocument test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "1";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
-		log.debug("insert non well-formed docid: " + name);
+		debug("insert non well-formed docid: " + name);
 		String content = "<?xml version=\"1.0\"?>"
 				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
 				+ "</identifier>" + "<allow>"
@@ -290,18 +302,20 @@
 				+ "<principal>public</principal>" + "<permission>read</permission>"
 				+ "</allow>";
 
-		log.debug("xml document: " + content);
+		debug("xml document: " + content);
 		assertTrue(!handleXMLDocument(content, name, "insert"));
 	}
 
 	/**
-	 * Test read a xml document  in xml format successfully
+	 * Test read a xml document in xml format successfully
 	 */
 	public void testReadXMLDocumentXMLFormat() {
+		debug("\nRunning: testReadXMLDocumentXMLFormat test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "1";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
@@ -310,31 +324,35 @@
 	}
 
 	/**
-	 * Test read a xml document  in html format successfully
+	 * Test read a xml document in html format successfully
 	 */
 	public void testReadXMLDocumentHTMLFormat() {
+		debug("\nRunning: testReadXMLDocumentHTMLFormat test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "1";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
-		}	
+		}
 		assertTrue(handleReadAction(name, "html"));
 
 	}
 
 	/**
-	 * Test read a xml document  in zip format successfully
+	 * Test read a xml document in zip format successfully
 	 */
 	public void testReadXMLDocumentZipFormat() {
+		debug("\nRunning: testReadXMLDocumentZipFormat test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "1";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "1";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
-		}	
+		}
 		assertTrue(handleReadAction(name, "zip"));
 
 	}
@@ -343,14 +361,16 @@
 	 * Test insert a xml document successfully
 	 */
 	public void testUpdateXMLDocument() {
+		debug("\nRunning: testUpdateXMLDocument test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "2";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "2";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
-		}		
-		log.debug("update docid: " + name);
+		}
+		debug("update docid: " + name);
 		String content = "<?xml version=\"1.0\"?>"
 				+ "<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
 				+ "eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
@@ -361,7 +381,7 @@
 				+ "<permission>all</permission>" + "</allow>" + "<allow>"
 				+ "<principal>public</principal>" + "<permission>read</permission>"
 				+ "</allow>" + "</acl>";
-		log.debug("xml document: " + content);
+		debug("xml document: " + content);
 		assertTrue(handleXMLDocument(content, name, "update"));
 
 	}
@@ -370,14 +390,16 @@
 	 * Test delete a xml document successfully
 	 */
 	public void testDeleteXMLDocument() {
+		debug("\nRunning: testDeleteXMLDocument test");
 		String name = null;
 		try {
-			name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber
-				+ PropertyService.getProperty("document.accNumSeparator") + "2";
+			name = "john" + PropertyService.getProperty("document.accNumSeparator")
+					+ serialNumber
+					+ PropertyService.getProperty("document.accNumSeparator") + "2";
 		} catch (PropertyNotFoundException pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
-		log.debug("delete docid: " + name);
+		debug("delete docid: " + name);
 		assertTrue(handleDeleteFile(name));
 
 	}
@@ -386,7 +408,7 @@
 	 * Test logout action
 	 */
 	public void testLogOut() {
-
+		debug("\nRunning: testLogOut test");
 		assertTrue(handleLogOut());
 
 	}
@@ -393,9 +415,11 @@
 
 	/**
 	 * Method to hanld login action
-	 *
-	 * @param usrerName, the DN name of the test method
-	 * @param passWord, the passwd of the user
+	 * 
+	 * @param usrerName,
+	 *            the DN name of the test method
+	 * @param passWord,
+	 *            the passwd of the user
 	 */
 
 	public boolean logIn(String userName, String passWord) {
@@ -407,7 +431,7 @@
 
 		// Now contact metacat
 		String response = getMetacatString(prop);
-		log.debug("Login Message: " + response);
+		debug("Login Message: " + response);
 		boolean connected = false;
 		if (response.indexOf("<login>") != -1) {
 			connected = true;
@@ -421,9 +445,11 @@
 
 	/**
 	 * Method to hanld logout action
-	 *
-	 * @param usrerName, the DN name of the test method
-	 * @param passWord, the passwd of the user
+	 * 
+	 * @param usrerName,
+	 *            the DN name of the test method
+	 * @param passWord,
+	 *            the passwd of the user
 	 */
 
 	public boolean handleLogOut() {
@@ -433,7 +459,7 @@
 		prop.put("qformat", "xml");
 
 		String response = getMetacatString(prop);
-		log.debug("Logout Message: " + response);
+		debug("Logout Message: " + response);
 		HttpMessage.setCookie(null);
 
 		if (response.indexOf("<logout>") != -1) {
@@ -447,9 +473,11 @@
 
 	/**
 	 * Method to hanld read both xml and data file
-	 *
-	 * @param docid, the docid of the document want to read
-	 * @param qformat, the format of document user want to get
+	 * 
+	 * @param docid,
+	 *            the docid of the document want to read
+	 * @param qformat,
+	 *            the format of document user want to get
 	 */
 	public boolean handleReadAction(String docid, String qformat) {
 		Properties prop = new Properties();
@@ -460,10 +488,13 @@
 
 		message = getMetacatString(prop);
 		message = message.trim();
-		if (message == null || message.equals("") || message.indexOf("<error>") != -1) {//there was an error
+		if (message == null || message.equals("") || message.indexOf("<error>") != -1) {// there
+																						// was
+																						// an
+																						// error
 
 			return false;
-		} else {//successfully
+		} else {// successfully
 			return true;
 		}
 
@@ -471,14 +502,17 @@
 
 	/**
 	 * Method to hanld inset or update xml document
-	 *
-	 * @param xmlDocument, the content of xml qformat
-	 * @param docid, the docid of the document
-	 * @param action, insert or update
+	 * 
+	 * @param xmlDocument,
+	 *            the content of xml qformat
+	 * @param docid,
+	 *            the docid of the document
+	 * @param action,
+	 *            insert or update
 	 */
 	public boolean handleXMLDocument(String xmlDocument, String docid, String action)
 
-	{ //-attempt to write file to metacat
+	{ // -attempt to write file to metacat
 		String access = "no";
 		StringBuffer fileText = new StringBuffer();
 		StringBuffer messageBuf = new StringBuffer();
@@ -485,20 +519,20 @@
 		String accessFileId = null;
 		Properties prop = new Properties();
 		prop.put("action", action);
-		prop.put("public", access); //This is the old way of controlling access
+		prop.put("public", access); // This is the old way of controlling access
 		prop.put("doctext", xmlDocument);
 		prop.put("docid", docid);
 
 		String message = getMetacatString(prop);
-		log.debug("Insert or Update Message: " + message);
-		if (message.indexOf("<error>") != -1) {//there was an error
+		debug("Insert or Update Message: " + message);
+		if (message.indexOf("<error>") != -1) {// there was an error
 
 			return false;
-		} else if (message.indexOf("<success>") != -1) {//the operation worked
-			//write the file to the cache and return the file object
+		} else if (message.indexOf("<success>") != -1) {// the operation worked
+			// write the file to the cache and return the file object
 			return true;
 
-		} else {//something weird happened.
+		} else {// something weird happened.
 			return false;
 		}
 
@@ -511,15 +545,15 @@
 		prop.put("docid", name);
 
 		String message = getMetacatString(prop);
-		log.debug("Delete Message: " + message);
-		if (message.indexOf("<error>") != -1) {//there was an error
+		debug("Delete Message: " + message);
+		if (message.indexOf("<error>") != -1) {// there was an error
 
 			return false;
-		} else if (message.indexOf("<success>") != -1) {//the operation worked
-			//write the file to the cache and return the file object
+		} else if (message.indexOf("<success>") != -1) {// the operation worked
+			// write the file to the cache and return the file object
 			return true;
 
-		} else {//something weird happened.
+		} else {// something weird happened.
 			return false;
 		}
 	}
@@ -549,8 +583,9 @@
 
 	/**
 	 * Send a request to Metacat
-	 *
-	 * @param prop the properties to be sent to Metacat
+	 * 
+	 * @param prop
+	 *            the properties to be sent to Metacat
 	 * @return InputStream as returned by Metacat
 	 */
 	public InputStream getMetacatInputStream(Properties prop) {
