protected KieServicesClient createDefaultClient() { Set<Class<?>> extraClasses = new HashSet<Class<?>>(); try { extraClasses.add(Class.forName("org.jbpm.data.Person", true, kieContainer.getClassLoader())); } catch (ClassNotFoundException e) { e.printStackTrace(); } KieServicesClient kieServicesClient = null; if (TestConfig.isLocalServer()) { KieServicesConfiguration localServerConfig = KieServicesFactory.newRestConfiguration(TestConfig.getHttpUrl(), null, null) .setMarshallingFormat(marshallingFormat); localServerConfig.addJaxbClasses(extraClasses); kieServicesClient = KieServicesFactory.newKieServicesClient(localServerConfig, kieContainer.getClassLoader()); } else { configuration.setMarshallingFormat(marshallingFormat); configuration.addJaxbClasses(extraClasses); configuration.setUserName("Administrator"); kieServicesClient = KieServicesFactory.newKieServicesClient(configuration, kieContainer.getClassLoader()); } configuration.setTimeout(5000); setupClients(kieServicesClient); return kieServicesClient; }
/* * The first call to the server takes usually much longer because the JVM needs to load all the classes, JAXRS subsystem gets * initialized, etc. The first test sometimes fails, more frequently on slow machines. * * This method creates dummy container and then immediately destroys it. This should warm-up the server enough * so that the subsequent calls are faster. */ private static void warmUpServer() throws Exception { logger.info( "Warming-up the server by creating dummy container and then immediately destroying it..."); KieServicesConfiguration config = createKieServicesRestConfiguration(); // specify higher timeout, the default is too small config.setTimeout(30000); KieServicesClient client = KieServicesFactory.newKieServicesClient(config); ReleaseId warmUpReleaseId = new ReleaseId("org.kie.server.testing", "server-warm-up", "42"); createAndDeployKJar(warmUpReleaseId); assertSuccess( client.createContainer( "warm-up-kjar", new KieContainerResource("warm-up-kjar", warmUpReleaseId))); assertSuccess(client.disposeContainer("warm-up-kjar")); logger.info("Server warm-up done."); }