use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testSshChangePort.
public void testSshChangePort() throws Exception {
Instance inst = EasyMock.createMock(Instance.class);
inst.changeSshPort(7788);
EasyMock.expectLastCall();
EasyMock.replay(inst);
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBean instanceServiceMBean = new InstancesMBeanImpl(instanceService);
instanceServiceMBean.changeSshPort("test instance", 7788);
EasyMock.verify(instanceService);
EasyMock.verify(inst);
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testCreateInstance.
public void testCreateInstance() throws Exception {
final InstanceSettings instanceSettings = new InstanceSettings(123, 456, 789, "somewhere", "someopts", Collections.emptyList(), Arrays.asList("webconsole", "funfeat"), "localhost");
final Instance inst = EasyMock.createMock(Instance.class);
EasyMock.expect(inst.getPid()).andReturn(42);
EasyMock.replay(inst);
org.apache.karaf.instance.core.InstanceService instanceService = EasyMock.createMock(org.apache.karaf.instance.core.InstanceService.class);
EasyMock.expect(instanceService.createInstance("t1", instanceSettings, false)).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBeanImpl ab = new InstancesMBeanImpl(instanceService);
assertEquals(42, ab.createInstance("t1", 123, 456, 789, "somewhere", "someopts", " webconsole, funfeat", ""));
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceMBeanImplTest method testRmiServerChangePort.
public void testRmiServerChangePort() throws Exception {
Instance inst = EasyMock.createMock(Instance.class);
inst.changeRmiServerPort(44444);
EasyMock.expectLastCall();
EasyMock.replay(inst);
InstanceService instanceService = EasyMock.createMock(InstanceService.class);
EasyMock.expect(instanceService.getInstance("test instance")).andReturn(inst);
EasyMock.replay(instanceService);
InstancesMBean instanceServiceMBean = new InstancesMBeanImpl(instanceService);
instanceServiceMBean.changeRmiServerPort("test instance", 44444);
EasyMock.verify(instanceService);
EasyMock.verify(inst);
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceToTableMapperTest method testJMXInstance2.
public void testJMXInstance2() throws Exception {
Instance instance = EasyMock.createMock(Instance.class);
EasyMock.expect(instance.getPid()).andReturn(1712);
EasyMock.expect(instance.getName()).andReturn("MyInstance");
EasyMock.expect(instance.isRoot()).andReturn(true);
EasyMock.expect(instance.getSshPort()).andReturn(0);
EasyMock.expect(instance.getSshHost()).andReturn("0.0.0.0");
EasyMock.expect(instance.getRmiRegistryPort()).andReturn(0);
EasyMock.expect(instance.getRmiRegistryHost()).andReturn("0.0.0.0");
EasyMock.expect(instance.getRmiServerPort()).andReturn(0);
EasyMock.expect(instance.getRmiServerHost()).andReturn("0.0.0.0");
EasyMock.expect(instance.getState()).andReturn("Started");
EasyMock.expect(instance.getLocation()).andReturn(null);
EasyMock.expect(instance.getJavaOpts()).andReturn(null);
EasyMock.replay(instance);
TabularData td = InstanceToTableMapper.tableFrom(Collections.singletonList(instance));
Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
Assert.assertEquals("MyInstance", keys.iterator().next());
CompositeData cd = td.get(keys.toArray());
Assert.assertEquals(1712, cd.get("Pid"));
Assert.assertEquals("MyInstance", cd.get("Name"));
Assert.assertEquals(true, cd.get("Is Root"));
Assert.assertEquals(0, cd.get("SSH Port"));
Assert.assertEquals("0.0.0.0", cd.get("SSH Host"));
Assert.assertEquals(0, cd.get("RMI Registry Port"));
Assert.assertEquals("0.0.0.0", cd.get("RMI Registry Host"));
Assert.assertEquals(0, cd.get("RMI Server Port"));
Assert.assertEquals("0.0.0.0", cd.get("RMI Server Host"));
Assert.assertEquals("Started", cd.get("State"));
Assert.assertNull(cd.get("Location"));
Assert.assertNull(cd.get("JavaOpts"));
}
use of org.apache.karaf.instance.core.Instance in project karaf by apache.
the class InstanceServiceImplTest method testTextResources.
public void testTextResources() throws Exception {
InstanceServiceImpl service = new InstanceServiceImpl();
service.setStorageLocation(new File("target/instances/" + System.currentTimeMillis()));
Map<String, URL> textResources = new HashMap<>();
textResources.put("etc/myresource", getClass().getClassLoader().getResource("myresource"));
InstanceSettings settings = new InstanceSettings(8122, 1122, 44444, getName(), null, null, null, null, textResources, new HashMap<>());
Instance instance = service.createInstance(getName(), settings, false);
assertFileExists(instance.getLocation(), "etc/myresource");
}
Aggregations