/// <summary>Test to verify the read timeout</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestGetImageTimeout()
        {
            HttpServer2 testServer = HttpServerFunctionalTest.CreateServer("hdfs");

            try
            {
                testServer.AddServlet("ImageTransfer", ImageServlet.PathSpec, typeof(TestTransferFsImage.TestImageTransferServlet
                                                                                     ));
                testServer.Start();
                Uri serverURL = HttpServerFunctionalTest.GetServerURL(testServer);
                TransferFsImage.timeout = 2000;
                try
                {
                    TransferFsImage.GetFileClient(serverURL, "txid=1", null, null, false);
                    NUnit.Framework.Assert.Fail("TransferImage Should fail with timeout");
                }
                catch (SocketTimeoutException e)
                {
                    NUnit.Framework.Assert.AreEqual("Read should timeout", "Read timed out", e.Message
                                                    );
                }
            }
            finally
            {
                if (testServer != null)
                {
                    testServer.Stop();
                }
            }
        }
        /// <summary>Test to verify the timeout of Image upload</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestImageUploadTimeout()
        {
            Configuration conf        = new HdfsConfiguration();
            NNStorage     mockStorage = Org.Mockito.Mockito.Mock <NNStorage>();
            HttpServer2   testServer  = HttpServerFunctionalTest.CreateServer("hdfs");

            try
            {
                testServer.AddServlet("ImageTransfer", ImageServlet.PathSpec, typeof(TestTransferFsImage.TestImageTransferServlet
                                                                                     ));
                testServer.Start();
                Uri serverURL = HttpServerFunctionalTest.GetServerURL(testServer);
                // set the timeout here, otherwise it will take default.
                TransferFsImage.timeout = 2000;
                FilePath tmpDir = new FilePath(new FileSystemTestHelper().GetTestRootDir());
                tmpDir.Mkdirs();
                FilePath         mockImageFile = FilePath.CreateTempFile("image", string.Empty, tmpDir);
                FileOutputStream imageFile     = new FileOutputStream(mockImageFile);
                imageFile.Write(Sharpen.Runtime.GetBytesForString("data"));
                imageFile.Close();
                Org.Mockito.Mockito.When(mockStorage.FindImageFile(Org.Mockito.Mockito.Any <NNStorage.NameNodeFile
                                                                                            >(), Org.Mockito.Mockito.AnyLong())).ThenReturn(mockImageFile);
                Org.Mockito.Mockito.When(mockStorage.ToColonSeparatedString()).ThenReturn("storage:info:string"
                                                                                          );
                try
                {
                    TransferFsImage.UploadImageFromStorage(serverURL, conf, mockStorage, NNStorage.NameNodeFile
                                                           .Image, 1L);
                    NUnit.Framework.Assert.Fail("TransferImage Should fail with timeout");
                }
                catch (SocketTimeoutException e)
                {
                    NUnit.Framework.Assert.AreEqual("Upload should timeout", "Read timed out", e.Message
                                                    );
                }
            }
            finally
            {
                testServer.Stop();
            }
        }