Author: kkolinko
Date: Thu Jan 21 18:45:54 2016
New Revision: 1726060

URL: http://svn.apache.org/viewvc?rev=1726060&view=rev
Log:
Use new ServerFactory method to clear Server instance after a test run.

Modified:
    
tomcat/tc6.0.x/branches/tomcat6-testing_20160106/test/org/apache/catalina/startup/TomcatBaseTest.java

Modified: 
tomcat/tc6.0.x/branches/tomcat6-testing_20160106/test/org/apache/catalina/startup/TomcatBaseTest.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/branches/tomcat6-testing_20160106/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1726060&r1=1726059&r2=1726060&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/branches/tomcat6-testing_20160106/test/org/apache/catalina/startup/TomcatBaseTest.java
 (original)
+++ 
tomcat/tc6.0.x/branches/tomcat6-testing_20160106/test/org/apache/catalina/startup/TomcatBaseTest.java
 Thu Jan 21 18:45:54 2016
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.lang.reflect.Field;
 import java.net.HttpURLConnection;
 import java.net.InetAddress;
 import java.net.URL;
@@ -103,10 +102,10 @@ public abstract class TomcatBaseTest ext
             fail("Unable to create appBase for test");
         }
 
-        // FIXME. This is an ugly sanity check that the Server reference has 
been cleared after the previous test run
-        Field f = ServerFactory.class.getDeclaredField("server");
-        f.setAccessible(true);
-        assertNull("ServerFactory.server field is not null", f.get(null));
+        // A sanity check that the Server reference has been cleared after
+        // the previous test run
+        assertNull("A Server has already been created.",
+                ServerFactory.getServer(false));
 
         tomcat = new TomcatWithFastSessionIDs();
 
@@ -177,18 +176,7 @@ public abstract class TomcatBaseTest ext
                 tomcat.destroy();
             }
         } finally {
-            // ServerFactory.setServer(null);
-            //
-            // FIXME: Implement ServerFactory.clear(), as suggested in
-            // http://tomcat.markmail.org/thread/ko7ip7obvyaftwe4
-            //
-            // The setServer(null) call does not work due to "if (server == 
null)" check.
-            // Thus I am implementing it via reflection.
-            //
-            Field f = ServerFactory.class.getDeclaredField("server");
-            f.setAccessible(true);
-            f.set(null, null);
-
+            ServerFactory.clear();
             super.tearDown();
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to