protected String curl(String path) throws IOException { return curl(path, "GET"); }
protected String curlAndStrip(String path) throws IOException { return curlAndStrip(path, "GET"); }
@AfterClass public void clean() { deleteRepoIfExists(localRepository.getKey()); deleteRepoIfExists(getJCenterRepoName()); artifactory.close(); }
url = readParam(props, "url"); if (!url.endsWith("/")) { url += "/"; username = readParam(props, "username"); password = readParam(props, "password"); filePath = "a/b"; fileSize = 141185; .setPassword(password) .build(); deleteRepoIfExists(localRepositoryKey); deleteRepoIfExists(getJCenterRepoName()); localRepository = artifactory.repositories().builders().localRepositoryBuilder() .key(localRepositoryKey) String jcenterRepoName = getJCenterRepoName(); if (!artifactory.repository(jcenterRepoName).exists()) { Repository jcenter = artifactory.repositories().builders().remoteRepositoryBuilder()
protected String curl(String path, String method) throws IOException { String authStringEnc = new String(encodeBase64((username + ":" + password).getBytes())); CloseableHttpResponse response = null; String responseString = null; try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpUriRequest request = createRequest(path, method); request.addHeader("Authorization", "Basic " + authStringEnc); response = httpClient.execute(request); HttpEntity entity = response.getEntity(); responseString = textFrom(entity.getContent()); } finally { if (response != null) { response.close(); } } return responseString; }
protected String getJcenterCacheName() { return getJCenterRepoName() + "-cache"; } }
public static String readParam(Properties props, String paramName) { String paramValue = null; if (props.size() > 0) { paramValue = props.getProperty(CLIENTTESTS_ARTIFACTORY_PROPERTIES_PREFIX + paramName); } if (paramValue == null) { paramValue = System.getProperty(CLIENTTESTS_ARTIFACTORY_PROPERTIES_PREFIX + paramName); } if (paramValue == null) { paramValue = System.getenv(CLIENTTESTS_ARTIFACTORY_ENV_VAR_PREFIX + paramName.toUpperCase()); } if (paramValue == null) { failInit(); } return paramValue; }
protected String curlAndStrip(String path, String method) throws IOException { String result = curl(path, method); result = remove(result, ' '); result = remove(result, '\r'); result = remove(result, '\n'); return result; }