use of com.google_voltpatches.common.reflect.ClassPath in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithClassesAndArtifacts.
/** Tests that when there are base classes and non-class files in the stored procedures,
* that these also exist in the staged catalog.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithClassesAndArtifacts() throws Exception {
System.out.println("Loading the schema from testprocs");
File resource = new File("tests/testprocs/org/voltdb_testprocs/fakeusecase/greetings/ddl.sql");
InputStream schemaReader = new FileInputStream(resource);
assertNotNull("Could not find " + resource, schemaReader);
String schema = CharStreams.toString(new InputStreamReader(schemaReader));
System.out.println("Creating a .jar file using all of the classes associated with this test.");
InMemoryJarfile originalInMemoryJar = new InMemoryJarfile();
VoltCompiler compiler = new VoltCompiler(false, false);
ClassPath classpath = ClassPath.from(this.getClass().getClassLoader());
String packageName = "org.voltdb_testprocs.fakeusecase.greetings";
int classesFound = 0;
for (ClassInfo myclass : classpath.getTopLevelClassesRecursive(packageName)) {
compiler.addClassToJar(originalInMemoryJar, myclass.load());
classesFound++;
}
// check that classes were found and loaded. If another test modifies "fakeusecase.greetings" it should modify this assert also.
assertEquals(5, classesFound);
System.out.println("Writing " + classesFound + " classes to jar file");
File classesJarfile = File.createTempFile("TestInitStartWithClasses-procedures", ".jar");
classesJarfile.deleteOnExit();
originalInMemoryJar.writeToFile(classesJarfile);
Configuration c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "schema", resource.getPath(), "classes", classesJarfile.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
validateStagedCatalog(schema, originalInMemoryJar);
}
Aggregations