use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RemoteRepositoryTest method serializeRemoteWithServerPem.
@Test
public void serializeRemoteWithServerPem() throws JsonProcessingException {
RemoteRepository remote = new RemoteRepository("test", "http://test.com/repo");
remote.setServerCertPem("AAAAFFFASDFADSFASDFSADFa");
remote.setServerTrustPolicy("self-signed");
String json = new IndyObjectMapper(true).writeValueAsString(remote);
System.out.println(json);
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class EndpointViewListingTest method jsonRoundTrip.
@Test
public void jsonRoundTrip() throws IOException {
EndpointView first = new EndpointView(new RemoteRepository("test", "http://foo.com/repo"), "http://localhost:8080/api/remote/test");
EndpointView second = new EndpointView(new RemoteRepository("test2", "http://foo2.com/repo2"), "http://localhost:8080/api/remote/test2");
EndpointViewListing in = new EndpointViewListing(Arrays.asList(first, second));
IndyObjectMapper mapper = new IndyObjectMapper(true);
String json = mapper.writeValueAsString(in);
EndpointViewListing out = mapper.readValue(json, EndpointViewListing.class);
assertThat(out, notNullValue());
List<EndpointView> items = out.getItems();
assertThat(items, notNullValue());
assertThat(items.size(), equalTo(2));
int i = 0;
EndpointView view = items.get(i++);
assertThat(view.getKey(), equalTo(first.getKey()));
assertThat(view.getName(), equalTo(first.getName()));
assertThat(view.getResourceUri(), equalTo(first.getResourceUri()));
assertThat(view.getStoreKey(), equalTo(first.getStoreKey()));
assertThat(view.getStoreType(), equalTo(first.getStoreType()));
assertThat(view, equalTo(first));
view = items.get(i++);
assertThat(view.getKey(), equalTo(second.getKey()));
assertThat(view.getName(), equalTo(second.getName()));
assertThat(view.getResourceUri(), equalTo(second.getResourceUri()));
assertThat(view.getStoreKey(), equalTo(second.getStoreKey()));
assertThat(view.getStoreType(), equalTo(second.getStoreType()));
assertThat(view, equalTo(second));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RemoteRepositoryTest method serializeRemoteWithKeyPemAndPassword.
@Test
public void serializeRemoteWithKeyPemAndPassword() throws JsonProcessingException {
RemoteRepository remote = new RemoteRepository("test", "http://test.com/repo");
remote.setKeyCertPem("AAAAFFFASDFADSFASDFSADFa");
remote.setKeyPassword("testme");
String json = new IndyObjectMapper(true).writeValueAsString(remote);
System.out.println(json);
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RemoteRepoInValidUrlTest method run.
@Ignore("Disabling validating decorator around StoreDataManager until we can be more certain it's correct and stable for all use cases")
@Test(expected = IndyClientException.class)
public void run() throws Exception {
final String INVALID_REPO = "invalid-repo";
final String INVALID_URL = "this.is.not.valid.url";
client.stores().create(new RemoteRepository(INVALID_REPO, INVALID_URL), "adding invalid test", RemoteRepository.class);
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class MetaListingRescheduleTimeoutTest method timeout.
@Test
@Category(TimingDependent.class)
public void timeout() throws Exception {
final int METADATA_TIMEOUT_SECONDS = 4;
final int METADATA_TIMEOUT_WAITING_MILLISECONDS = 3000;
final String repoId = "test-repo";
// path without trailing slash for ExpectationServer...
String repoRootPath = "org/foo/bar";
final String repoRootUrl = server.formatUrl(repoId, repoRootPath);
// now append the trailing '/' so Indy knows to try a directory listing...
repoRootPath += "/";
final String repoSubPath1 = "org/foo/bar/1.0/pom.xml";
final String repoSubPath2 = "org/foo/bar/1.1/pom.xml";
final String repoSubUrl1 = server.formatUrl(repoId, repoSubPath1);
final String repoSubUrl2 = server.formatUrl(repoId, repoSubPath2);
// mocking up a http server that expects access to metadata
final String listingContent = "<html>" + "<head><title>Index of /org/foo/bar</title></head>" + "<body><h1>Index of /org/foo/bar/</h1>" + "<hr><pre>" + "<a href=\"1.0/\">1.0/</a>" + "<a href=\"1.1/\">1.1/</a>" + "</pre><hr></body></html>";
server.expect(repoRootUrl, 200, listingContent);
final String datetime = (new Date()).toString();
server.expect(repoSubUrl1, 200, String.format("metadata %s", datetime));
server.expect(repoSubUrl2, 200, String.format("metadata %s", datetime));
// set up remote repository pointing to the test http server, and timeout little later
final String changelog = "Timeout Testing: " + name.getMethodName();
final RemoteRepository repository = new RemoteRepository(repoId, server.formatUrl(repoId));
repository.setMetadataTimeoutSeconds(METADATA_TIMEOUT_SECONDS);
client.stores().create(repository, changelog, RemoteRepository.class);
try (InputStream is = client.content().get(remote, repoId, repoSubPath1)) {
}
try (InputStream is = client.content().get(remote, repoId, repoSubPath2)) {
}
// first time trigger normal content storage with timeout, should be 4s
InputStream content = client.content().get(remote, repoId, repoRootPath);
assertThat("no metadata result", content, notNullValue());
logger.debug("### will begin to get content");
IOUtils.readLines(content).forEach(logger::info);
content.close();
final String listingMetaPath = "org/foo/bar/.listing.txt";
File listingMetaFile = Paths.get(fixture.getBootOptions().getIndyHome(), "var/lib/indy/storage", MAVEN_PKG_KEY, remote.singularEndpointName() + "-" + repoId, listingMetaPath).toFile();
assertThat("metadata doesn't exist: " + listingMetaFile, listingMetaFile.exists(), equalTo(true));
// wait for first time
Thread.sleep(METADATA_TIMEOUT_WAITING_MILLISECONDS);
// as the metadata content re-request, the metadata timeout interval should NOT be re-scheduled
client.content().get(remote, repoId, repoRootPath).close();
// will wait second time for a longer period
Thread.sleep(METADATA_TIMEOUT_WAITING_MILLISECONDS * getTestTimeoutMultiplier());
// logger.info( "Checking whether metadata file {} has been deleted...", listingMetaFile );
// as rescheduled, the artifact should not be deleted
assertThat("artifact should be removed as the rescheduled of metadata should not succeed", listingMetaFile.exists(), equalTo(false));
}
Aggregations