use of org.kie.server.api.model.KieServerConfig in project droolsjbpm-integration by kiegroup.
the class KieControllerCrashIntegrationTest method testCrashAfterRegistered.
@Test
public void testCrashAfterRegistered() throws Exception {
final String SERVER_TEMPLATE_ID = "template-id";
final String SERVER_NAME = "server-name";
KieServerEnvironment.setServerId(SERVER_TEMPLATE_ID);
ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_NAME);
controllerClient.saveServerTemplate(serverTemplate);
ServerTemplateList instanceList = controllerClient.listServerTemplates();
assertEquals(1, instanceList.getServerTemplates().length);
// Register kie server in controller.
KieServerInfo kieServerInfo = new KieServerInfo(SERVER_TEMPLATE_ID, "1.0.0");
kieServerInfo.setLocation("http://127.0.0.1:20000");
kieServerInfo.setMode(KieServerMode.PRODUCTION);
kieServerInfo.setName(SERVER_NAME);
KieServerRegistry registry = new KieServerRegistryImpl();
KieServerStateRepository dummyKieServerStateRepository = new KieServerStateRepository() {
@Override
public void store(String serverId, KieServerState kieServerState) {
}
@Override
public KieServerState load(String serverId) {
KieServerState kieServerState = new KieServerState();
kieServerState.setControllers(Collections.singleton(TestConfig.getControllerHttpUrl()));
kieServerState.setConfiguration(new KieServerConfig());
if (TestConfig.isLocalServer()) {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, "", null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, "", null));
} else {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, TestConfig.getUsername(), null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, TestConfig.getPassword(), null));
}
return kieServerState;
}
};
registry.registerStateRepository(dummyKieServerStateRepository);
KieServerController controller = new DefaultRestControllerImpl(registry);
controller.connect(kieServerInfo);
// Check that kie server is registered.
serverUp.await(5, TimeUnit.SECONDS);
ServerInstanceKeyList list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
if (list.getServerInstanceKeys().length == 0) {
// Race condition when health check deleted server instance sooner than we were able to check. Resubmitting server instance again.
serverUp = new CountDownLatch(1);
serverDown = new CountDownLatch(1);
controller.connect(kieServerInfo);
serverUp.await(5, TimeUnit.SECONDS);
list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
}
assertNotNull(list.getServerInstanceKeys());
assertEquals(1, list.getServerInstanceKeys().length);
// Check that kie server is deregistered automatically.
serverDown.await(5, TimeUnit.SECONDS);
list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
assertNotNull(list.getServerInstanceKeys());
assertEquals(0, list.getServerInstanceKeys().length);
}
use of org.kie.server.api.model.KieServerConfig in project droolsjbpm-integration by kiegroup.
the class KieControllerValidationIntegrationTest method init.
@Before
public void init() {
dummyKieServerStateRepository = new KieServerStateRepository() {
@Override
public void store(String serverId, KieServerState kieServerState) {
}
@Override
public KieServerState load(String serverId) {
KieServerState kieServerState = new KieServerState();
kieServerState.setControllers(Collections.singleton(TestConfig.getControllerHttpUrl()));
kieServerState.setConfiguration(new KieServerConfig());
if (TestConfig.isLocalServer()) {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, "", null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, "", null));
} else {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, TestConfig.getUsername(), null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, TestConfig.getPassword(), null));
}
return kieServerState;
}
};
registry = new KieServerRegistryImpl();
registry.registerStateRepository(dummyKieServerStateRepository);
}
use of org.kie.server.api.model.KieServerConfig in project droolsjbpm-integration by kiegroup.
the class KeyStoreHelperUtilTest method testConfigPassword.
@Test
public void testConfigPassword() {
final KieServerConfig serverConfig = new KieServerConfig();
final String defaultPassword = "default";
serverConfig.addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, defaultPassword, null));
final String password = loadControllerPassword(serverConfig);
assertEquals(defaultPassword, password);
}
use of org.kie.server.api.model.KieServerConfig in project droolsjbpm-integration by kiegroup.
the class KeyStoreHelperUtilTest method testConfigDefaultPassword.
@Test
public void testConfigDefaultPassword() {
final KieServerConfig serverConfig = new KieServerConfig();
final String password = loadControllerPassword(serverConfig);
assertEquals("kieserver1!", password);
}
use of org.kie.server.api.model.KieServerConfig in project droolsjbpm-integration by kiegroup.
the class KieServerStateTest method testLoadKieServerState.
@Test
public void testLoadKieServerState() {
KieServerStateRepository repository = new KieServerStateFileRepository(REPOSITORY_DIR);
String serverId = UUID.randomUUID().toString();
KieServerState state = repository.load(serverId);
Assert.assertNotNull(state);
KieServerConfig config = state.getConfiguration();
Assert.assertNotNull(config);
Assert.assertNull(config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DIALECT));
Assert.assertNull(config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS));
Assert.assertNull(config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_TM));
System.setProperty(KieServerConstants.CFG_PERSISTANCE_DIALECT, "org.hibernate.dialect.PostgreSQLDialect");
System.setProperty(KieServerConstants.CFG_PERSISTANCE_DS, "jdbc/jbpm");
System.setProperty(KieServerConstants.CFG_PERSISTANCE_TM, "JBossTS");
repository.store(serverId, state);
repository = new KieServerStateFileRepository(REPOSITORY_DIR);
state = repository.load(serverId);
Assert.assertNotNull(state);
config = state.getConfiguration();
Assert.assertNotNull(config);
Assert.assertEquals("org.hibernate.dialect.PostgreSQLDialect", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DIALECT));
Assert.assertEquals("jdbc/jbpm", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS));
Assert.assertEquals("JBossTS", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_TM));
}
Aggregations