ApplicationWsDelegate { public void removeInstance( String applicationName, String instancePath ) { this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...", instancePath, applicationName ) ); WebResource path = this.resource .path( UrlConstants.APP ) .path( applicationName ) .path( "instances" ) .queryParam( "instance-path", instancePath ); this.wsClient.createBuilder( path ).delete(); this.logger.finer( String.format( "Instance \"%s\" has been removed from application \"%s\"", instancePath, applicationName ) ); } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ); void setDescription( String applicationName, String newDesc ); void deployAndStartAll( String applicationName, String instancePath ); void stopAll( String applicationName, String instancePath ); void undeployAll( String applicationName, String instancePath ); List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ); void addInstance( String applicationName, String parentInstancePath, Instance instance ); void removeInstance( String applicationName, String instancePath ); void resynchronize( String applicationName ); List<Component> listAllComponents( String applicationName ); List<Component> findComponentChildren( String applicationName, String componentName ); List<Component> findComponentAncestors( String applicationName, String componentName ); void bindApplication( String applicationName, String boundTplName, String boundApp ); List<String> listAllCommands( String applicationName );  }
@Test public void testRemoveInstance_success() { final String tomcatPath = InstanceHelpers.computeInstancePath( this.app.getTomcat() ); Assert.assertNotNull( InstanceHelpers.findInstanceByPath( this.app, tomcatPath ) ); this.client.getApplicationDelegate().removeInstance( this.app.getName(), tomcatPath ); Assert.assertNull( InstanceHelpers.findInstanceByPath( this.app, tomcatPath ) ); }
@Test public void testRemoveInstance_nonExistingInstance() { try { this.client.getApplicationDelegate().removeInstance( this.app.getName(), "/I-do-not-exist" ); Assert.fail( "Expecting exception" ); } catch ( UniformInterfaceException e ) { Assert.assertEquals( 404, e.getResponse().getStatus() ); } }
@Test public void testRemoveInstance_nonExistingApplication() { try { this.client.getApplicationDelegate().removeInstance( "I-am-not-an-app", InstanceHelpers.computeInstancePath( this.app.getTomcat() ) ); Assert.fail( "Expecting exception" ); } catch ( UniformInterfaceException e ) { Assert.assertEquals( 404, e.getResponse().getStatus() ); } }