@Test(dependsOnMethods = "testUploadWithSingleProperty") public void testUploadExplodeArchive() throws IOException { artifactory.repository(localRepository.getKey()).upload("sample/sample.zip", this.getClass().getResourceAsStream("/sample.zip")) .doUploadAndExplode(); List<Item> items = ((FolderImpl) artifactory.repository(localRepository.getKey()).folder("sample").info()).getChildren(); assertEquals(items.get(0).getUri(), "/a.txt"); assertEquals(items.get(1).getUri(), "/b.txt"); assertEquals(items.get(2).getUri(), "/c.txt"); }
@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(groups = "items") public void testSetItemPropertiesOnNonExistingDirectory() throws Exception { ItemHandle folder = artifactory.repository(localRepository.getKey()).folder("x/y/z"); try { folder.info(); //should fail } catch (Exception e) { //noinspection ConstantConditions if (!(e instanceof HttpResponseException) || !(((HttpResponseException) e).getStatusCode() == 404 || ((HttpResponseException) e).getStatusCode() == 405)) { throw e; } } folder.properties().addProperty("v1", "b2").doSet(); Folder info = folder.info(); assertNotNull(info); assertTrue(info.isFolder()); assertTrue(folder.getPropertyValues("v1").contains("b2")); }
@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"); }