@Test(enabled = false) public void testExecutePlugin(){ //TODO change to assert default params instead of null once RTFACT-5867 is fixed verifyExecutionResult(artifactory.plugins().execute(PLUGIN_NAME).sync(), null); String variable = "test"; verifyExecutionResult(artifactory.plugins().execute(PLUGIN_NAME).withParameter("whom", variable).sync(), "["+variable+"]"); }
@Test public void testMoveDirectory() throws Exception { try { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).folder("m"); String path = "abc"; checkTheEqualityOfFolders(itemHandle.move(NEW_LOCAL_TO, path), NEW_LOCAL_TO, path); } finally { deleteAllRelatedRepos(); } }
@Test public void testCopyFile() throws Exception { try { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).file(PATH); ItemHandle newItemHandle = itemHandle.copy(NEW_LOCAL_TO, PATH); checkTheEqualityOfFiles(newItemHandle, NEW_LOCAL_TO, PATH); } finally { deleteAllRelatedRepos(); } }
@Test public void testFolderInfo() throws IOException { // Get the folder to the cache artifactory.repository(getJCenterRepoName()).download("junit/junit/4.10/junit-4.10-sources.jar").doDownload(); Folder folder = artifactory.repository(getJcenterCacheName()).folder("junit").info(); assertNotNull(folder); assertTrue(folder.isFolder()); assertEquals(folder.getChildren().size(), 1); assertEquals(folder.getRepo(), getJcenterCacheName()); assertEquals(folder.getPath(), "/junit"); }
@Test(dependsOnMethods = "testUploadWithMultipleProperties", expectedExceptions = HttpResponseException.class) public void testDownloadWithWrongMandatoryProperties() throws IOException { // Property doesn't match, will fail artifactory.repository(localRepository.getKey()).download(PATH).withMandatoryProperty("colors", "black").doDownload(); }
@Test(dependsOnMethods = "testUploadWithMultipleProperties", expectedExceptions = HttpResponseException.class) public void testDownloadWithWrongNonMandatoryProperties() throws IOException { //property doesn't match, will fail artifactory.repository(localRepository.getKey()).download(PATH).withProperty("colors", "black").doDownload(); }
private String executeApi(String command) throws Exception { ArtifactoryRequest renameRequest = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.POST) .apiUrl("api/system/replications/" + command) .responseType(ArtifactoryRequest.ContentType.TEXT); return artifactory.restCall(renameRequest).getRawBody(); }
private List getPermissionTargets() throws Exception { ArtifactoryRequest req = new ArtifactoryRequestImpl() .method(ArtifactoryRequest.Method.GET) .apiUrl("api/security/permissions") .responseType(ArtifactoryRequest.ContentType.JSON); ArtifactoryResponse response = artifactory.restCall(req); List<String> responseBody = response.parseBody(List.class); return responseBody; }
@Test public void testLatestVersionSearch() throws IOException { String results = artifactory.searches().artifactsLatestVersion() .groupId("junit") .artifactId("junit") .repositories(getJCenterRepoName()) .doRawSearch(); assertEquals(results, "4.13-beta-1"); }
private void prepareRepositoriesForMovingAndCoping() throws IOException { deleteAllRelatedRepos(); setupLocalRepo(NEW_LOCAL_FROM); setupLocalRepo(NEW_LOCAL_TO); InputStream content = this.getClass().getResourceAsStream("/sample.txt"); assertNotNull(content); artifactory.repository(NEW_LOCAL_FROM).upload(PATH, content).doUpload(); }
@Test public void testMoveFile() throws Exception { try { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).file(PATH); ItemHandle newItemHandle = itemHandle.move(NEW_LOCAL_TO, PATH); checkTheEqualityOfFiles(newItemHandle, NEW_LOCAL_TO, PATH); } finally { deleteAllRelatedRepos(); } }
@Test public void testCopyDirectory() throws Exception { try { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).folder("m"); String path = "abc"; checkTheEqualityOfFolders(itemHandle.copy(NEW_LOCAL_TO, path), NEW_LOCAL_TO, path); } finally { deleteAllRelatedRepos(); } }
@Test public void testSearchByPropertyAndWrongRepoFilter() throws IOException { List<RepoPath> list = artifactory.searches().repositories(getJCenterRepoName()).itemsByProperty().property(releasedProp, true).doSearch(); assertTrue(list.isEmpty()); }
@Test(groups = "security") public void testEffectiveRepoPermissions() { Set<ItemPermission> itemPermissions = artifactory.repository(localRepository.getKey()).effectivePermissions(); assertItemPermissions(itemPermissions); }
private void checkTheEqualityOfFiles(ItemHandle newItemHandle, String expectedRepo, String expectedPath) { ItemHandle itemHandle = artifactory.repository(expectedRepo).file(expectedPath); assertEquals(itemHandle.info(), (Item)newItemHandle.info()); }
private void checkTheEqualityOfFolders(ItemHandle newItemHandle, String expectedRepo, String expectedPath) { ItemHandle itemHandle = artifactory.repository(expectedRepo).folder(expectedPath); assertEquals(itemHandle.info(), (Item)newItemHandle.info()); }
@Test(enabled = false) public void testPluginsListByType() { List<Plugin> list = artifactory.plugins().list(executions); verifyExecutionPlugins(list); }
@AfterClass public void tearDown() { try { artifactory.security().deletePermissionTarget(PERMISSION_Target_NAME); } catch (Exception ignore) { } }
protected String getJcenterCacheName() { return getJCenterRepoName() + "-cache"; } }
@Test(dependsOnMethods = "testUploadWithMultipleProperties", expectedExceptions = IOException.class) public void testDownloadWithNonExistingMandatoryProperties() throws IOException { // Property doesn't exist, will fail artifactory.repository(localRepository.getKey()).download(PATH).withMandatoryProperty("foo", "bar").doDownload(); }