@Test public void testBuildBasicAuthString() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method m = MetricStoreImpl.class.getDeclaredMethod ("buildBasicAuthString", String.class, String.class); m.setAccessible(true); String authStr = (String) m.invoke(null, "user", "password"); assertTrue(authStr.equals("Basic dXNlcjpwYXNzd29yZA==")); }
private static String buildBasicAuthString(String user, String password) { String auth = user + ":" + password; return String.format("Basic %s", Base64.getEncoder().encodeToString( auth.getBytes())); }
MetricStoreImpl implements MetricStore { private static String buildBasicAuthString(String user, String password) { String auth = user + ":" + password; return String.format("Basic %s", Base64.getEncoder().encodeToString( auth.getBytes())); } }
MetricStoreImpl implements MetricStore { private static String buildBasicAuthString(String user, String password) { String auth = user + ":" + password; return String.format("Basic %s", Base64.getEncoder().encodeToString( auth.getBytes())); } MetricStoreImpl(@Value("${elasticsearch.host}") String host,
                           @Value("${elasticsearch.port}") int port,
                           @Value("${elasticsearch.scheme:http}") String scheme,
                           @Value("${elasticsearch.user:}") String user,
                           @Value("${elasticsearch.password:}") String password); }
MetricStoreImpl implements MetricStore { private static String buildBasicAuthString(String user, String password) { String auth = user + ":" + password; return String.format("Basic %s", Base64.getEncoder().encodeToString( auth.getBytes())); } MetricStoreImpl(@Value("${elasticsearch.host}") String host,
                           @Value("${elasticsearch.port}") int port,
                           @Value("${elasticsearch.scheme:http}") String scheme,
                           @Value("${elasticsearch.user:}") String user,
                           @Value("${elasticsearch.password:}") String password); @Override List<MetricValue> getMetricValues(String metricName, int from,
                                             int size, long tmst); @Override ResponseEntity<?> addMetricValues(List<MetricValue> metricValues); @Override ResponseEntity<?> deleteMetricValues(String metricName); @Override MetricValue getMetric(String applicationId); }
MetricStoreImpl implements MetricStore { private static String buildBasicAuthString(String user, String password) { String auth = user + ":" + password; return String.format("Basic %s", Base64.getEncoder().encodeToString( auth.getBytes())); } MetricStoreImpl(@Value("${elasticsearch.host}") String host,
                           @Value("${elasticsearch.port}") int port,
                           @Value("${elasticsearch.scheme:http}") String scheme,
                           @Value("${elasticsearch.user:}") String user,
                           @Value("${elasticsearch.password:}") String password); @Override List<MetricValue> getMetricValues(String metricName, int from,
                                             int size, long tmst); @Override ResponseEntity<?> addMetricValues(List<MetricValue> metricValues); @Override ResponseEntity<?> deleteMetricValues(String metricName); @Override MetricValue getMetric(String applicationId);  }