import org.apache.felix.karaf.admin.InstanceSettings;
import org.easymock.EasyMock;
public class CreateCommandTest extends TestCase {
public void testCreateCommandExecute() throws Exception {
AdminService adminService = EasyMock.createMock(AdminService.class);
EasyMock.replay(adminService);
CreateCommand cc = new CreateCommand();
cc.setAdminService(adminService);
cc.port = 9941;
cc.location = "top";
cc.features = Arrays.asList("abc", "def");
cc.featureURLs = Collections.singletonList("http://something");
cc.instance = "myInstance";
EasyMock.verify(adminService); // check precondition
EasyMock.reset(adminService);
InstanceSettings expectedIS =
new InstanceSettings(9941, "top", Collections.singletonList("http://something"), Arrays.asList("abc", "def"));
EasyMock.expect(adminService.createInstance("myInstance", expectedIS)).andReturn(null);
EasyMock.replay(adminService);
cc.doExecute();
EasyMock.verify(adminService);
}