Search in sources :

Example 1 with InstanceService

use of org.apache.karaf.instance.core.InstanceService in project karaf by apache.

the class Activator method doStart.

@Override
protected void doStart() throws Exception {
    InstanceService instanceService = new InstanceServiceImpl();
    register(InstanceService.class, instanceService);
    RegexCommandLoggingFilter filter = new RegexCommandLoggingFilter();
    filter.addCommandOption("--password", "connect");
    filter.addCommandOption("-p", "connect");
    register(CommandLoggingFilter.class, filter);
    InstancesMBeanImpl mbean = new InstancesMBeanImpl(instanceService);
    registerMBean(mbean, "type=instance");
}
Also used : InstanceServiceImpl(org.apache.karaf.instance.core.internal.InstanceServiceImpl) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl) RegexCommandLoggingFilter(org.apache.karaf.shell.support.RegexCommandLoggingFilter) InstanceService(org.apache.karaf.instance.core.InstanceService)

Example 2 with InstanceService

use of org.apache.karaf.instance.core.InstanceService in project karaf by apache.

the class CreateCommandTest method testCreateCommandExecute.

public void testCreateCommandExecute() throws Exception {
    InstanceService instanceService = EasyMock.createMock(InstanceService.class);
    EasyMock.replay(instanceService);
    CreateCommand cc = new CreateCommand();
    cc.setInstanceService(instanceService);
    cc.sshPort = 9941;
    cc.rmiRegistryPort = 1122;
    cc.rmiServerPort = 44444;
    cc.location = "top";
    cc.javaOpts = "foo";
    cc.features = new ArrayList<>(Arrays.asList("abc", "def"));
    cc.featureURLs = new ArrayList<>(Arrays.asList("http://something"));
    cc.instance = "myInstance";
    cc.verbose = true;
    // Create the features config file used
    System.setProperty("karaf.etc", "target/etc");
    File cfgFile = new File("target/etc/" + CreateCommand.FEATURES_SERVICE_CONFIG_FILE);
    cfgFile.getParentFile().mkdirs();
    cfgFile.createNewFile();
    // check precondition
    EasyMock.verify(instanceService);
    EasyMock.reset(instanceService);
    InstanceSettings expectedIS = new InstanceSettings(9941, 1122, 44444, "top", "foo", Collections.singletonList("http://something"), Arrays.asList("abc", "def"));
    EasyMock.expect(instanceService.createInstance("myInstance", expectedIS, true)).andReturn(null);
    EasyMock.replay(instanceService);
    cc.doExecute();
    EasyMock.verify(instanceService);
}
Also used : InstanceSettings(org.apache.karaf.instance.core.InstanceSettings) InstanceService(org.apache.karaf.instance.core.InstanceService) File(java.io.File)

Example 3 with InstanceService

use of org.apache.karaf.instance.core.InstanceService 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);
}
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 4 with InstanceService

use of org.apache.karaf.instance.core.InstanceService 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", ""));
}
Also used : InstanceSettings(org.apache.karaf.instance.core.InstanceSettings) InstanceService(org.apache.karaf.instance.core.InstanceService) Instance(org.apache.karaf.instance.core.Instance) InstancesMBeanImpl(org.apache.karaf.instance.core.internal.InstancesMBeanImpl)

Example 5 with InstanceService

use of org.apache.karaf.instance.core.InstanceService 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);
}
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)14 InstancesMBeanImpl (org.apache.karaf.instance.core.internal.InstancesMBeanImpl)12 Instance (org.apache.karaf.instance.core.Instance)11 InstancesMBean (org.apache.karaf.instance.core.InstancesMBean)9 InstanceSettings (org.apache.karaf.instance.core.InstanceSettings)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 HashMap (java.util.HashMap)1 CompositeData (javax.management.openmbean.CompositeData)1 TabularData (javax.management.openmbean.TabularData)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 InstanceServiceImpl (org.apache.karaf.instance.core.internal.InstanceServiceImpl)1 RegexCommandLoggingFilter (org.apache.karaf.shell.support.RegexCommandLoggingFilter)1