private void checkTheEqualityOfFiles(ItemHandle newItemHandle, String expectedRepo, String expectedPath) { ItemHandle itemHandle = artifactory.repository(expectedRepo).file(expectedPath); assertEquals(itemHandle.info(), (Item)newItemHandle.info()); }
@Test(groups = "security") public void testEffectiveItemPermissions() throws Exception { InputStream inputStream = this.getClass().getResourceAsStream("/sample.txt"); Assert.assertNotNull(inputStream); File deployed = artifactory.repository(localRepository.getKey()).upload(PATH, inputStream).doUpload(); Assert.assertNotNull(deployed); Set<ItemPermission> itemPermissions = artifactory.repository(localRepository.getKey()).file(PATH).effectivePermissions(); assertItemPermissions(itemPermissions); }
@Test public void testExceptionOnCopingFile() throws Exception { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).file("a/a"); try { itemHandle.copy(NEW_LOCAL_TO, PATH); } catch (CopyMoveException e) { assertTrue(curl("api/copy/" + NEW_LOCAL_FROM + "/a/a?to=" + NEW_LOCAL_TO + "/" + PATH, "POST").contains(e.getCopyMoveResultReport().getMessages().get(0).getMessage())); } finally { deleteAllRelatedRepos(); } }
@Test public void testExceptionOnMovingFile() throws Exception { prepareRepositoriesForMovingAndCoping(); ItemHandle itemHandle = artifactory.repository(NEW_LOCAL_FROM).file("a/a"); try { itemHandle.move(NEW_LOCAL_TO, PATH); } catch (CopyMoveException e) { assertTrue(curl("api/move/" + NEW_LOCAL_FROM + "/a/a?to=" + NEW_LOCAL_TO + "/" + PATH, "POST").contains(e.getCopyMoveResultReport().getMessages().get(0).getMessage())); } 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 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(); } }
assertNotNull(content); artifactory.repository(localRepository.getKey()).upload(PATH_PROPS, content).doUpload(); ItemHandle file = artifactory.repository(localRepository.getKey()).file(PATH_PROPS); Map<String, ?> resProps = file.getProperties(); assertTrue(resProps.isEmpty());
@Test(dependsOnMethods = "testFileInfo") public void testFileInfoWithSha256() throws Exception { String path = "junit/junit/4.10/junit-4.10-sources.jar"; calcSha256ForItem(getJcenterCacheName(), path); File file = artifactory.repository(getJcenterCacheName()).file(path).info(); assertNotNull(file); assertEquals(file.getDownloadUri(), url + getJcenterCacheName() + "/junit/junit/4.10/junit-4.10-sources.jar"); assertEquals(file.getChecksums().getMd5(), "8f17d4271b86478a2731deebdab8c846"); assertEquals(file.getChecksums().getSha1(), "6c98d6766e72d5575f96c9479d1c1d3b865c6e25"); assertEquals(file.getChecksums().getSha256(), "e3a4cb7ac3343265f5663b68857078ae68787450afc6e72dc6826962a1bf5212"); }
@Test public void testFileInfo() throws IOException { // Get the file to the cache artifactory.repository(getJCenterRepoName()).download("junit/junit/4.10/junit-4.10-sources.jar").doDownload(); File file = artifactory.repository(getJcenterCacheName()).file("junit/junit/4.10/junit-4.10-sources.jar").info(); assertNotNull(file); assertFalse(file.isFolder()); assertEquals(file.getSize(), 141185); assertEquals(file.getDownloadUri(), url + getJcenterCacheName() + "/junit/junit/4.10/junit-4.10-sources.jar"); assertEquals(file.getChecksums().getMd5(), "8f17d4271b86478a2731deebdab8c846"); assertEquals(file.getChecksums().getSha1(), "6c98d6766e72d5575f96c9479d1c1d3b865c6e25"); }