Search in sources :

Example 1 with IndyFoloContentClientModule

use of org.commonjava.indy.folo.client.IndyFoloContentClientModule in project indy by Commonjava.

the class StoreFileThenDownloadThenUploadAndVerifyInTrackingReportTest method runDownloadThenUpload.

@Test
public void runDownloadThenUpload() throws Exception {
    final String trackingId = newName();
    // initiate file
    client.module(IndyContentClientModule.class).store(hosted, STORE, path, new ByteArrayInputStream(bytes));
    IndyFoloContentClientModule module = client.module(IndyFoloContentClientModule.class);
    // download
    module.get(trackingId, hosted, STORE, path);
    // upload
    module.store(trackingId, hosted, STORE, path, new ByteArrayInputStream(bytes));
    // wait for event being fired
    Thread.sleep(2000);
    sealAndCheck(trackingId);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IndyContentClientModule(org.commonjava.indy.client.core.module.IndyContentClientModule) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) Test(org.junit.Test)

Example 2 with IndyFoloContentClientModule

use of org.commonjava.indy.folo.client.IndyFoloContentClientModule in project indy by Commonjava.

the class StoreFileThenUploadThenDownloadAndVerifyInTrackingReportTest method runUploadThenDownload.

@Test
public void runUploadThenDownload() throws Exception {
    final String trackingId = newName();
    IndyFoloContentClientModule module = client.module(IndyFoloContentClientModule.class);
    // upload
    module.store(trackingId, hosted, STORE, path, new ByteArrayInputStream(bytes));
    // download
    module.get(trackingId, hosted, STORE, path);
    // wait for event being fired
    Thread.sleep(2000);
    sealAndCheck(trackingId);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) Test(org.junit.Test)

Example 3 with IndyFoloContentClientModule

use of org.commonjava.indy.folo.client.IndyFoloContentClientModule in project indy by Commonjava.

the class AutomaticPomDownloadTest method downloadJarAndCheckIfPomWasDownloaded.

@Test
public void downloadJarAndCheckIfPomWasDownloaded() throws Exception {
    final String repoId = "test-repo";
    final String pathFormat = "/org/foo/bar/1.0/bar-1.0.%s";
    final String jarPath = String.format(pathFormat, "jar");
    final String jarUrl = server.formatUrl(repoId, jarPath);
    final String pomPath = String.format(pathFormat, "pom");
    final String pomUrl = server.formatUrl(repoId, pomPath);
    // mocking up a http server that expects access to both a .jar and the accompanying .pom
    String datetime = (new Date()).toString();
    server.expect(pomUrl, 200, String.format("pom %s", datetime));
    server.expect(jarUrl, 200, String.format("jar %s", datetime));
    // set up remote repository pointing to the test http server
    final String changelog = "Setup: " + name.getMethodName();
    client.stores().create(new RemoteRepository(repoId, server.formatUrl(repoId)), changelog, RemoteRepository.class);
    // ensure the pom does not exist before the jar download
    assertThat(client.content().exists(remote, repoId, pomPath, true), equalTo(false));
    // download the .jar
    IndyFoloContentClientModule clientModule = client.module(IndyFoloContentClientModule.class);
    final InputStream result = clientModule.get(newName(), remote, repoId, jarPath);
    assertThat(result, notNullValue());
    result.close();
    // verify the existence of the .pom file after sleeping a bit to allow the event to propagate
    Thread.sleep(3000);
    assertThat(client.content().exists(remote, repoId, pomPath, true), equalTo(true));
}
Also used : InputStream(java.io.InputStream) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Date(java.util.Date) Test(org.junit.Test)

Aggregations

IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)3 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)1 Date (java.util.Date)1 IndyContentClientModule (org.commonjava.indy.client.core.module.IndyContentClientModule)1 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)1