diff --git a/ql/pom.xml b/ql/pom.xml index f1a6f7d..53b638f 100644 --- a/ql/pom.xml +++ b/ql/pom.xml @@ -630,7 +630,28 @@ + + + + set -x + set -e + function generate_jar(){ + jarName=$1 + cp src/test/resources/$jarName.txt target/RefreshedJarClass.java + cd target + javac RefreshedJarClass.java + jar cf RefreshedJarClass.jar RefreshedJarClass.class + mv RefreshedJarClass.jar /tmp/$jarName.jar + cd - + } + + generate_jar RefreshedJarClassV1 + generate_jar RefreshedJarClassV2 + + + + diff --git a/ql/src/test/org/apache/hadoop/hive/ql/session/TestSessionState.java b/ql/src/test/org/apache/hadoop/hive/ql/session/TestSessionState.java index 45ba07e..6eedc7a 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/session/TestSessionState.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/session/TestSessionState.java @@ -50,10 +50,10 @@ public class TestSessionState { private final boolean prewarm; - private final static String clazzDistFileName = "SessionStateTest.jar.v1"; - private final static String clazzV2FileName = "SessionStateTest.jar.v2"; - private final static String reloadClazzFileName = "reloadingClazz.jar"; - private final static String reloadClazzName = "org.apache.test.RefreshedJarClass"; + private final static String clazzDistFileName = "RefreshedJarClassV1.jar"; + private final static String clazzV2FileName = "RefreshedJarClassV2.jar"; + private final static String reloadClazzFileName = "RefreshedJarClass.jar"; + private final static String reloadClazzName = "RefreshedJarClass"; private final static String versionMethodName = "version"; private static String hiveReloadPath; private File reloadFolder; @@ -183,7 +183,7 @@ public void testReloadAuxJars2() { File dist = null; try { dist = new File(reloadFolder.getAbsolutePath() + File.separator + reloadClazzFileName); - Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzDistFileName)), dist); + Files.copy(new File("/tmp" + File.separator + clazzDistFileName.toString()), dist); ss.reloadAuxJars(); Assert.assertEquals("version1", getReloadedClazzVersion(ss.getConf().getClassLoader())); } catch (Exception e) { @@ -215,14 +215,14 @@ public void testReloadExistingAuxJars2() { LOG.info("copy jar file 1"); dist = new File(reloadFolder.getAbsolutePath() + File.separator + reloadClazzFileName); - Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzDistFileName)), dist); + Files.copy(new File("/tmp" + File.separator + clazzDistFileName.toString()), dist); ss.reloadAuxJars(); Assert.assertEquals("version1", getReloadedClazzVersion(ss.getConf().getClassLoader())); LOG.info("copy jar file 2"); FileUtils.deleteQuietly(dist); - Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzV2FileName)), dist); + Files.copy(new File("/tmp" + File.separator + clazzV2FileName.toString()), dist); ss.reloadAuxJars(); Assert.assertEquals("version2", getReloadedClazzVersion(ss.getConf().getClassLoader())); diff --git a/ql/src/test/resources/RefreshedJarClassV1.txt b/ql/src/test/resources/RefreshedJarClassV1.txt new file mode 100644 index 0000000..036b998 --- /dev/null +++ b/ql/src/test/resources/RefreshedJarClassV1.txt @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +public class RefreshedJarClass { + public String version(){ + return "version1"; + } + + public static void main(String [] args){ + System.out.println(new RefreshedJarClass().version()); + } +} \ No newline at end of file diff --git a/ql/src/test/resources/RefreshedJarClassV2.txt b/ql/src/test/resources/RefreshedJarClassV2.txt new file mode 100644 index 0000000..c965265 --- /dev/null +++ b/ql/src/test/resources/RefreshedJarClassV2.txt @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +public class RefreshedJarClass { + public String version(){ + return "version2"; + } + + public static void main(String [] args){ + System.out.println(new RefreshedJarClass().version()); + } +} \ No newline at end of file