/// <summary>1.</summary>
        /// <remarks>
        /// 1. create files with dfs
        /// 2. write MIN_N_PACKET to MAX_N_PACKET packets
        /// 3. close file
        /// 4. open the same file
        /// 5. read the bytes and compare results
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        private static void WriteSeveralPackets(string methodName)
        {
            Random r              = FiTestUtil.Random.Get();
            int    nPackets       = FiTestUtil.NextRandomInt(MinNPacket, MaxNPacket + 1);
            int    lastPacketSize = FiTestUtil.NextRandomInt(1, PacketSize + 1);
            int    size           = (nPackets - 1) * PacketSize + lastPacketSize;

            FiTestUtil.Log.Info("size=" + size + ", nPackets=" + nPackets + ", lastPacketSize="
                                + lastPacketSize);
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(Replication
                                                                                   + 2).Build();
            FileSystem dfs = cluster.GetFileSystem();

            try
            {
                Path p = new Path("/" + methodName + "/foo");
                FSDataOutputStream @out = CreateFile(dfs, p);
                long   seed             = r.NextLong();
                Random ran = new Random(seed);
                ran.NextBytes(bytes);
                @out.Write(bytes, 0, size);
                @out.Close();
                FSDataInputStream @in = dfs.Open(p);
                int totalRead         = 0;
                int nRead             = 0;
                while ((nRead = @in.Read(toRead, totalRead, size - totalRead)) > 0)
                {
                    totalRead += nRead;
                }
                NUnit.Framework.Assert.AreEqual("Cannot read file.", size, totalRead);
                for (int i = 0; i < size; i++)
                {
                    NUnit.Framework.Assert.IsTrue("File content differ.", bytes[i] == toRead[i]);
                }
            }
            finally
            {
                dfs.Close();
                cluster.Shutdown();
            }
        }