@Test
public void testListApplicationTemplates() throws Exception {

	// Prepare
	List<ApplicationTemplate> templates = this.client.getManagementDelegate().listApplicationTemplates();
	Assert.assertNotNull( templates );
	Assert.assertEquals( 0, templates.size());
	TestApplicationTemplate tpl = new TestApplicationTemplate();
	this.managerWrapper.getApplicationTemplates().put( tpl, Boolean.TRUE );
	// Get ALL the templates
	templates = this.client.getManagementDelegate().listApplicationTemplates();
	Assert.assertNotNull( templates );
	Assert.assertEquals( 1, templates.size());
	ApplicationTemplate receivedTpl = templates.get( 0 );
	Assert.assertEquals( tpl.getName(), receivedTpl.getName());
	Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription());
	Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion());
	// Get the "filter" template
	templates = this.client.getManagementDelegate().listApplicationTemplates( "filter", null );
	Assert.assertNotNull( templates );
	Assert.assertEquals( 0, templates.size());
	// Get the test template with no specific qualifier
	templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName(), null );
	Assert.assertNotNull( templates );
	Assert.assertEquals( 1, templates.size());
	receivedTpl = templates.get( 0 );
	Assert.assertEquals( tpl.getName(), receivedTpl.getName());
	Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription());
	Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion());
	// Get the test template with the exact qualifier
	templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName(), tpl.getVersion());
	Assert.assertNotNull( templates );
	Assert.assertEquals( 1, templates.size());
	receivedTpl = templates.get( 0 );
	Assert.assertEquals( tpl.getName(), receivedTpl.getName());
	Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription());
	Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion());
	// Get the test template with the exact qualifier but no specific name
	templates = this.client.getManagementDelegate().listApplicationTemplates( null, tpl.getVersion());
	Assert.assertNotNull( templates );
	Assert.assertEquals( 1, templates.size());
	receivedTpl = templates.get( 0 );
	Assert.assertEquals( tpl.getName(), receivedTpl.getName());
	Assert.assertEquals( tpl.getDescription(), receivedTpl.getDescription());
	Assert.assertEquals( tpl.getVersion(), receivedTpl.getVersion());
	// Invalid qualifier
	templates = this.client.getManagementDelegate().listApplicationTemplates( null, tpl.getVersion() + "2" );
	Assert.assertNotNull( templates );
	Assert.assertEquals( 0, templates.size());
	// Invalid name
	templates = this.client.getManagementDelegate().listApplicationTemplates( tpl.getName() + "1", null );
	Assert.assertNotNull( templates );
	Assert.assertEquals( 0, templates.size());
}