Search in sources :

Example 51 with InMemoryJarfile

use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.

the class TestInitStartLocalClusterInProcess method testGetClasses.

public void testGetClasses() throws IOException {
    InMemoryJarfile jarFile = getProcJarFromCatalog();
    assertTrue(!anyCatalogDefaultArtifactsExists(jarFile));
    org.voltdb.client.ClientResponse resp = null;
    // No java stored proc at this time, will give jar with no classes
    try {
        resp = client.callProcedure("@SystemCatalog", "CLASSES");
    } catch (ProcCallException excp) {
        assert false : "@SystemCatalogClasses failed";
    }
    assertTrue(jarFile.getLoader().getClassNames().size() == resp.getResults()[0].getRowCount());
    // load java stored proc classes and verify the retrieved classes count
    loadAndAddProcs();
    jarFile = getProcJarFromCatalog();
    assertTrue(!anyCatalogDefaultArtifactsExists(jarFile));
    try {
        resp = client.callProcedure("@SystemCatalog", "CLASSES");
    } catch (ProcCallException excp) {
        assert false : "@SystemCatalogClasses failed";
    }
    assertTrue(jarFile.getLoader().getClassNames().size() == resp.getResults()[0].getRowCount());
}
Also used : InMemoryJarfile(org.voltdb.utils.InMemoryJarfile) ClientResponse(org.voltdb.client.ClientResponse) ProcCallException(org.voltdb.client.ProcCallException)

Example 52 with InMemoryJarfile

use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.

the class TestInitStartLocalClusterInProcess method loadAndAddProcs.

void loadAndAddProcs() throws IOException, NoConnectionsException {
    ClientResponse resp = null;
    long numberOfClasses = 0;
    try {
        resp = client.callProcedure("@SystemCatalog", "CLASSES");
    } catch (ProcCallException excp) {
        assert false : "@SystemCatalogClasses failed";
    }
    numberOfClasses = resp.getResults()[0].getRowCount();
    InMemoryJarfile jarfile = new InMemoryJarfile();
    VoltCompiler comp = new VoltCompiler(false);
    try {
        comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testImportProc.class);
        comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testCreateProcFromClassProc.class);
        comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.InnerClassesTestProc.class);
        comp.addClassToJar(jarfile, RangeCount.class);
    } catch (Exception e) {
        assert false : "Failed add class to jar: " + e.getMessage();
    }
    try {
        client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
    } catch (ProcCallException excp) {
        assert false : "Failed updating the class";
    }
    try {
        resp = client.callProcedure("@SystemCatalog", "CLASSES");
    } catch (ProcCallException excp) {
        assert false : "@SystemCatalogClasses failed";
    }
    assertTrue((numberOfClasses + jarfile.getLoader().getClassNames().size()) == resp.getResults()[0].getRowCount());
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltCompiler(org.voltdb.compiler.VoltCompiler) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile) ProcCallException(org.voltdb.client.ProcCallException) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException)

Aggregations

InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)52 VoltCompiler (org.voltdb.compiler.VoltCompiler)26 File (java.io.File)20 ProcCallException (org.voltdb.client.ProcCallException)19 ClientResponse (org.voltdb.client.ClientResponse)18 Test (org.junit.Test)15 Configuration (org.voltdb.VoltDB.Configuration)15 IOException (java.io.IOException)14 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)12 VoltDB (org.voltdb.VoltDB)9 Catalog (org.voltdb.catalog.Catalog)6 VoltTable (org.voltdb.VoltTable)5 VoltFile (org.voltdb.utils.VoltFile)5 ArrayList (java.util.ArrayList)4 JSONObject (org.json_voltpatches.JSONObject)3 CatalogContext (org.voltdb.CatalogContext)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JAXBException (javax.xml.bind.JAXBException)2