use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class DownloadFromTrackedAndRetrieveInRepoZipTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
String path = "org/commonjava/commonjava/2/commonjava-2.pom";
centralServer.expect(centralServer.formatUrl(path), 200, Thread.currentThread().getContextClassLoader().getResourceAsStream("folo-content/commonjava-2.pom"));
InputStream result = client.module(IndyFoloContentClientModule.class).get(trackingId, remote, CENTRAL, path);
assertThat(result, notNullValue());
final String pom = IOUtils.toString(result);
result.close();
assertThat(pom.contains("<groupId>org.commonjava</groupId>"), equalTo(true));
IndyFoloAdminClientModule module = client.module(IndyFoloAdminClientModule.class);
boolean success = module.sealTrackingRecord(trackingId);
assertThat(success, equalTo(true));
result = module.getTrackingRepoZip(trackingId);
assertThat(result, notNullValue());
// ZipInputStream wrapping this resulting InputStream didn't seem to work...I was probably doing something wrong
File f = getTemp().newFile("downloaded.zip");
try (FileOutputStream fos = new FileOutputStream(f)) {
IOUtils.copy(result, fos);
}
ZipFile zf = new ZipFile(f);
ZipEntry entry = zf.getEntry(path);
assertThat(entry, notNullValue());
try (InputStream stream = zf.getInputStream(entry)) {
String fromZip = IOUtils.toString(stream);
assertThat("zip contents differ from direct download!", fromZip, equalTo(pom));
}
}
use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class StoreAndPromoteFileToTrackedHostedRepoTest method run.
@Test
public void run() throws Exception {
String changelog = "Create test repo";
IndyFoloContentClientModule folo = client.module(IndyFoloContentClientModule.class);
IndyPromoteClientModule promote = client.module(IndyPromoteClientModule.class);
IndyFoloAdminClientModule foloAdmin = client.module(IndyFoloAdminClientModule.class);
// 0. Create tracking id and use it as promotion source
String trackingId = newName();
// 1. Create source and target repositories
HostedRepository source = new HostedRepository(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, trackingId);
client.stores().create(source, changelog, HostedRepository.class);
HostedRepository target = new HostedRepository(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, "target");
client.stores().create(target, changelog, HostedRepository.class);
// 2. Store the artifact to source repo
InputStream stream = new ByteArrayInputStream(bytes);
folo.store(trackingId, source.getKey(), path, stream);
// 3. Seal the record
foloAdmin.sealTrackingRecord(trackingId);
// 4. Promote to target repo (by path)
PathsPromoteRequest promoteRequest = new PathsPromoteRequest(source.getKey(), target.getKey());
promoteRequest.setFireEvents(true);
promote.promoteByPath(promoteRequest);
// 5. Check tracking record, the store is adjusted to target
TrackedContentDTO trackingContent = foloAdmin.getRawTrackingContent(trackingId);
List<TrackedContentEntryDTO> list = new ArrayList<>(trackingContent.getUploads());
TrackedContentEntryDTO trackedContent = list.get(0);
assertEquals(target.getKey(), trackedContent.getStoreKey());
}
use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class StoreFileThenUploadThenDownloadAndVerifyInTrackingReportTest method sealAndCheck.
void sealAndCheck(String trackingId) throws IndyClientException {
// seal
IndyFoloAdminClientModule adminModule = client.module(IndyFoloAdminClientModule.class);
boolean success = adminModule.sealTrackingRecord(trackingId);
assertThat(success, equalTo(true));
// check report
final TrackedContentDTO report = adminModule.getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> downloads = report.getDownloads();
assertThat(downloads, notNullValue());
assertThat(downloads.size(), equalTo(1));
final Set<TrackedContentEntryDTO> uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
}
use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class FoloBackupListenerTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
final String path = "/path/to/foo.class";
client.module(IndyFoloContentClientModule.class).store(trackingId, hosted, STORE, path, stream);
IndyFoloAdminClientModule adminModule = client.module(IndyFoloAdminClientModule.class);
boolean success = adminModule.sealTrackingRecord(trackingId);
assertThat(success, equalTo(true));
final TrackedContentDTO report = adminModule.getTrackingReport(trackingId);
assertThat(report, notNullValue());
final Set<TrackedContentEntryDTO> uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
final TrackedContentEntryDTO entry = uploads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(hosted, STORE)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(hosted, STORE, path)));
assertThat(entry.getOriginUrl(), nullValue());
// /////////////////////////////////////////////////////////////////////////////
// the above are copied from StoreFileAndVerifyInTrackingReportTest
// next, we check the backup dir contains two files, one from startup action, the other is just added
// **/
// File f1 = new File( dataDir, FOLO_DIR + "/" + BAK_DIR +"/sealed/" + trackingId );
// assertTrue( f1.exists() );
File f2 = new File(dataDir, FOLO_DIR + "/" + BAK_DIR + "/sealed");
assertDumped(f2);
}
use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class RecordsMigrationTest method run.
@Test
public void run() throws Exception {
IndyFoloAdminClientModule adminClientModule = client.module(IndyFoloAdminClientModule.class);
TrackingIdsDTO idsDTO = adminClientModule.getTrackingIds(SEALED.getValue());
assertNotNull(idsDTO);
List<String> expectedIds = Arrays.asList("Mg4NV207", "qC8c1cZB");
// **/ Disabled behawior because it is affeecting auditing for folo records
// checkIdsDTO( idsDTO, expectedIds, adminClientModule );
}
Aggregations