AgentUtils { public static boolean isValidIP( String ip ) { boolean result = false; try { String[] parts; if( ! Utils.isEmptyOrWhitespaces( ip ) && (parts = ip.split("\\.")).length == 4 ) { result = true; for( String s : parts ) { int part = Integer.parseInt( s ); if( part < 0 || part > 255 ) { result = false; break; } } } } catch( NumberFormatException e ) { result = false; } return result; } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); static final String INJECTED_CONFIGS_DIR; }
@Test public void testIsValidIP() { Assert.assertTrue( AgentUtils.isValidIP( "127.0.0.1" )); Assert.assertTrue( AgentUtils.isValidIP( "192.168.1.1" )); Assert.assertTrue( AgentUtils.isValidIP( "46.120.105.36" )); Assert.assertTrue( AgentUtils.isValidIP( "216.24.131.152" )); Assert.assertFalse( AgentUtils.isValidIP( "localhost" )); Assert.assertFalse( AgentUtils.isValidIP( "127.0.0." )); Assert.assertFalse( AgentUtils.isValidIP( "127.0.0" )); Assert.assertFalse( AgentUtils.isValidIP( "-192.168.1.-5" )); Assert.assertFalse( AgentUtils.isValidIP( "192.168.1.-5" )); Assert.assertFalse( AgentUtils.isValidIP( "192.168.lol.1" )); Assert.assertFalse( AgentUtils.isValidIP( "192.168.2.1024" )); Assert.assertFalse( AgentUtils.isValidIP( "" )); Assert.assertFalse( AgentUtils.isValidIP( null )); }