Author: suresh
Date: Tue Dec  4 19:26:13 2012
New Revision: 1417133

URL: http://svn.apache.org/viewvc?rev=1417133&view=rev
Log:
HADOOP-9111. Merging change r1416751 from branch-1 to be picked up for release 
1.1.2

Modified:
    hadoop/common/branches/branch-1.1/CHANGES.txt
    
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java
    
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java
    
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java
    
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java
    
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java

Modified: hadoop/common/branches/branch-1.1/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/CHANGES.txt?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1.1/CHANGES.txt Tue Dec  4 19:26:13 2012
@@ -25,6 +25,9 @@ Release 1.1.2 - 2012.11.18
     HDFS-4208. NameNode could be stuck in SafeMode due to never-created
     blocks. (Brandon Li via suresh)
 
+    HADOOP-9111. Change some JUnit 3 tests to JUnit 4 so that @Ignore tests can
+    be run with ant 1.8.x.  (Jing Zhao via szetszwo)
+
 Release 1.1.1 - 2012.11.18
 
   INCOMPATIBLE CHANGES

Modified: 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java
 Tue Dec  4 19:26:13 2012
@@ -26,15 +26,13 @@ import java.net.URL;
 import java.util.Enumeration;
 import java.util.Properties;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.junit.After;
 
 /**
  * A test-cluster based on {@link MiniMRCluster} that is started with
@@ -43,7 +41,7 @@ import org.apache.hadoop.hdfs.MiniDFSClu
  * should extend this.
  * 
  */
-public class ClusterWithCapacityScheduler extends TestCase {
+public class ClusterWithCapacityScheduler {
 
   static final Log LOG = LogFactory.getLog(ClusterWithCapacityScheduler.class);
   private MiniMRCluster mrCluster;
@@ -153,8 +151,8 @@ public class ClusterWithCapacitySchedule
     return this.mrCluster.getJobTrackerRunner().getJobTracker();
   }
 
-  @Override
-  protected void tearDown()
+  @After
+  public void tearDown()
       throws Exception {
     cleanUpSchedulerConfigFile();
     

Modified: 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java
 Tue Dec  4 19:26:13 2012
@@ -18,11 +18,15 @@
 
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 import java.net.URL;
 
+import org.junit.Test;
+
 public class TestCapacitySchedulerServlet extends
     ClusterWithCapacityScheduler {
 
@@ -32,6 +36,7 @@ public class TestCapacitySchedulerServle
    * 
    * @throws IOException
    */
+  @Test
   public void testCapacitySchedulerServlet() throws IOException {
     Properties schedulerProps = new Properties();
     String[] queues = new String[] { "Q1", "Q2" };

Modified: 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java
 Tue Dec  4 19:26:13 2012
@@ -18,10 +18,15 @@
 
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.util.Properties;
 
 import org.apache.hadoop.examples.SleepJob;
+import org.junit.Test;
 
 
 public class TestCapacitySchedulerWithJobTracker extends
@@ -33,6 +38,7 @@ public class TestCapacitySchedulerWithJo
    * 
    * @throws Exception
    */
+  @Test
   public void testFailingJobInitalization() throws Exception {
     Properties schedulerProps = new Properties();
     schedulerProps.put("mapred.capacity-scheduler.queue.default.capacity",
@@ -72,6 +78,7 @@ public class TestCapacitySchedulerWithJo
    * 
    * @throws Exception
    */
+  @Test
   public void testJobTrackerIntegration() throws Exception {
 
     Properties schedulerProps = new Properties();

Modified: 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java
 Tue Dec  4 19:26:13 2012
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertTrue;
+
 import java.util.Properties;
 import 
org.apache.hadoop.mapred.ControlledMapReduceJob.ControlledMapReduceJobRunner;
 import org.junit.*;
@@ -37,6 +39,7 @@ public class TestJobTrackerRestartWithCS
    *
    * @throws Exception
    */
+  @Test
   public void testJobTrackerRestartWithCS()
           throws Exception {
     try {

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java
 Tue Dec  4 19:26:13 2012
@@ -17,18 +17,22 @@
  */
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.*;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.mapred.UtilsForTests;
 import org.apache.hadoop.mapred.QueueManager.QueueACL;
+import org.apache.hadoop.mapred.UtilsForTests.HalfWaitingMapper;
+import org.apache.hadoop.mapred.UtilsForTests.WaitingReducer;
 import org.apache.hadoop.security.UserGroupInformation;
-
-import junit.framework.TestCase;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.*;
+import org.junit.Ignore;
+import org.junit.Test;
 /** 
  * TestJobTrackerRestart checks if the jobtracker can restart. JobTracker 
  * should be able to continue running the previously running jobs and also 
@@ -37,7 +41,7 @@ import org.junit.*;
 /**UNTIL MAPREDUCE-873 is backported, we will not run recovery manager tests
  */
 @Ignore
-public class TestJobTrackerRestart extends TestCase {
+public class TestJobTrackerRestart {
   static final Path testDir = 
     new Path(System.getProperty("test.build.data","/tmp"), 
              "jt-restart-testing");
@@ -96,6 +100,7 @@ public class TestJobTrackerRestart exten
    * 
    * Check if the job is missing
    */
+  @Test
   public void testRestartWithoutRecovery(MiniDFSCluster dfs, 
                                          MiniMRCluster mr) 
   throws IOException {
@@ -190,6 +195,7 @@ public class TestJobTrackerRestart exten
    *    - Check if the counters can be accessed
    *    - Check if the history files are (re)named properly
    */
+  @Test
   public void testTaskEventsAndReportsWithRecovery(MiniDFSCluster dfs, 
                                                    MiniMRCluster mr) 
   throws IOException {
@@ -404,6 +410,7 @@ public class TestJobTrackerRestart exten
    * 
    * Assumption that map slots are given first for setup.
    */
+  @Test
   public void testJobRecoveryWithEmptyHistory(MiniDFSCluster dfs, 
                                               MiniMRCluster mr) 
   throws IOException {
@@ -495,6 +502,7 @@ public class TestJobTrackerRestart exten
     assertFalse("Old jobconf file is not deleted", historyFS.exists(confPath));
   }
   
+  @Test
   public void testJobTrackerRestart() throws IOException {
     String namenode = null;
     MiniDFSCluster dfs = null;

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java
 Tue Dec  4 19:26:13 2012
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -48,7 +50,7 @@ public class TestLocalizationWithLinuxTa
   }
 
   @Override
-  protected void setUp()
+  public void setUp()
       throws Exception {
 
     if (!canRun()) {
@@ -62,7 +64,7 @@ public class TestLocalizationWithLinuxTa
   }
 
   @Override
-  protected void tearDown()
+  public void tearDown()
       throws Exception {
     if (!canRun()) {
       return;

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java
 Tue Dec  4 19:26:13 2012
@@ -17,31 +17,32 @@
  */
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 
-import junit.framework.TestCase;
-import org.junit.Ignore;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.filecache.DistributedCache;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.lib.IdentityReducer;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * Class to test mapred debug Script
  */
 @Ignore //disabled until we fix the issues in running debug scripts
-public class TestMiniMRMapRedDebugScript extends TestCase {
+public class TestMiniMRMapRedDebugScript {
   private static final Log LOG =
     LogFactory.getLog(TestMiniMRMapRedDebugScript.class.getName());
 
@@ -185,6 +186,7 @@ public class TestMiniMRMapRedDebugScript
    * the output of debug out log. 
    *
    */
+  @Test
   public void testMapDebugScript() throws Exception {
     try {
       

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java
 Tue Dec  4 19:26:13 2012
@@ -17,6 +17,9 @@
  */
 package org.apache.hadoop.mapred;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -26,9 +29,6 @@ import java.util.TreeMap;
 import java.util.jar.JarOutputStream;
 import java.util.zip.ZipEntry;
 
-import junit.framework.TestCase;
-import org.junit.Ignore;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -37,7 +37,6 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.LocalDirAllocator;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapred.JvmManager.JvmEnv;
 import org.apache.hadoop.mapred.QueueManager.QueueACL;
 import org.apache.hadoop.mapred.TaskTracker.LocalStorage;
 import org.apache.hadoop.mapred.TaskTracker.RunningJob;
@@ -49,6 +48,10 @@ import org.apache.hadoop.mapreduce.serve
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * Test to verify localization of a job and localization of a task on a
@@ -56,7 +59,7 @@ import org.apache.hadoop.util.Shell;
  * 
  */
 @Ignore // test relies on deprecated functionality/lifecycle
-public class TestTaskTrackerLocalization extends TestCase {
+public class TestTaskTrackerLocalization {
 
   private File TEST_ROOT_DIR;
   private File ROOT_MAPRED_LOCAL_DIR;
@@ -92,8 +95,8 @@ public class TestTaskTrackerLocalization
     return true;
   }
 
-  @Override
-  protected void setUp()
+  @Before
+  public void setUp()
       throws Exception {
     if (!canRun()) {
       return;
@@ -261,8 +264,8 @@ public class TestTaskTrackerLocalization
         TokenCache.JOB_TOKEN_HDFS_FILE), new Configuration());
   }
 
-  @Override
-  protected void tearDown()
+  @After
+  public void tearDown()
       throws Exception {
     if (!canRun()) {
       return;
@@ -296,6 +299,7 @@ public class TestTaskTrackerLocalization
    * 
    * @throws IOException
    */
+  @Test
   public void testTaskControllerSetup()
       throws IOException {
     if (!canRun()) {
@@ -322,6 +326,7 @@ public class TestTaskTrackerLocalization
    * 
    * @throws IOException
    */
+  @Test
   public void testUserLocalization()
       throws IOException {
     if (!canRun()) {
@@ -397,6 +402,7 @@ public class TestTaskTrackerLocalization
    * 
    * @throws IOException
    */
+  @Test
   public void testJobLocalization()
       throws Exception {
     if (!canRun()) {
@@ -513,6 +519,7 @@ public class TestTaskTrackerLocalization
    * 
    * @throws IOException
    */
+  @Test
   public void testTaskLocalization()
       throws Exception {
     if (!canRun()) {
@@ -640,6 +647,7 @@ public class TestTaskTrackerLocalization
    * Validates if task cleanup is done properly for a succeeded task
    * @throws IOException
    */
+  @Test
   public void testTaskFilesRemoval()
       throws Exception {
     if (!canRun()) {
@@ -652,6 +660,7 @@ public class TestTaskTrackerLocalization
    * Validates if task cleanup is done properly for a task that is not 
succeeded
    * @throws IOException
    */
+  @Test
   public void testFailedTaskFilesRemoval()
   throws Exception {
     if (!canRun()) {
@@ -673,6 +682,7 @@ public class TestTaskTrackerLocalization
    * Validates if task cleanup is done properly for a succeeded task
    * @throws IOException
    */
+  @Test
   public void testTaskFilesRemovalWithJvmUse()
       throws Exception {
     if (!canRun()) {
@@ -782,6 +792,7 @@ public class TestTaskTrackerLocalization
    *   - create files with no write permissions to TT under job-work-dir
    *   - create files with no write permissions to TT under task-work-dir
    */
+  @Test
   public void testJobFilesRemoval() throws IOException, InterruptedException {
     if (!canRun()) {
       return;
@@ -873,6 +884,7 @@ public class TestTaskTrackerLocalization
    * @throws IOException
    * @throws InterruptedException
    */
+  @Test
   public void testTrackerRestart() throws IOException, InterruptedException {
     if (!canRun()) {
       return;
@@ -914,6 +926,7 @@ public class TestTaskTrackerLocalization
    * @throws IOException
    * @throws InterruptedException
    */
+  @Test
   public void testTrackerReinit() throws IOException, InterruptedException {
     if (!canRun()) {
       return;
@@ -949,6 +962,7 @@ public class TestTaskTrackerLocalization
    * @throws InterruptedException 
    * @throws IOException 
    */
+  @Test
   public void testCleanupTaskLocalization() throws IOException,
       InterruptedException {
     if (!canRun()) {

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java
 Tue Dec  4 19:26:13 2012
@@ -13,18 +13,9 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
-import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
-import junit.framework.TestCase;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.ServletHolder;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,7 +28,19 @@ import java.net.ServerSocket;
 import java.net.URL;
 import java.util.Properties;
 
-public abstract class AuthenticatorTestCase extends TestCase {
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public abstract class AuthenticatorTestCase {
   private Server server;
   private String host = null;
   private int port = -1;

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java
 Tue Dec  4 19:26:13 2012
@@ -13,11 +13,14 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
+import static org.junit.Assert.*;
+
 import org.apache.hadoop.security.authentication.KerberosTestUtils;
 import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
 import 
org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
 import 
org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
 import org.junit.Ignore;
+import org.junit.Test;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -38,6 +41,7 @@ public class TestKerberosAuthenticator e
     return props;
   }
 
+  @Test
   public void testFallbacktoPseudoAuthenticator() throws Exception {
     Properties props = new Properties();
     props.setProperty(AuthenticationFilter.AUTH_TYPE, "simple");
@@ -46,6 +50,7 @@ public class TestKerberosAuthenticator e
     _testAuthentication(new KerberosAuthenticator(), false);
   }
 
+  @Test
   public void testNotAuthenticated() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     start();
@@ -60,7 +65,7 @@ public class TestKerberosAuthenticator e
     }
   }
 
-
+  @Test
   public void testAuthentication() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     KerberosTestUtils.doAsClient(new Callable<Void>() {
@@ -72,6 +77,7 @@ public class TestKerberosAuthenticator e
     });
   }
 
+  @Test
   public void testAuthenticationPost() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     KerberosTestUtils.doAsClient(new Callable<Void>() {

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java
 Tue Dec  4 19:26:13 2012
@@ -13,8 +13,11 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
+import static org.junit.Assert.*;
+
 import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
 import 
org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
+import org.junit.Test;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -29,11 +32,13 @@ public class TestPseudoAuthenticator ext
     return props;
   }
 
+  @Test
   public void testGetUserName() throws Exception {
     PseudoAuthenticator authenticator = new PseudoAuthenticator();
     assertEquals(System.getProperty("user.name"), authenticator.getUserName());
   }
 
+  @Test
   public void testAnonymousAllowed() throws Exception {
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     start();
@@ -47,6 +52,7 @@ public class TestPseudoAuthenticator ext
     }
   }
 
+  @Test
   public void testAnonymousDisallowed() throws Exception {
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     start();
@@ -60,21 +66,25 @@ public class TestPseudoAuthenticator ext
     }
   }
 
+  @Test
   public void testAuthenticationAnonymousAllowed() throws Exception {
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     _testAuthentication(new PseudoAuthenticator(), false);
   }
 
+  @Test
   public void testAuthenticationAnonymousDisallowed() throws Exception {
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     _testAuthentication(new PseudoAuthenticator(), false);
   }
 
+  @Test
   public void testAuthenticationAnonymousAllowedWithPost() throws Exception {
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     _testAuthentication(new PseudoAuthenticator(), true);
   }
 
+  @Test
   public void testAuthenticationAnonymousDisallowedWithPost() throws Exception 
{
     
setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     _testAuthentication(new PseudoAuthenticator(), true);

Modified: 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java?rev=1417133&r1=1417132&r2=1417133&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
 (original)
+++ 
hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
 Tue Dec  4 19:26:13 2012
@@ -13,34 +13,37 @@
  */
 package org.apache.hadoop.security.authentication.server;
 
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.security.authentication.KerberosTestUtils;
 import 
org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
-import junit.framework.TestCase;
-import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.security.authentication.util.KerberosUtil;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSManager;
 import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Ignore;
+import org.junit.Test;
 import org.mockito.Mockito;
-import org.ietf.jgss.Oid;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.lang.reflect.Field;
-import java.util.Properties;
-import java.util.concurrent.Callable;
 
 //Disabled because kerberos setup and valid keytabs are required.
 @Ignore("requires kerberos setup")
-public class TestKerberosAuthenticationHandler extends TestCase {
+public class TestKerberosAuthenticationHandler {
 
   private KerberosAuthenticationHandler handler;
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUp() throws Exception {
     handler = new KerberosAuthenticationHandler();
     Properties props = new Properties();
     props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, 
KerberosTestUtils.getServerPrincipal());
@@ -55,25 +58,27 @@ public class TestKerberosAuthenticationH
     }
   }
 
-  @Override
-  protected void tearDown() throws Exception {
+  @After
+  public void tearDown() throws Exception {
     if (handler != null) {
       handler.destroy();
       handler = null;
     }
-    super.tearDown();
   }
 
+  @Test
   public void testInit() throws Exception {
     assertEquals(KerberosTestUtils.getServerPrincipal(), 
handler.getPrincipal());
     assertEquals(KerberosTestUtils.getKeytabFile(), handler.getKeytab());
   }
 
+  @Test
   public void testType() throws Exception {
     KerberosAuthenticationHandler handler = new 
KerberosAuthenticationHandler();
     assertEquals(KerberosAuthenticationHandler.TYPE, handler.getType());
   }
 
+  @Test
   public void testRequestWithoutAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -83,6 +88,7 @@ public class TestKerberosAuthenticationH
     Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
   }
 
+  @Test
   public void testRequestWithInvalidAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -93,6 +99,7 @@ public class TestKerberosAuthenticationH
     Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
   }
 
+  @Test
   public void testRequestWithIncompleteAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -109,7 +116,7 @@ public class TestKerberosAuthenticationH
     }
   }
 
-
+  @Test
   public void testRequestWithAuthorization() throws Exception {
     String token = KerberosTestUtils.doAsClient(new Callable<String>() {
       @Override
@@ -163,6 +170,7 @@ public class TestKerberosAuthenticationH
     }
   }
 
+  @Test
   public void testRequestWithInvalidKerberosAuthorization() throws Exception {
 
     String token = new Base64(0).encodeToString(new byte[]{0, 1, 2});


Reply via email to