Beispiel #1
0
        public virtual void TestFileStatusWritable()
        {
            FileStatus[] tests = new FileStatus[] { new FileStatus(1, false, 5, 3, 4, 5, null
                                                                   , string.Empty, string.Empty, new Path("/a/b")), new FileStatus(0, false, 1, 2,
                                                                                                                                   3, new Path("/")), new FileStatus(1, false, 5, 3, 4, 5, null, string.Empty, string.Empty
                                                                                                                                                                     , new Path("/a/b")) };
            Log.Info("Writing FileStatuses to a ByteArrayOutputStream");
            // Writing input list to ByteArrayOutputStream
            ByteArrayOutputStream baos   = new ByteArrayOutputStream();
            BinaryWriter          writer = new DataOutputStream(baos);

            foreach (FileStatus fs in tests)
            {
                fs.Write(@out);
            }
            Log.Info("Creating ByteArrayInputStream object");
            BinaryReader reader = new DataInputStream(new ByteArrayInputStream(baos.ToByteArray()));

            Log.Info("Testing if read objects are equal to written ones");
            FileStatus dest     = new FileStatus();
            int        iterator = 0;

            foreach (FileStatus fs_1 in tests)
            {
                dest.ReadFields(@in);
                Assert.Equal("Different FileStatuses in iteration " + iterator
                             , dest, fs_1);
                iterator++;
            }
        }