Repository: hive Updated Branches: refs/heads/branch-1.2 38a2248de -> b43f33f78
HIVE-11041 : Update tests for HIVE-9302 after removing binaries (Jesus Camacho Rodriguez reviewed by Hari Subramaniyan) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b43f33f7 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b43f33f7 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b43f33f7 Branch: refs/heads/branch-1.2 Commit: b43f33f7849b09eaf7f91cdec4951bf232fc51fb Parents: 38a2248 Author: Hari Subramaniyan <[email protected]> Authored: Thu Jun 18 13:56:13 2015 -0700 Committer: Hari Subramaniyan <[email protected]> Committed: Thu Jun 18 13:56:13 2015 -0700 ---------------------------------------------------------------------- .../hive/ql/session/TestSessionState.java | 20 ++++++++++----- src/test/resources/RefreshedJarClassV1.txt | 26 ++++++++++++++++++++ src/test/resources/RefreshedJarClassV2.txt | 26 ++++++++++++++++++++ 3 files changed, 66 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/b43f33f7/ql/src/test/org/apache/hadoop/hive/ql/session/TestSessionState.java ---------------------------------------------------------------------- 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 c3c353b..9e16c0c 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 @@ -20,13 +20,16 @@ package org.apache.hadoop.hive.ql.session; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collection; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hive.conf.HiveConf; @@ -48,12 +51,10 @@ import com.google.common.io.Files; */ @RunWith(value = Parameterized.class) 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 = "RefreshedJarClass.jar.V1"; + private final static String clazzV2FileName = "RefreshedJarClass.jar.V2"; + private final static String reloadClazzFileName = "RefreshedJarClass.jar"; private final static String versionMethodName = "version"; private final static String RELOADED_CLAZZ_PREFIX_NAME = "RefreshedJarClass"; private final static String V1 = "V1"; @@ -86,6 +87,13 @@ public class TestSessionState { reloadFolder.mkdir(); } + try { + generateRefreshJarFiles(V2); + generateRefreshJarFiles(V1); + } catch (Throwable e) { + Assert.fail("fail to generate refresh jar file due to the error " + e); + } + if (prewarm) { HiveConf.setBoolVar(conf, ConfVars.HIVE_PREWARM_ENABLED, true); HiveConf.setIntVar(conf, ConfVars.HIVE_PREWARM_NUM_CONTAINERS, 1); @@ -170,7 +178,7 @@ public class TestSessionState { } private String getReloadedClazzVersion(ClassLoader cl) throws Exception { - Class addedClazz = Class.forName(reloadClazzName, true, cl); + Class addedClazz = Class.forName(RELOADED_CLAZZ_PREFIX_NAME, true, cl); Method versionMethod = addedClazz.getMethod(versionMethodName); return (String) versionMethod.invoke(addedClazz.newInstance()); } http://git-wip-us.apache.org/repos/asf/hive/blob/b43f33f7/src/test/resources/RefreshedJarClassV1.txt ---------------------------------------------------------------------- diff --git a/src/test/resources/RefreshedJarClassV1.txt b/src/test/resources/RefreshedJarClassV1.txt new file mode 100644 index 0000000..70c9069 --- /dev/null +++ b/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()); + } +} http://git-wip-us.apache.org/repos/asf/hive/blob/b43f33f7/src/test/resources/RefreshedJarClassV2.txt ---------------------------------------------------------------------- diff --git a/src/test/resources/RefreshedJarClassV2.txt b/src/test/resources/RefreshedJarClassV2.txt new file mode 100644 index 0000000..6aac034 --- /dev/null +++ b/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()); + } +}
