@Test
public void testAnalyzeOverriddenExport() {

	Component tomcatComponent = new Component( "Tomcat" ).installerName( "puppet" );
	tomcatComponent.addExportedVariable( new ExportedVariable( "Tomcat.ip", null ));
	tomcatComponent.addExportedVariable( new ExportedVariable( "Tomcat.port", "8080" ));
	Instance tomcatInstance = new Instance( "tomcat" ).component( tomcatComponent );
	Collection<ModelError> errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
	tomcatInstance.overriddenExports.put( "Tomcat.port", "whatever" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
	tomcatInstance.overriddenExports.put( "oops", "whatever" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 1, errors.size());
	Assert.assertEquals( ErrorCode.RM_MAGIC_INSTANCE_VARIABLE, errors.iterator().next().getErrorCode());
	tomcatInstance.overriddenExports.remove( "oops" );
	tomcatInstance.overriddenExports.put( "port", "whatever" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
	tomcatInstance.overriddenExports.remove( "Tomcat.port" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
	Facet facet = new Facet( "facet" );
	facet.addExportedVariable( new ExportedVariable( "ip", null ));
	tomcatComponent.associateFacet( facet );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
	tomcatInstance.overriddenExports.put( "ip", "localhost" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 1, errors.size());
	Assert.assertEquals( ErrorCode.RM_AMBIGUOUS_OVERRIDING, errors.iterator().next().getErrorCode());
	tomcatInstance.overriddenExports.remove( "ip" );
	tomcatInstance.overriddenExports.put( "facet.ip", "localhost" );
	errors = RuntimeModelValidator.validate( tomcatInstance );
	Assert.assertEquals( 0, errors.size());
}