Package org.apache.karaf.instance.core

Examples of org.apache.karaf.instance.core.Instance


        EasyMock.verify(instanceService);
        EasyMock.verify(inst);
    }

    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);
View Full Code Here


import org.easymock.EasyMock;
import org.junit.Assert;

public class InstanceToTableMapperTest extends TestCase {
    public void testJMXInstance() 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(false);
        EasyMock.expect(instance.getSshPort()).andReturn(0);
        EasyMock.expect(instance.getRmiRegistryPort()).andReturn(0);
        EasyMock.expect(instance.getRmiServerPort()).andReturn(0);
        EasyMock.expect(instance.getState()).andThrow(new Exception("gotcha"));
        EasyMock.expect(instance.getLocation()).andReturn("somewhere");
        EasyMock.expect(instance.getJavaOpts()).andReturn("someopts");
        EasyMock.replay(instance);
       
        TabularData td = InstanceToTableMapper.tableFrom(Collections.singletonList(instance));
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
        Assert.assertEquals("MyInstance", keys.iterator().next());
View Full Code Here

        Assert.assertEquals("somewhere", cd.get("Location"));
        Assert.assertEquals("someopts", cd.get("JavaOpts"));
    }

    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.getRmiRegistryPort()).andReturn(0);
        EasyMock.expect(instance.getRmiServerPort()).andReturn(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());
View Full Code Here

    public void setInstanceService(InstanceService instanceService) {
        this.instanceService = instanceService;
    }

    protected Instance getExistingInstance(String name) {
        Instance i = instanceService.getInstance(name);
        if (i == null) {
            throw new IllegalArgumentException("Instances '" + name + "' does not exist");
        }
        return i;
    }
View Full Code Here

    static final String DEBUG_OPTS = " -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005";
    static final String DEFAULT_OPTS = "-server -Xmx512M -Dcom.sun.management.jmxremote";

    protected Object doExecute() throws Exception {
        Instance child = getExistingInstance(instance);
        String opts = javaOpts;
        if (opts == null) {
            opts = child.getJavaOpts();
        }
        if (opts == null) {
            opts = DEFAULT_OPTS;
        }
        if (debug) {
            opts += DEBUG_OPTS;
        }
        if (wait) {
            String state = child.getState();
            if (Instance.STOPPED.equals(state)) {
                child.start(opts);
            }
            if (!Instance.STARTED.equals(state)) {
                do {
                    Thread.sleep(500);
                    state = child.getState();
                } while (Instance.STARTING.equals(state));
            }
        } else {
            child.start(opts);
        }
        return null;
    }
View Full Code Here

    public void testConfigurationFiles() throws Exception {
        InstanceServiceImpl service = new InstanceServiceImpl();
        service.setStorageLocation(tempFolder.newFolder("instances"));

        InstanceSettings settings = new InstanceSettings(8122, 1122, 44444, getName(), null, null, null);
        Instance instance = service.createInstance(getName(), settings, true);

        assertFileExists(instance.getLocation(), "etc/config.properties");
        assertFileExists(instance.getLocation(), "etc/users.properties");
        assertFileExists(instance.getLocation(), "etc/startup.properties");

        assertFileExists(instance.getLocation(), "etc/java.util.logging.properties");
        assertFileExists(instance.getLocation(), "etc/org.apache.karaf.features.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.felix.fileinstall-deploy.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.karaf.log.cfg");
        assertFileExists(instance.getLocation(), "etc/org.apache.karaf.management.cfg");
        assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.logging.cfg");
        assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.url.mvn.cfg");
    }
View Full Code Here

    @Argument(index = 0, name = "name", description = "The name of the instance", required = true, multiValued = false)
    private String name;

    protected Object doExecute() throws Exception {
        Instance instance = getExistingInstance(name);
        System.out.println(instance.getState());
        return null;
    }
View Full Code Here

    public void testCreateInstance() throws Exception {
        final InstanceSettings instanceSettings = new InstanceSettings(123, 456,789, "somewhere", "someopts",
                Collections.<String>emptyList(), Arrays.asList("webconsole", "funfeat"));
       
        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);
View Full Code Here

        InstancesMBean ab = new InstancesMBeanImpl(instanceService);
        assertEquals(-1, ab.createInstance("t1", 0, 0, 0, "", "", "", ""));
    }
   
    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.getRmiRegistryPort()).andReturn(1122);
        EasyMock.expect(i1.getRmiServerPort()).andReturn(44444);
        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);
View Full Code Here

        CompositeData cd2 = tabularData.get(new Object [] {"i2"});
        Assert.assertTrue(cd2.containsValue("i2"));
    }
   
    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);
View Full Code Here

TOP

Related Classes of org.apache.karaf.instance.core.Instance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.