Index: test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 8805)
+++ test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java	(revision 8806)
@@ -26,6 +26,14 @@
 
 package edu.ucsb.nceas.metacattest;
 
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 import edu.ucsb.nceas.MCTestCase;
 import edu.ucsb.nceas.metacat.IdentifierManager;
 import edu.ucsb.nceas.metacat.client.MetacatClient;
@@ -34,14 +42,7 @@
 import edu.ucsb.nceas.metacat.properties.PropertyService;
 import edu.ucsb.nceas.utilities.PropertyNotFoundException;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
 
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-
 /**
  * A JUnit test for testing Step class processing
  */
@@ -167,6 +168,8 @@
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = PropertyService.getProperty("test.mcPassword");
             assertTrue(logIn(user, passwd));
+            this.testLogOut();
+
         } catch (PropertyNotFoundException pnfe) {
             fail("Could not find property: " + pnfe.getMessage());
         }
@@ -181,6 +184,8 @@
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = "BogusPasswordShouldFail";
             assertTrue(!logIn(user, passwd));
+            this.testLogOut();
+
         } catch (PropertyNotFoundException pnfe) {
             fail("Could not find property: " + pnfe.getMessage());
         }
@@ -202,7 +207,9 @@
 
 		debug("Logging into lter: " + user + " : " + passwd);
 		assertTrue(logIn(user, passwd));
+        this.testLogOut();
 
+
 	}
 
 	/**
@@ -219,6 +226,8 @@
     }
 		assertTrue(!logIn(user, passwd));
 		// assertTrue( withProtocol.getProtocol().equals("http"));
+        this.testLogOut();
+
 	}
 
 	/**
@@ -237,6 +246,8 @@
 		debug("logging in Other user: " + user + ":" + passwd);
 		assertTrue(logIn(user, passwd));
 		// assertTrue( withProtocol.getProtocol().equals("http"));
+        this.testLogOut();
+
 	}
 
 	/**
@@ -253,6 +264,8 @@
     }
 		assertTrue(!logIn(user, passwd));
 		// assertTrue( withProtocol.getProtocol().equals("http"));
+        this.testLogOut();
+
 	}
 	
 
@@ -266,7 +279,8 @@
         try {
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = PropertyService.getProperty("test.mcPassword");
-
+            metacat.login(user, passwd);
+            
             name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber + PropertyService.getProperty("document.accNumSeparator")
                     + "1";
             debug("insert docid: " + name);
@@ -277,9 +291,15 @@
                     + "<permission>read</permission>" + "</allow>" + "</acl>";
             debug("xml document: " + content);
             assertTrue(handleXMLDocument(content, name, "insert"));
+            metacat.logout();
+
         } catch (PropertyNotFoundException pnfe) {
             fail("Could not find property: " + pnfe.getMessage());
-        }
+        } catch (Exception e) {
+			// TODO Auto-generated catch block
+			fail(e.getMessage());
+			e.printStackTrace();
+		}
     }
 
 	/**
@@ -292,6 +312,7 @@
         try {
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
 
             name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber + PropertyService.getProperty("document.accNumSeparator")
                     + "1";
@@ -301,8 +322,10 @@
                     + "<permission>read</permission>" + "</allow>" + "</acl>";
             debug("xml document: " + content);
             assertTrue(handleXMLDocument(content, name, "insert"));
-        } catch (PropertyNotFoundException pnfe) {
-            fail("Could not find property: " + pnfe.getMessage());
+            metacat.logout();
+
+        } catch (Exception pnfe) {
+            fail(pnfe.getMessage());
         }
     }
 
@@ -316,6 +339,7 @@
         try {
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
 
             name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber + PropertyService.getProperty("document.accNumSeparator")
                     + "1";
@@ -326,8 +350,10 @@
 
             debug("xml document: " + content);
             assertTrue(!handleXMLDocument(content, name, "insert"));
-        } catch (PropertyNotFoundException pnfe) {
-            fail("Could not find property: " + pnfe.getMessage());
+            this.testLogOut();
+
+        } catch (Exception pnfe) {
+            fail(pnfe.getMessage());
         }
     }
 
@@ -338,13 +364,17 @@
 		debug("\nRunning: testReadXMLDocumentXMLFormat test");
 		String name = null;
 		try {
+			String user = PropertyService.getProperty("test.mcUser");
+            String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
 			name = "john" + PropertyService.getProperty("document.accNumSeparator")
 					+ serialNumber
 					+ PropertyService.getProperty("document.accNumSeparator") + "1";
-		} catch (PropertyNotFoundException pnfe) {
+			assertTrue(handleReadAction(name, "xml"));
+			metacat.logout();
+		} catch (Exception pnfe) {
 			fail("Could not find property: " + pnfe.getMessage());
 		}
-		assertTrue(handleReadAction(name, "xml"));
 
 	}
 
@@ -355,13 +385,17 @@
 		debug("\nRunning: testReadXMLDocumentHTMLFormat test");
 		String name = null;
 		try {
+			String user = PropertyService.getProperty("test.mcUser");
+            String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
 			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"));
+			metacat.logout();
+		} catch (Exception pnfe) {
+			fail(pnfe.getMessage());
 		}
-		assertTrue(handleReadAction(name, "html"));
 
 	}
 
@@ -372,13 +406,17 @@
 		debug("\nRunning: testReadXMLDocumentZipFormat test");
 		String name = null;
 		try {
+			String user = PropertyService.getProperty("test.mcUser");
+            String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
 			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"));
+			metacat.logout();
+		} catch (Exception pnfe) {
+			fail(pnfe.getMessage());
 		}
-		assertTrue(handleReadAction(name, "zip"));
 
 	}
 
@@ -392,6 +430,8 @@
             String user = PropertyService.getProperty("test.mcUser");
             String passwd = PropertyService.getProperty("test.mcPassword");
 
+            metacat.login(user, passwd);
+            
             name = "john" + PropertyService.getProperty("document.accNumSeparator") + serialNumber + PropertyService.getProperty("document.accNumSeparator")
                     + "2";
             debug("update docid: " + name);
@@ -402,8 +442,9 @@
                     + "<permission>read</permission>" + "</allow>" + "</acl>";
             debug("xml document: " + content);
             assertTrue(handleXMLDocument(content, name, "update"));
-        } catch (PropertyNotFoundException pnfe) {
-            fail("Could not find property: " + pnfe.getMessage());
+            this.testLogOut();
+        } catch (Exception pnfe) {
+            fail(pnfe.getMessage());
         }
     }
 
@@ -412,16 +453,24 @@
 	 */
 	public void testDeleteXMLDocument() {
 		debug("\nRunning: testDeleteXMLDocument test");
+		
 		String name = null;
 		try {
+			String user = PropertyService.getProperty("test.mcUser");
+            String passwd = PropertyService.getProperty("test.mcPassword");
+            metacat.login(user, passwd);
+            
 			name = "john" + PropertyService.getProperty("document.accNumSeparator")
 					+ serialNumber
 					+ PropertyService.getProperty("document.accNumSeparator") + "2";
-		} catch (PropertyNotFoundException pnfe) {
-			fail("Could not find property: " + pnfe.getMessage());
+			debug("delete docid: " + name);
+			assertTrue(handleDeleteFile(name));
+			metacat.logout();
+			
+		} catch (Exception pnfe) {
+			fail(pnfe.getMessage());
 		}
-		debug("delete docid: " + name);
-		assertTrue(handleDeleteFile(name));
+		
 
 	}
 
@@ -619,6 +668,7 @@
 			response = sw.toString();
 			sw.close();
 		} catch (Exception e) {
+			e.printStackTrace();
 			return null;
 		}
 
