public static void Init()
        {
            GenericTestUtils.AssumeInNativeProfile();
            Configuration conf = new Configuration();

            codec = CryptoCodec.GetInstance(conf);
        }
Пример #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAppendSort()
        {
            GenericTestUtils.AssumeInNativeProfile();
            Path file = new Path(RootPath, "testseqappendSort.seq");

            fs.Delete(file, true);
            Path sortedFile = new Path(RootPath, "testseqappendSort.seq.sort");

            fs.Delete(sortedFile, true);
            SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs, new JavaSerializationComparator
                                                                 <long>(), typeof(long), typeof(string), conf);
            SequenceFile.Writer.Option compressOption = SequenceFile.Writer.Compression(SequenceFile.CompressionType
                                                                                        .Block, new GzipCodec());
            SequenceFile.Writer writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.
                                                                   File(file), SequenceFile.Writer.KeyClass(typeof(long)), SequenceFile.Writer.ValueClass
                                                                       (typeof(string)), compressOption);
            writer.Append(2L, "two");
            writer.Append(1L, "one");
            writer.Close();
            writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                               .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                               .AppendIfExists(true), compressOption);
            writer.Append(4L, "four");
            writer.Append(3L, "three");
            writer.Close();
            // Sort file after append
            sorter.Sort(file, sortedFile);
            VerifyAll4Values(sortedFile);
            fs.DeleteOnExit(file);
            fs.DeleteOnExit(sortedFile);
        }
Пример #3
0
 /// <exception cref="System.Exception"/>
 public virtual void TestOpensslAesCtrCryptoCodec()
 {
     GenericTestUtils.AssumeInNativeProfile();
     if (!NativeCodeLoader.BuildSupportsOpenssl())
     {
         Log.Warn("Skipping test since openSSL library not loaded");
         Assume.AssumeTrue(false);
     }
     Assert.Equal(null, OpensslCipher.GetLoadingFailureReason());
     CryptoCodecTest(conf, seed, 0, opensslCodecClass, opensslCodecClass, iv);
     CryptoCodecTest(conf, seed, count, opensslCodecClass, opensslCodecClass, iv);
     CryptoCodecTest(conf, seed, count, opensslCodecClass, jceCodecClass, iv);
     // Overflow test, IV: xx xx xx xx xx xx xx xx ff ff ff ff ff ff ff ff
     for (int i = 0; i < 8; i++)
     {
         iv[8 + i] = unchecked ((byte)unchecked ((int)(0xff)));
     }
     CryptoCodecTest(conf, seed, count, opensslCodecClass, opensslCodecClass, iv);
     CryptoCodecTest(conf, seed, count, opensslCodecClass, jceCodecClass, iv);
 }
Пример #4
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAppendRecordCompression()
        {
            GenericTestUtils.AssumeInNativeProfile();
            Path file = new Path(RootPath, "testseqappendblockcompr.seq");

            fs.Delete(file, true);
            SequenceFile.Writer.Option compressOption = SequenceFile.Writer.Compression(SequenceFile.CompressionType
                                                                                        .Record, new GzipCodec());
            SequenceFile.Writer writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.
                                                                   File(file), SequenceFile.Writer.KeyClass(typeof(long)), SequenceFile.Writer.ValueClass
                                                                       (typeof(string)), compressOption);
            writer.Append(1L, "one");
            writer.Append(2L, "two");
            writer.Close();
            Verify2Values(file);
            writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                               .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                               .AppendIfExists(true), compressOption);
            writer.Append(3L, "three");
            writer.Append(4L, "four");
            writer.Close();
            VerifyAll4Values(file);
            fs.DeleteOnExit(file);
        }
Пример #5
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAppendBlockCompression()
        {
            GenericTestUtils.AssumeInNativeProfile();
            Path file = new Path(RootPath, "testseqappendblockcompr.seq");

            fs.Delete(file, true);
            SequenceFile.Writer.Option compressOption = SequenceFile.Writer.Compression(SequenceFile.CompressionType
                                                                                        .Block, new GzipCodec());
            SequenceFile.Writer writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.
                                                                   File(file), SequenceFile.Writer.KeyClass(typeof(long)), SequenceFile.Writer.ValueClass
                                                                       (typeof(string)), compressOption);
            writer.Append(1L, "one");
            writer.Append(2L, "two");
            writer.Close();
            Verify2Values(file);
            writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                               .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                               .AppendIfExists(true), compressOption);
            writer.Append(3L, "three");
            writer.Append(4L, "four");
            writer.Close();
            VerifyAll4Values(file);
            // Verify failure if the compression details are different or not Provided
            try
            {
                writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                                   .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                                   .AppendIfExists(true));
                writer.Close();
                NUnit.Framework.Assert.Fail("Expected IllegalArgumentException for compression options"
                                            );
            }
            catch (ArgumentException)
            {
            }
            // Expected exception. Ignore it
            // Verify failure if the compression details are different
            try
            {
                SequenceFile.Writer.Option wrongCompressOption = SequenceFile.Writer.Compression(
                    SequenceFile.CompressionType.Record, new GzipCodec());
                writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                                   .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                                   .AppendIfExists(true), wrongCompressOption);
                writer.Close();
                NUnit.Framework.Assert.Fail("Expected IllegalArgumentException for compression options"
                                            );
            }
            catch (ArgumentException)
            {
            }
            // Expected exception. Ignore it
            try
            {
                SequenceFile.Writer.Option wrongCompressOption = SequenceFile.Writer.Compression(
                    SequenceFile.CompressionType.Block, new DefaultCodec());
                writer = SequenceFile.CreateWriter(conf, SequenceFile.Writer.File(file), SequenceFile.Writer
                                                   .KeyClass(typeof(long)), SequenceFile.Writer.ValueClass(typeof(string)), SequenceFile.Writer
                                                   .AppendIfExists(true), wrongCompressOption);
                writer.Close();
                NUnit.Framework.Assert.Fail("Expected IllegalArgumentException for compression options"
                                            );
            }
            catch (ArgumentException)
            {
            }
            // Expected exception. Ignore it
            fs.DeleteOnExit(file);
        }