Search in sources :

Example 6 with InstancesMBeanImpl

use of org.apache.karaf.instance.core.internal.InstancesMBeanImpl in project karaf by apache.

the class InstanceServiceMBeanImplTest method testChangeOptions.

public void testChangeOptions() throws Exception {
    Instance inst = EasyMock.createMock(Instance.class);
    inst.changeJavaOpts("new opts");
    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.changeJavaOpts("test instance", "new opts");
    EasyMock.verify(instanceService);
    EasyMock.verify(inst);
}
Also used : Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) InstancesMBean(org.apache.karaf.instance.core.InstancesMBean) InstanceService(org.apache.karaf.instance.core.InstanceService)

Example 7 with InstancesMBeanImpl

use of org.apache.karaf.instance.core.internal.InstancesMBeanImpl in project karaf by apache.

the class InstanceServiceMBeanImplTest method testStartInstanceWithNoJavaOpts.

public void testStartInstanceWithNoJavaOpts() throws Exception {
    Instance inst = EasyMock.createMock(Instance.class);
    inst.start(null);
    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.startInstance("test instance", null);
    EasyMock.verify(instanceService);
    EasyMock.verify(inst);
}
Also used : Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) InstancesMBean(org.apache.karaf.instance.core.InstancesMBean) InstanceService(org.apache.karaf.instance.core.InstanceService)

Example 8 with InstancesMBeanImpl

use of org.apache.karaf.instance.core.internal.InstancesMBeanImpl in project karaf by apache.

the class InstanceServiceMBeanImplTest method testGetInstances.

public void testGetInstances() throws Exception {
    Instance i1 = EasyMock.createMock(Instance.class);
    EasyMock.expect(i1.getPid()).andReturn(1234);
    EasyMock.expect(i1.getSshPort()).andReturn(8818);
    EasyMock.expect(i1.getSshHost()).andReturn("0.0.0.0");
    EasyMock.expect(i1.getRmiRegistryPort()).andReturn(1122);
    EasyMock.expect(i1.getRmiRegistryHost()).andReturn("0.0.0.0");
    EasyMock.expect(i1.getRmiServerPort()).andReturn(44444);
    EasyMock.expect(i1.getRmiServerHost()).andReturn("0.0.0.0");
    EasyMock.expect(i1.getName()).andReturn("i1");
    EasyMock.expect(i1.isRoot()).andReturn(true);
    EasyMock.expect(i1.getLocation()).andReturn("somewhere");
    EasyMock.expect(i1.getJavaOpts()).andReturn("someopts");
    EasyMock.expect(i1.getState()).andReturn("Stopped");
    EasyMock.replay(i1);
    Instance i2 = EasyMock.createNiceMock(Instance.class);
    EasyMock.expect(i2.getName()).andReturn("i2");
    EasyMock.replay(i2);
    InstanceService instanceService = EasyMock.createMock(InstanceService.class);
    EasyMock.expect(instanceService.getInstances()).andReturn(new Instance[] { i1, i2 });
    EasyMock.replay(instanceService);
    InstancesMBeanImpl instanceServiceMBean = new InstancesMBeanImpl(instanceService);
    TabularData tabularData = instanceServiceMBean.getInstances();
    Assert.assertEquals(2, tabularData.size());
    CompositeData cd1 = tabularData.get(new Object[] { "i1" });
    Assert.assertTrue(cd1.containsValue("i1"));
    Assert.assertTrue(cd1.containsValue(true));
    Assert.assertTrue(cd1.containsValue(1234));
    Assert.assertTrue(cd1.containsValue(8818));
    Assert.assertTrue(cd1.containsValue(1122));
    Assert.assertTrue(cd1.containsValue(44444));
    Assert.assertTrue(cd1.containsValue("0.0.0.0"));
    Assert.assertTrue(cd1.containsValue("somewhere"));
    Assert.assertTrue(cd1.containsValue("someopts"));
    Assert.assertTrue(cd1.containsValue("Stopped"));
    CompositeData cd2 = tabularData.get(new Object[] { "i2" });
    Assert.assertTrue(cd2.containsValue("i2"));
}
Also used : Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) CompositeData(javax.management.openmbean.CompositeData) InstanceService(org.apache.karaf.instance.core.InstanceService) TabularData(javax.management.openmbean.TabularData)

Example 9 with InstancesMBeanImpl

use of org.apache.karaf.instance.core.internal.InstancesMBeanImpl in project karaf by apache.

the class InstanceServiceMBeanImplTest method testRmiRegistryChangePort.

public void testRmiRegistryChangePort() throws Exception {
    Instance inst = EasyMock.createMock(Instance.class);
    inst.changeRmiRegistryPort(1123);
    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.changeRmiRegistryPort("test instance", 1123);
    EasyMock.verify(instanceService);
    EasyMock.verify(inst);
}
Also used : Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) InstancesMBean(org.apache.karaf.instance.core.InstancesMBean) InstanceService(org.apache.karaf.instance.core.InstanceService)

Example 10 with InstancesMBeanImpl

use of org.apache.karaf.instance.core.internal.InstancesMBeanImpl in project karaf by apache.

the class InstanceServiceMBeanImplTest method testStartInstanceWithJavaOpts.

public void testStartInstanceWithJavaOpts() throws Exception {
    Instance inst = EasyMock.createMock(Instance.class);
    inst.start("-x -y -z");
    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.startInstance("test instance", "-x -y -z");
    EasyMock.verify(instanceService);
    EasyMock.verify(inst);
}
Also used : Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) InstancesMBean(org.apache.karaf.instance.core.InstancesMBean) InstanceService(org.apache.karaf.instance.core.InstanceService)

Aggregations

InstanceService (org.apache.karaf.instance.core.InstanceService)12 InstancesMBeanImpl (org.apache.karaf.instance.core.internal.InstancesMBeanImpl)12 Instance (org.apache.karaf.instance.core.Instance)10 InstancesMBean (org.apache.karaf.instance.core.InstancesMBean)9 InstanceSettings (org.apache.karaf.instance.core.InstanceSettings)2 CompositeData (javax.management.openmbean.CompositeData)1 TabularData (javax.management.openmbean.TabularData)1 InstanceServiceImpl (org.apache.karaf.instance.core.internal.InstanceServiceImpl)1 RegexCommandLoggingFilter (org.apache.karaf.shell.support.RegexCommandLoggingFilter)1