@Test
public void testParsingWithInstancesAndComponentExtensions() throws Exception {

	File dir = TestUtils.findApplicationDirectory( "component-extensions" );
	Assert.assertTrue( dir.isDirectory());
	ApplicationLoadResult alr = RuntimeModelIo.loadApplication( dir );
	Assert.assertFalse( RoboconfErrorHelpers.containsCriticalErrors( alr.getLoadErrors()));
	// Ambiguous overriding with multiple inheritance
	Instance ambiguous = InstanceHelpers.findInstanceByPath( alr.getApplicationTemplate(), "/container-bootstrap-vm/ambiguous" );
	Assert.assertNotNull( ambiguous );
	Map<String,String> exportedVariables = InstanceHelpers.findAllExportedVariables( ambiguous );
	Assert.assertEquals( 9, exportedVariables.size());
	Assert.assertEquals( "petals-sl-postgresql-9.4-1201-jdbc4", exportedVariables.get( "PetalsJBIComponent.componentId" ));
	Assert.assertEquals( "petals-sl-postgresql-9.4-1201-jdbc4", exportedVariables.get( "PetalsSL.componentId" ));
	Assert.assertEquals( "petals-sl-postgresql-9.4-1201-jdbc4", exportedVariables.get( "PetalsSLPostgreSQL.componentId" ));
	Assert.assertEquals( "petals-sl-postgresql-9.4-1201-jdbc4", exportedVariables.get( "componentId" ));
	Assert.assertEquals( "SL", exportedVariables.get( "PetalsSL.componentType" ));
	Assert.assertEquals( "SL", exportedVariables.get( "PetalsSLPostgreSQL.componentType" ));
	Assert.assertEquals( "true", exportedVariables.get( "PetalsSLPostgreSQL.present" ));
	Assert.assertEquals( "roboconf-demo", exportedVariables.get( "domainName" ));
	Assert.assertEquals( "roboconf-demo-1", exportedVariables.get( "subdomainName" ));
	// Specific overriding with multiple inheritance
	Instance specific = InstanceHelpers.findInstanceByPath( alr.getApplicationTemplate(), "/container-bootstrap-vm/specific" );
	Assert.assertNotNull( specific );
	exportedVariables = InstanceHelpers.findAllExportedVariables( specific );
	Assert.assertEquals( 7, exportedVariables.size());
	Assert.assertEquals( "comp", exportedVariables.get( "PetalsJBIComponent.componentId" ));
	Assert.assertEquals( "sl", exportedVariables.get( "PetalsSL.componentId" ));
	Assert.assertEquals( "last", exportedVariables.get( "PetalsSLPostgreSQL.componentId" ));
	Assert.assertNull( exportedVariables.get( "componentId" ));
	Assert.assertEquals( "SL", exportedVariables.get( "PetalsSL.componentType" ));
	Assert.assertEquals( "SL", exportedVariables.get( "PetalsSLPostgreSQL.componentType" ));
	Assert.assertEquals( "true", exportedVariables.get( "PetalsSLPostgreSQL.present" ));
	Assert.assertEquals( "roboconf-demo", exportedVariables.get( "domainName" ));
	Assert.assertNull( exportedVariables.get( "subdomainName" ));
	// Instance from a super component
	Instance superInstance = InstanceHelpers.findInstanceByPath( alr.getApplicationTemplate(), "/container-bootstrap-vm/superInstance" );
	Assert.assertNotNull( superInstance );
	exportedVariables = InstanceHelpers.findAllExportedVariables( superInstance );
	Assert.assertEquals( 4, exportedVariables.size());
	Assert.assertEquals( "my-sl", exportedVariables.get( "PetalsJBIComponent.componentId" ));
	Assert.assertEquals( "my-sl", exportedVariables.get( "PetalsSL.componentId" ));
	Assert.assertEquals( "my-sl", exportedVariables.get( "componentId" ));
	Assert.assertEquals( "SL", exportedVariables.get( "PetalsSL.componentType" ));
	Assert.assertNull( exportedVariables.get( "PetalsSLPostgreSQL.componentId" ));
	Assert.assertNull( exportedVariables.get( "domainName" ));
	Assert.assertNull( exportedVariables.get( "subdomainName" ));
}