public virtual void TestJVMId()
        {
            JVMId jvmid  = new JVMId("test", 1, true, 2);
            JVMId jvmid1 = JVMId.ForName("jvm_test_0001_m_000002");

            // test compare methot should be the same
            NUnit.Framework.Assert.AreEqual(0, jvmid.CompareTo(jvmid1));
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestGetTask()
        {
            AppContext            appCtx             = Org.Mockito.Mockito.Mock <AppContext>();
            JobTokenSecretManager secret             = Org.Mockito.Mockito.Mock <JobTokenSecretManager>();
            RMHeartbeatHandler    rmHeartbeatHandler = Org.Mockito.Mockito.Mock <RMHeartbeatHandler
                                                                                 >();
            TaskHeartbeatHandler hbHandler = Org.Mockito.Mockito.Mock <TaskHeartbeatHandler>();

            TestTaskAttemptListenerImpl.MockTaskAttemptListenerImpl listener = new TestTaskAttemptListenerImpl.MockTaskAttemptListenerImpl
                                                                                   (appCtx, secret, rmHeartbeatHandler, hbHandler);
            Configuration conf = new Configuration();

            listener.Init(conf);
            listener.Start();
            JVMId        id  = new JVMId("foo", 1, true, 1);
            WrappedJvmID wid = new WrappedJvmID(id.GetJobId(), id.isMap, id.GetId());
            // Verify ask before registration.
            //The JVM ID has not been registered yet so we should kill it.
            JvmContext context = new JvmContext();

            context.jvmId = id;
            JvmTask result = listener.GetTask(context);

            NUnit.Framework.Assert.IsNotNull(result);
            NUnit.Framework.Assert.IsTrue(result.shouldDie);
            // Verify ask after registration but before launch.
            // Don't kill, should be null.
            TaskAttemptId attemptID = Org.Mockito.Mockito.Mock <TaskAttemptId>();
            Task          task      = Org.Mockito.Mockito.Mock <Task>();

            //Now put a task with the ID
            listener.RegisterPendingTask(task, wid);
            result = listener.GetTask(context);
            NUnit.Framework.Assert.IsNull(result);
            // Unregister for more testing.
            listener.Unregister(attemptID, wid);
            // Verify ask after registration and launch
            //Now put a task with the ID
            listener.RegisterPendingTask(task, wid);
            listener.RegisterLaunchedTask(attemptID, wid);
            Org.Mockito.Mockito.Verify(hbHandler).Register(attemptID);
            result = listener.GetTask(context);
            NUnit.Framework.Assert.IsNotNull(result);
            NUnit.Framework.Assert.IsFalse(result.shouldDie);
            // Don't unregister yet for more testing.
            //Verify that if we call it again a second time we are told to die.
            result = listener.GetTask(context);
            NUnit.Framework.Assert.IsNotNull(result);
            NUnit.Framework.Assert.IsTrue(result.shouldDie);
            listener.Unregister(attemptID, wid);
            // Verify after unregistration.
            result = listener.GetTask(context);
            NUnit.Framework.Assert.IsNotNull(result);
            NUnit.Framework.Assert.IsTrue(result.shouldDie);
            listener.Stop();
            // test JVMID
            JVMId jvmid = JVMId.ForName("jvm_001_002_m_004");

            NUnit.Framework.Assert.IsNotNull(jvmid);
            try
            {
                JVMId.ForName("jvm_001_002_m_004_006");
                Assert.Fail();
            }
            catch (ArgumentException e)
            {
                NUnit.Framework.Assert.AreEqual(e.Message, "TaskId string : jvm_001_002_m_004_006 is not properly formed"
                                                );
            }
        }