OpenstackIaasHandler extends AbstractThreadedTargetHandler { static void validate( Map<String,String> targetProperties ) throws TargetException { checkProperty( API_URL, targetProperties ); checkProperty( IMAGE_NAME, targetProperties ); checkProperty( TENANT_NAME, targetProperties ); checkProperty( FLAVOR_NAME, targetProperties ); checkProperty( SECURITY_GROUP, targetProperties ); checkProperty( KEY_PAIR, targetProperties ); checkProperty( USER, targetProperties ); checkProperty( PASSWORD, targetProperties ); }  @Override String getTargetId(); @Override String createMachine( TargetHandlerParameters parameters ); @Override boolean isMachineRunning( TargetHandlerParameters parameters, String machineId ); @Override MachineConfigurator machineConfigurator( TargetHandlerParameters parameters, String machineId ); @Override void terminateMachine( TargetHandlerParameters parameters, String machineId ); @Override String retrievePublicIpAddress( TargetHandlerParameters parameters, String machineId ); static final String TARGET_ID; }
@Test public void testValidate() throws Exception { Map<String,String> targetProperties = new HashMap<>(); targetProperties.put( FLAVOR_NAME, UUID.randomUUID().toString()); targetProperties.put( TENANT_NAME, UUID.randomUUID().toString()); targetProperties.put( IMAGE_NAME, UUID.randomUUID().toString()); targetProperties.put( SECURITY_GROUP, UUID.randomUUID().toString()); targetProperties.put( USER, UUID.randomUUID().toString()); targetProperties.put( PASSWORD, UUID.randomUUID().toString()); targetProperties.put( KEY_PAIR, UUID.randomUUID().toString()); targetProperties.put( API_URL, UUID.randomUUID().toString()); validate( targetProperties ); targetProperties.put( FLOATING_IP_POOL, UUID.randomUUID().toString()); targetProperties.put( NETWORK_ID, UUID.randomUUID().toString()); validate( targetProperties ); }
@Test( expected = TargetException.class ) public void testValidate_error1() throws Exception { Map<String,String> targetProperties = new HashMap<>(); targetProperties.put( FLAVOR_NAME, UUID.randomUUID().toString()); targetProperties.put( IMAGE_NAME, UUID.randomUUID().toString()); targetProperties.put( SECURITY_GROUP, UUID.randomUUID().toString()); targetProperties.put( USER, UUID.randomUUID().toString()); targetProperties.put( PASSWORD, UUID.randomUUID().toString()); targetProperties.put( KEY_PAIR, UUID.randomUUID().toString()); targetProperties.put( API_URL, UUID.randomUUID().toString()); validate( targetProperties ); }
@Test( expected = TargetException.class ) public void testValidate_error2() throws Exception { validate( new HashMap<String,String>( 0 )); }
@Test( expected = TargetException.class ) public void testValidate_error3() throws Exception { Map<String,String> targetProperties = new HashMap<>(); targetProperties.put( FLAVOR_NAME, "" ); targetProperties.put( TENANT_NAME, UUID.randomUUID().toString()); targetProperties.put( IMAGE_NAME, UUID.randomUUID().toString()); targetProperties.put( SECURITY_GROUP, UUID.randomUUID().toString()); targetProperties.put( USER, UUID.randomUUID().toString()); targetProperties.put( PASSWORD, UUID.randomUUID().toString()); targetProperties.put( KEY_PAIR, UUID.randomUUID().toString()); targetProperties.put( API_URL, UUID.randomUUID().toString()); validate( targetProperties ); }