示例#1
0
        public virtual void TestUnJar()
        {
            FilePath unjarDir = new FilePath(TestRootDir, "unjar-all");

            NUnit.Framework.Assert.IsFalse("unjar dir shouldn't exist at test start", new FilePath
                                               (unjarDir, "foobar.txt").Exists());
            // Unjar everything
            RunJar.UnJar(new FilePath(TestRootDir, TestJarName), unjarDir);
            Assert.True("foobar unpacked", new FilePath(unjarDir, "foobar.txt"
                                                        ).Exists());
            Assert.True("foobaz unpacked", new FilePath(unjarDir, "foobaz.txt"
                                                        ).Exists());
        }
示例#2
0
        /// <summary>Test unjarring a specific regex</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestUnJarWithPattern()
        {
            FilePath unjarDir = new FilePath(TestRootDir, "unjar-pattern");

            NUnit.Framework.Assert.IsFalse("unjar dir shouldn't exist at test start", new FilePath
                                               (unjarDir, "foobar.txt").Exists());
            // Unjar only a regex
            RunJar.UnJar(new FilePath(TestRootDir, TestJarName), unjarDir, Pattern.Compile
                             (".*baz.*"));
            NUnit.Framework.Assert.IsFalse("foobar not unpacked", new FilePath(unjarDir, "foobar.txt"
                                                                               ).Exists());
            Assert.True("foobaz unpacked", new FilePath(unjarDir, "foobaz.txt"
                                                        ).Exists());
        }
示例#3
0
        public virtual void TestRunjar()
        {
            FilePath outFile = new FilePath(TestRootDir, "out");

            // delete if output file already exists.
            if (outFile.Exists())
            {
                outFile.Delete();
            }
            FilePath makeTestJar = MakeTestJar();

            string[] args = new string[3];
            args[0] = makeTestJar.GetAbsolutePath();
            args[1] = "org.apache.hadoop.util.Hello";
            args[2] = outFile.ToString();
            RunJar.Main(args);
            NUnit.Framework.Assert.IsTrue("RunJar failed", outFile.Exists());
        }
示例#4
0
        public virtual void TestClientClassLoader()
        {
            RunJar runJar = Org.Mockito.Mockito.Spy(new RunJar());

            // enable the client classloader
            Org.Mockito.Mockito.When(runJar.UseClientClassLoader()).ThenReturn(true);
            // set the system classes and blacklist the test main class and the test
            // third class so they can be loaded by the application classloader
            string mainCls       = typeof(ClassLoaderCheckMain).FullName;
            string thirdCls      = typeof(ClassLoaderCheckThird).FullName;
            string systemClasses = "-" + mainCls + "," + "-" + thirdCls + "," + ApplicationClassLoader
                                   .SystemClassesDefault;

            Org.Mockito.Mockito.When(runJar.GetSystemClasses()).ThenReturn(systemClasses);
            // create the test jar
            FilePath testJar = MakeClassLoaderTestJar(mainCls, thirdCls);

            // form the args
            string[] args = new string[3];
            args[0] = testJar.GetAbsolutePath();
            args[1] = mainCls;
            // run RunJar
            runJar.Run(args);
        }