From common-commits-return-19950-apmail-hadoop-common-commits-archive=hadoop.apache.org@hadoop.apache.org Tue Dec 4 02:42:18 2012 Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 584C9EFA6 for ; Tue, 4 Dec 2012 02:42:18 +0000 (UTC) Received: (qmail 24221 invoked by uid 500); 4 Dec 2012 02:42:17 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 24155 invoked by uid 500); 4 Dec 2012 02:42:16 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 24117 invoked by uid 99); 4 Dec 2012 02:42:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2012 02:42:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2012 02:42:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 08247238890B for ; Tue, 4 Dec 2012 02:41:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1416752 - in /hadoop/common/branches/branch-1-win: ./ src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ src/test/org/apache/hadoop/mapred/ src/test/org/apache/hadoop/security/authentication/client/ src/test/org/apache/hadoo... Date: Tue, 04 Dec 2012 02:41:44 -0000 To: common-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121204024148.08247238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szetszwo Date: Tue Dec 4 02:41:40 2012 New Revision: 1416752 URL: http://svn.apache.org/viewvc?rev=1416752&view=rev Log: svn merge -c 1416751 from branch-1 for HADOOP-9111. Change some JUnit 3 tests to JUnit 4 so that @Ignore tests can be run with ant 1.8.x. Modified: hadoop/common/branches/branch-1-win/ (props changed) hadoop/common/branches/branch-1-win/CHANGES.txt (contents, props changed) hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java Propchange: hadoop/common/branches/branch-1-win/ ------------------------------------------------------------------------------ Merged /hadoop/common/branches/branch-1:r1416751 Modified: hadoop/common/branches/branch-1-win/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.txt?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/CHANGES.txt (original) +++ hadoop/common/branches/branch-1-win/CHANGES.txt Tue Dec 4 02:41:40 2012 @@ -40,6 +40,9 @@ Release 1.2.0 - unreleased HADOOP-9099. TestNetUtils fails if "UnknownHost" is resolved as a valid hostname. (Ivan Mitic via szetszwo) + 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 - Unreleased INCOMPATIBLE CHANGES Propchange: hadoop/common/branches/branch-1-win/CHANGES.txt ------------------------------------------------------------------------------ Merged /hadoop/common/branches/branch-1/CHANGES.txt:r1416751 Modified: hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java (original) +++ hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/ClusterWithCapacityScheduler.java Tue Dec 4 02:41:40 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-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java (original) +++ hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerServlet.java Tue Dec 4 02:41:40 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-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java (original) +++ hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacitySchedulerWithJobTracker.java Tue Dec 4 02:41:40 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-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java (original) +++ hadoop/common/branches/branch-1-win/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobTrackerRestartWithCS.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestJobTrackerRestart.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestLocalizationWithLinuxTaskController.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestTaskTrackerLocalization.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java Tue Dec 4 02:41:40 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() { @@ -72,6 +77,7 @@ public class TestKerberosAuthenticator e }); } + @Test public void testAuthenticationPost() throws Exception { setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration()); KerberosTestUtils.doAsClient(new Callable() { Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java Tue Dec 4 02:41:40 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-win/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java?rev=1416752&r1=1416751&r2=1416752&view=diff ============================================================================== --- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java (original) +++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java Tue Dec 4 02:41:40 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() { @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});