@Test
public void testComponent() {

	Component comp = new Component();
	Iterator<ModelError> iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_EMPTY_COMPONENT_NAME, iterator.next().getErrorCode());
	Assert.assertEquals( ErrorCode.RM_EMPTY_COMPONENT_INSTALLER, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setName( "my # component" );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_INVALID_COMPONENT_NAME, iterator.next().getErrorCode());
	Assert.assertEquals( ErrorCode.RM_EMPTY_COMPONENT_INSTALLER, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setName( "my.component" );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_DOT_IS_NOT_ALLOWED, iterator.next().getErrorCode());
	Assert.assertEquals( ErrorCode.RM_EMPTY_COMPONENT_INSTALLER, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setName( "comp" );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_EMPTY_COMPONENT_INSTALLER, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setInstallerName( "my installer !!" );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_INVALID_COMPONENT_INSTALLER, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setInstallerName( "my installer" );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_ROOT_INSTALLER_MUST_BE_TARGET, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.setInstallerName( Constants.TARGET_INSTALLER );
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
	comp.associateFacet( new Facet( "" ));
	Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
	iterator = RuntimeModelValidator.validate( comp.getFacets().iterator().next()).iterator();
	Assert.assertEquals( ErrorCode.RM_EMPTY_FACET_NAME, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.disassociateFacet( comp.getFacets().iterator().next());
	comp.associateFacet( new Facet( "!nvalid-facet-n@me" ));
	Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
	iterator = RuntimeModelValidator.validate( comp.getFacets().iterator().next()).iterator();
	Assert.assertEquals( ErrorCode.RM_INVALID_FACET_NAME, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.disassociateFacet( comp.getFacets().iterator().next());
	Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
	comp.addExportedVariable( new ExportedVariable( "comp.ip", null ));
	comp.addExportedVariable( new ExportedVariable( "comp.port", "9000" ));
	comp.addImportedVariable( new ImportedVariable( "comp.ip", false, false ));
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_COMPONENT_IMPORTS_EXPORTS, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.addImportedVariable( new ImportedVariable( "comp.ip", true, false ));
	Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
	comp.addImportedVariable( new ImportedVariable( "", false, false ));
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_EMPTY_VARIABLE_NAME, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.importedVariables.clear();
	comp.addImportedVariable( new ImportedVariable( "comp.inva!id", false, false ));
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertEquals( ErrorCode.RM_INVALID_VARIABLE_NAME, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp.importedVariables.clear();
	comp.addExportedVariable( new ExportedVariable( "toto", "" ));
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertFalse( iterator.hasNext());
	comp.exportedVariables.clear();
	comp.addExportedVariable( new ExportedVariable( "toto.ip", "" ));
	iterator = RuntimeModelValidator.validate( comp ).iterator();
	Assert.assertFalse( iterator.hasNext());
	comp.exportedVariables.clear();
}