Package org.apache.hadoop.hbase.util
Class ClassLoaderTestHelper
java.lang.Object
org.apache.hadoop.hbase.util.ClassLoaderTestHelper
Some utilities to help class loader testing
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private static final org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addJarFilesToJar
(File targetJar, String libPrefix, File... srcJars) Add a list of jar files to another jar file under a specific folder.static File
Create a test jar for testing purpose for a given class name with specified code string: save the class to a file, compile it, and jar it up.static File
Create a test jar for testing purpose for a given class name with specified code string.private static boolean
createJarArchive
(File archiveFile, File[] tobeJared) Jar a list of files into a jar archive.static void
deleteClass
(String className, String testDir, org.apache.hadoop.conf.Configuration conf) static String
localDirPath
(org.apache.hadoop.conf.Configuration conf)
-
Field Details
-
LOG
-
BUFFER_SIZE
- See Also:
-
-
Constructor Details
-
ClassLoaderTestHelper
private ClassLoaderTestHelper()
-
-
Method Details
-
createJarArchive
Jar a list of files into a jar archive.- Parameters:
archiveFile
- the target jar archivetobeJared
- a list of files to be jared- Returns:
- true if a jar archive is build, false otherwise
-
buildJar
Create a test jar for testing purpose for a given class name with specified code string: save the class to a file, compile it, and jar it up. If the code string passed in is null, a bare empty class will be created and used.- Parameters:
testDir
- the folder under which to store the test class and jarclassName
- the test class namecode
- the optional test class code, which can be null. If null, a bare empty class will be used- Returns:
- the test jar file generated
- Throws:
Exception
-
buildJar
public static File buildJar(String testDir, String className, String code, String folder) throws Exception Create a test jar for testing purpose for a given class name with specified code string.- Parameters:
testDir
- the folder under which to store the test classclassName
- the test class namecode
- the optional test class code, which can be null. If null, an empty class will be usedfolder
- the folder under which to store the generated jar- Returns:
- the test jar file generated
- Throws:
Exception
-
addJarFilesToJar
public static void addJarFilesToJar(File targetJar, String libPrefix, File... srcJars) throws Exception Add a list of jar files to another jar file under a specific folder. It is used to generated coprocessor jar files which can be loaded by the coprocessor class loader. It is for testing usage only so we don't be so careful about stream closing in case any exception.- Parameters:
targetJar
- the target jar filelibPrefix
- the folder where to put inner jar filessrcJars
- the source inner jar files to be added- Throws:
Exception
- if anything doesn't work as expected
-
localDirPath
-
deleteClass
public static void deleteClass(String className, String testDir, org.apache.hadoop.conf.Configuration conf) throws Exception - Throws:
Exception
-