use of org.commonjava.indy.client.core.helper.PathInfo in project indy by Commonjava.
the class StoreFileAndVerifyPathInfoResultExistsTest method storeFileAndVerifyReturnedInfo.
@Test
public void storeFileAndVerifyReturnedInfo() throws Exception {
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
final String path = "/path/to/foo.class";
client.content().store(hosted, STORE, path, stream);
final PathInfo result = client.content().getInfo(hosted, STORE, path);
System.out.println(result);
assertThat(result, notNullValue());
assertThat(result.exists(), equalTo(true));
}
use of org.commonjava.indy.client.core.helper.PathInfo in project indy by Commonjava.
the class GroupMetaOverlapWithNestedGroupOfHostRepoNoMetaTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
final String repo1 = "repo1";
final String repo2 = "repo2";
final String path = "org/foo/bar/maven-metadata.xml";
/* @formatter:off */
final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.0</latest>\n" + " <release>1.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " </versions>\n" + " <lastUpdated>20150722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.expect(server.formatUrl(repo2, path), 200, repo2Content);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
// constructs 3 level group structure: top -> middle -> bottom
// and the bottom group contains repo1 and repo2
Group bottomGroup = new Group("bottom", remote1.getKey(), remote2.getKey());
bottomGroup = client.stores().create(bottomGroup, "adding bottom group", Group.class);
System.out.printf("\n\nBottom group constituents are:\n %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n "));
Group middleGroup = new Group("middle", bottomGroup.getKey());
middleGroup = client.stores().create(middleGroup, "adding middle group", Group.class);
System.out.printf("\n\nMiddle group constituents are:\n %s\n\n", StringUtils.join(middleGroup.getConstituents(), "\n "));
Group topGroup = new Group("top", middleGroup.getKey());
topGroup = client.stores().create(topGroup, "adding top group", Group.class);
System.out.printf("\n\nTop group constituents are:\n %s\n\n", StringUtils.join(topGroup.getConstituents(), "\n "));
InputStream stream = client.content().get(group, topGroup.getName(), path);
assertThat(stream, notNullValue());
String metadata = IOUtils.toString(stream);
stream.close();
/* @formatter:off */
final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(groupContent));
final String hostedRepo = "hostedRepo";
HostedRepository hostedRepository = new HostedRepository(hostedRepo);
hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
// don't use the same GA as above, in case we ever decide to "actively" manage metadata in the repo manager (hint: we will)
final String normalPath = "org/foo/other/1.0/other-1.0.pom";
client.content().store(hostedRepository.getKey(), normalPath, new ByteArrayInputStream("<version>1.0</version>".getBytes("UTF-8")));
final PathInfo p = client.content().getInfo(hosted, hostedRepo, normalPath);
assertThat("hosted content should exist", p.exists(), equalTo(true));
// added hosted repo to bottom group and update
bottomGroup.addConstituent(hostedRepository);
client.stores().update(bottomGroup, "add new hosted");
System.out.printf("\n\nUpdated group constituents are:\n %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n "));
waitForEventPropagation();
// the top group should not reflect the meta file deprecation and expiration
final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s/%s-%s/%s", fixture.getBootOptions().getIndyHome(), MAVEN_PKG_KEY, group.name(), topGroup.getName(), path);
assertThat("group metadata should not be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(true));
stream = client.content().get(group, topGroup.getName(), path);
assertThat(stream, notNullValue());
metadata = IOUtils.toString(stream);
stream.close();
assertThat(metadata, equalTo(groupContent));
}
use of org.commonjava.indy.client.core.helper.PathInfo in project indy by Commonjava.
the class GroupMetaOverlapWithoutMetaOfHostedReposTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
final String repo1 = "repo1";
final String repo2 = "repo2";
final String path = "org/foo/bar/maven-metadata.xml";
/* @formatter:off */
final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.0</latest>\n" + " <release>1.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " </versions>\n" + " <lastUpdated>20150722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.expect(server.formatUrl(repo2, path), 200, repo2Content);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
Group g = new Group("test", remote1.getKey(), remote2.getKey());
g = client.stores().create(g, "adding group", Group.class);
System.out.printf("\n\nGroup constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
InputStream stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
String metadata = IOUtils.toString(stream);
stream.close();
/* @formatter:off */
final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(groupContent));
final String hostedRepo = "hostedRepo";
HostedRepository hostedRepository = new HostedRepository(hostedRepo);
hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
// don't use the same GA as above, in case we ever decide to "actively" manage metadata in the repo manager (hint: we will)
final String normalPath = "org/foo/other/1.0/other-1.0.pom";
client.content().store(hostedRepository.getKey(), normalPath, new ByteArrayInputStream("<version>1.0</version>".getBytes("UTF-8")));
final PathInfo p = client.content().getInfo(hosted, hostedRepo, normalPath);
assertThat("hosted content should exist", p.exists(), equalTo(true));
g.addConstituent(hostedRepository);
client.stores().update(g, "add new hosted");
System.out.printf("\n\nUpdated group constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
waitForEventPropagation();
File gpLevelMetaFile = Paths.get(fixture.getBootOptions().getIndyHome(), "var/lib/indy/storage", MAVEN_PKG_KEY, group.singularEndpointName() + "-" + g.getName(), path).toFile();
assertThat("group metadata should not be removed after merging", gpLevelMetaFile.exists(), equalTo(true));
stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
metadata = IOUtils.toString(stream);
stream.close();
assertThat(metadata, equalTo(groupContent));
}
use of org.commonjava.indy.client.core.helper.PathInfo in project indy by Commonjava.
the class RoutedCacheProviderForRemoteWithNoNFSTest method proxyRemoteWithNoNFS.
@Test
public void proxyRemoteWithNoNFS() throws Exception {
final String repo1 = "repo1";
final String pomPath = "org/foo/bar/1.0/bar-1.0.pom";
final String pomUrl = server.formatUrl(repo1, pomPath);
final String datetime = (new Date()).toString();
server.expect(pomUrl, 200, String.format("pom %s", datetime));
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
client.stores().create(remote1, "adding remote", RemoteRepository.class);
final PathInfo result = client.content().getInfo(remote, repo1, pomPath);
assertThat("no result", result, notNullValue());
assertThat("doesn't exist", result.exists(), equalTo(true));
final File nfsStorage = Paths.get(fixture.getBootOptions().getIndyHome(), NFS_BASE).toFile();
assertThat(nfsStorage.exists(), equalTo(false));
}
use of org.commonjava.indy.client.core.helper.PathInfo in project indy by Commonjava.
the class StoreAndConsistentlyVerifyPathInfoExistenceTest method storeAndVerifyPathInfo_10Times.
@Test
public void storeAndVerifyPathInfo_10Times() throws Exception {
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
final String path = "/path/to/foo.class";
client.content().store(hosted, STORE, path, stream);
for (int i = 0; i < 10; i++) {
final PathInfo result = client.content().getInfo(hosted, STORE, path);
assertThat("pass: " + i + "...no result", result, notNullValue());
assertThat("pass: " + i + "...doesn't exist", result.exists(), equalTo(true));
}
}
Aggregations