JCloudsHandler implements TargetHandler { static void validate( Map<String,String> targetProperties ) throws TargetException { checkProperty( PROVIDER_ID, targetProperties ); checkProperty( ENDPOINT, targetProperties ); checkProperty( IMAGE_NAME, targetProperties ); checkProperty( SECURITY_GROUP, targetProperties ); checkProperty( IDENTITY, targetProperties ); checkProperty( CREDENTIAL, targetProperties ); checkProperty( HARDWARE_NAME, targetProperties ); }  @Override String getTargetId(); @Override String createMachine( TargetHandlerParameters parameters ); @Override void configureMachine( TargetHandlerParameters parameters, String machineId ); @Override boolean isMachineRunning( TargetHandlerParameters parameters, String machineId ); @Override void terminateMachine( TargetHandlerParameters parameters, String machineId ); @Override String retrievePublicIpAddress( TargetHandlerParameters parameters, String machineId ); static final String TARGET_ID; }
@Test( expected = TargetException.class ) public void testValidate_error1() throws Exception { Map<String,String> targetProperties = new HashMap<String,String> (); targetProperties.put( JCloudsHandler.ENDPOINT, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.IMAGE_NAME, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.SECURITY_GROUP, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.IDENTITY, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.CREDENTIAL, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.HARDWARE_NAME, UUID.randomUUID().toString()); JCloudsHandler.validate( targetProperties ); }
@Test( expected = TargetException.class ) public void testValidate_error2() throws Exception { JCloudsHandler.validate( new HashMap<String,String>( 0 )); }
@Test public void testValidate() throws Exception { Map<String,String> targetProperties = new HashMap<String,String> (); targetProperties.put( JCloudsHandler.PROVIDER_ID, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.ENDPOINT, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.IMAGE_NAME, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.SECURITY_GROUP, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.IDENTITY, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.CREDENTIAL, UUID.randomUUID().toString()); targetProperties.put( JCloudsHandler.HARDWARE_NAME, UUID.randomUUID().toString()); JCloudsHandler.validate( targetProperties ); targetProperties.put( JCloudsHandler.KEY_PAIR, UUID.randomUUID().toString()); JCloudsHandler.validate( targetProperties ); }