@@ -0,0 +1,3428 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.pig.test;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.util.HashSet;%0Aimport java.util.Properties;%0Aimport java.util.jar.JarFile;%0A%0Aimport org.apache.pig.ExecType;%0Aimport org.apache.pig.PigServer;%0Aimport org.apache.pig.backend.executionengine.ExecException;%0Aimport org.apache.pig.impl.util.JarManager;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A/**%0A * Ensure that jars marked as predeployed are not included in the generated %0A * job jar. %0A */%0Apublic class TestPredeployedJar %7B%0A    @Test%0A    public void testPredeployedJar() throws IOException, ClassNotFoundException %7B%0A        // The default jar should contain jackson classes%0A        PigServer pigServer = new PigServer(ExecType.LOCAL, new Properties());%0A        File jobJarFile = Util.createTempFileDelOnExit(%22Job%22, %22.jar%22);%0A        FileOutputStream fos = new FileOutputStream(jobJarFile);%0A        JarManager.createJar(fos, new HashSet%3CString%3E(), pigServer.getPigContext());%0A        JarFile jobJar = new JarFile(jobJarFile);%0A        Assert.assertNotNull(jobJar.getJarEntry(%22org/codehaus/jackson/JsonParser.class%22));%0A        %0A        // Now let's mark the jackson jar as predeployed. %0A        pigServer = new PigServer(ExecType.LOCAL, new Properties());%0A        pigServer.getPigContext().markJarAsPredeployed(JarManager.findContainingJar(%0A                org.codehaus.jackson.JsonParser.class));%0A        jobJarFile = Util.createTempFileDelOnExit(%22Job%22, %22.jar%22);%0A        fos = new FileOutputStream(jobJarFile);%0A        JarManager.createJar(fos, new HashSet%3CString%3E(), pigServer.getPigContext());%0A        jobJar = new JarFile(jobJarFile);%0A        %0A        // And check that the predeployed jar was not added%0A        Assert.assertNull(jobJar.getJarEntry(%22org/codehaus/jackson/JsonParser.class%22));%0A    %7D%0A    %0A    @Test%0A    public void testPredeployedJarsProperty() throws ExecException %7B%0A        Properties p = new Properties();%0A        p.setProperty(%22pig.predeployed.jars%22, %22zzz%22);%0A        PigServer pigServer = new PigServer(ExecType.LOCAL, p);%0A        %0A        Assert.assertTrue(pigServer.getPigContext().predeployedJars.contains(%22zzz%22));%0A        %0A        p = new Properties();%0A        p.setProperty(%22pig.predeployed.jars%22, %22aaa%22 + File.pathSeparator + %22bbb%22);%0A        pigServer = new PigServer(ExecType.LOCAL, p);%0A        %0A        Assert.assertTrue(pigServer.getPigContext().predeployedJars.contains(%22aaa%22));%0A        Assert.assertTrue(pigServer.getPigContext().predeployedJars.contains(%22bbb%22));%0A        %0A        Assert.assertFalse(pigServer.getPigContext().predeployedJars.contains(%22zzz%22));%0A    %7D%0A%7D%0A

Add support for pre-deployed jars (commit missing test)