ApplicationWsDelegate { public void bindApplication( String applicationName, String boundTplName, String boundApp ) throws ApplicationWsException { this.logger.finer( "Creating a binding for external exports in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "bind" ) .queryParam( "bound-tpl", boundTplName ) .queryParam( "bound-app", boundApp ); ClientResponse response = this.wsClient.createBuilder( path ).post( ClientResponse.class ); handleResponse( response ); } 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( expected = ApplicationWsException.class ) public void testBindApplication_inexistingApplication() throws Exception { this.client.getApplicationDelegate().bindApplication( "inexisting", this.ma.getApplication().getTemplate().getName(), this.ma.getName()); }
@Test( expected = ApplicationWsException.class ) public void testBindApplication_invalidBoundApplication() throws Exception { this.client.getApplicationDelegate().bindApplication( this.ma.getName(), this.ma.getApplication().getTemplate().getName(), "invalid" ); }
@Test( expected = ApplicationWsException.class ) public void testBindApplication_invalidBoundTemplate() throws Exception { TestApplication app2 = new TestApplication(); app2.setDirectory( this.folder.newFolder()); app2.getTemplate().setName( "tpl-other" ); app2.setName( "app-other" ); this.managerWrapper.addManagedApplication( new ManagedApplication( app2 )); this.client.getApplicationDelegate().bindApplication( this.ma.getName(), this.ma.getApplication().getTemplate().getName(), app2.getName()); }
@Test public void testBindApplication_success() throws Exception { TestApplication app2 = new TestApplication(); app2.setDirectory( this.folder.newFolder()); app2.getTemplate().setName( "tpl-other" ); app2.getTemplate().setExternalExportsPrefix( "eep" ); app2.setName( "app-other" ); this.managerWrapper.addManagedApplication( new ManagedApplication( app2 )); Assert.assertEquals( 0, this.msgClient.allSentMessages.size()); Assert.assertEquals( 0, this.ma.removeAwaitingMessages( this.app.getTomcatVm()).size()); Assert.assertEquals( 0, this.ma.removeAwaitingMessages( this.app.getMySqlVm()).size()); this.client.getApplicationDelegate().bindApplication( this.ma.getName(), app2.getTemplate().getExternalExportsPrefix(), app2.getName()); Assert.assertEquals( 0, this.msgClient.allSentMessages.size()); List<Message> messages = this.ma.removeAwaitingMessages( this.app.getTomcatVm()); Assert.assertEquals( 1, messages.size()); messages.addAll( this.ma.removeAwaitingMessages( this.app.getMySqlVm())); Assert.assertEquals( 2, messages.size()); for( Message m : this.msgClient.allSentMessages ) { Assert.assertEquals( MsgCmdChangeBinding.class, m.getClass()); MsgCmdChangeBinding msg = (MsgCmdChangeBinding) m; Assert.assertEquals( app2.getTemplate().getExternalExportsPrefix(), msg.getExternalExportsPrefix()); Assert.assertNotNull( msg.getAppNames()); Assert.assertEquals( 1, msg.getAppNames().size()); Assert.assertTrue( msg.getAppNames().contains( app2.getName())); } }