Exemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestCloseForErroneousSequenceFile()
        {
            Configuration   conf = new Configuration();
            LocalFileSystem fs   = FileSystem.GetLocal(conf);
            // create an empty file (which is not a valid sequence file)
            Path path = new Path(Runtime.GetProperty("test.build.data", ".") + "/broken.seq");

            fs.Create(path).Close();
            // try to create SequenceFile.Reader
            TestSequenceFile.TestFSDataInputStream[] openedFile = new TestSequenceFile.TestFSDataInputStream
                                                                  [1];
            try
            {
                new _Reader_509(openedFile, fs, path, conf);
                // this method is called by the SequenceFile.Reader constructor, overwritten, so we can access the opened file
                Fail("IOException expected.");
            }
            catch (IOException)
            {
            }
            NUnit.Framework.Assert.IsNotNull(path + " should have been opened.", openedFile[0
                                             ]);
            Assert.True("InputStream for " + path + " should have been closed."
                        , openedFile[0].IsClosed());
        }
Exemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            protected internal override FSDataInputStream OpenFile(FileSystem fs, Path file,
                                                                   int bufferSize, long length)
            {
                InputStream @in = base.OpenFile(fs, file, bufferSize, length);

                openedFile[0] = new TestSequenceFile.TestFSDataInputStream(@in);
                return(openedFile[0]);
            }