@Test public void testParseGrpcUrl() { String url = "grpc: Properties purl = Utils.parseGrpcUrl(url); Assert.assertEquals("grpc", purl.getProperty("protocol")); Assert.assertEquals("hyperledger.org", purl.getProperty("host")); Assert.assertEquals("1234", purl.getProperty("port")); }
public static Properties parseGrpcUrl(String url) { if (StringUtil.isNullOrEmpty(url)) { throw new RuntimeException("URL cannot be null or empty"); } Properties props = new Properties(); Pattern p = Pattern.compile("([^\\:]+)[\\:] Matcher m = p.matcher(url); if (m.matches()) { props.setProperty("protocol", m.group(1)); props.setProperty("host", m.group(2)); props.setProperty("port", m.group(3)); String protocol = props.getProperty("protocol"); if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) { throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol)); } } else { throw new RuntimeException("URL must be of the format protocol: } return props; }
Utils { public static Properties parseGrpcUrl(String url) { if (StringUtil.isNullOrEmpty(url)) { throw new RuntimeException("URL cannot be null or empty"); } Properties props = new Properties(); Pattern p = Pattern.compile("([^\\:]+)[\\:] Matcher m = p.matcher(url); if (m.matches()) { props.setProperty("protocol", m.group(1)); props.setProperty("host", m.group(2)); props.setProperty("port", m.group(3)); String protocol = props.getProperty("protocol"); if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) { throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol)); } } else { throw new RuntimeException("URL must be of the format protocol: } return props; } }
Utils { public static Properties parseGrpcUrl(String url) { if (StringUtil.isNullOrEmpty(url)) { throw new RuntimeException("URL cannot be null or empty"); } Properties props = new Properties(); Pattern p = Pattern.compile("([^\\:]+)[\\:] Matcher m = p.matcher(url); if (m.matches()) { props.setProperty("protocol", m.group(1)); props.setProperty("host", m.group(2)); props.setProperty("port", m.group(3)); String protocol = props.getProperty("protocol"); if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) { throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol)); } } else { throw new RuntimeException("URL must be of the format protocol: } return props; } private  Utils(); }
Utils { public static Properties parseGrpcUrl(String url) { if (StringUtil.isNullOrEmpty(url)) { throw new RuntimeException("URL cannot be null or empty"); } Properties props = new Properties(); Pattern p = Pattern.compile("([^\\:]+)[\\:] Matcher m = p.matcher(url); if (m.matches()) { props.setProperty("protocol", m.group(1)); props.setProperty("host", m.group(2)); props.setProperty("port", m.group(3)); String protocol = props.getProperty("protocol"); if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) { throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol)); } } else { throw new RuntimeException("URL must be of the format protocol: } return props; } private  Utils(); static String generateParameterHash(String path, String func, List<String> args); static String generateDirectoryHash(String rootDir, String chaincodeDir, String hash); static byte[] generateTarGz(File sourceDirectory, String pathPrefix); static byte[] readFile(File input); static String generateUUID(); static Timestamp generateTimestamp(); static void deleteFileOrDirectory(File file); static byte[] hash(byte[] input, Digest digest); static String combinePaths(String first, String... other); static byte[] readFileFromClasspath(String fileName); static Properties parseGrpcUrl(String url); static Exception checkGrpcUrl(String url); static boolean isNullOrEmpty(String url); static String logString(final String string); static byte[] generateNonce(); static String toHexString(ByteString byteString); static String toHexString(byte[] bytes); }
Utils { public static Properties parseGrpcUrl(String url) { if (StringUtil.isNullOrEmpty(url)) { throw new RuntimeException("URL cannot be null or empty"); } Properties props = new Properties(); Pattern p = Pattern.compile("([^\\:]+)[\\:] Matcher m = p.matcher(url); if (m.matches()) { props.setProperty("protocol", m.group(1)); props.setProperty("host", m.group(2)); props.setProperty("port", m.group(3)); String protocol = props.getProperty("protocol"); if (!"grpc".equals(protocol) && !"grpcs".equals(protocol)) { throw new RuntimeException(String.format("Invalid protocol expected grpc or grpcs and found %s.", protocol)); } } else { throw new RuntimeException("URL must be of the format protocol: } return props; } private  Utils(); static String generateParameterHash(String path, String func, List<String> args); static String generateDirectoryHash(String rootDir, String chaincodeDir, String hash); static byte[] generateTarGz(File sourceDirectory, String pathPrefix); static byte[] readFile(File input); static String generateUUID(); static Timestamp generateTimestamp(); static void deleteFileOrDirectory(File file); static byte[] hash(byte[] input, Digest digest); static String combinePaths(String first, String... other); static byte[] readFileFromClasspath(String fileName); static Properties parseGrpcUrl(String url); static Exception checkGrpcUrl(String url); static boolean isNullOrEmpty(String url); static String logString(final String string); static byte[] generateNonce(); static String toHexString(ByteString byteString); static String toHexString(byte[] bytes);  }