use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeOneTransferWithProviderError.
@Test
public void mergeOneTransferWithProviderError() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Group g = new Group("test-group", h1.getKey());
List<Transfer> sources = Arrays.asList(t1);
TestMavenMetadataProvider testProvider = new TestMavenMetadataProvider(new IndyWorkflowException("Failed to get provider content"));
byte[] output = new MavenMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
assertThat(versioning.getRelease(), equalTo("1.0"));
assertThat(versioning.getLatest(), equalTo("1.0"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class CalculateHostedRepoTest method calculate.
@Test
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.hosted, name);
assertThat(calculation.getRuleName(), equalTo("0001-simple-rule"));
assertThat(calculation.getSupplementalStores().isEmpty(), equalTo(true));
final HostedRepository remote = (HostedRepository) calculation.getStore();
assertThat(remote.isAllowReleases(), equalTo(true));
assertThat(remote.isAllowSnapshots(), equalTo(true));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ModelJSONTest method deserializeHostedRepo.
@Test
public void deserializeHostedRepo() throws Exception {
final String json = loadJson("hosted-with-storage.json");
System.out.println(json);
final HostedRepository repo = mapper.readValue(json, HostedRepository.class);
System.out.println(repo);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RoutedCacheProviderForGroupTest method addGroupAndNFSSetup.
@Test
public void addGroupAndNFSSetup() throws Exception {
final String content = "This is a test: " + System.nanoTime();
final InputStream stream = new ByteArrayInputStream(content.getBytes());
final String path = "/path/to/foo.class";
final String hostedName1 = "test1";
final HostedRepository hostedRepo1 = this.client.stores().create(new HostedRepository(hostedName1), "create group", HostedRepository.class);
final File nfsStorage1 = Paths.get(fixture.getBootOptions().getIndyHome(), NFS_BASE, MAVEN_PKG_KEY, hosted.singularEndpointName() + "-" + hostedName1, path).toFile();
final String gname = newName();
Group g = this.client.stores().create(new Group(gname), "create group", Group.class);
g.addConstituent(hostedRepo1);
this.client.stores().update(g, "update group");
assertThat(client.content().exists(hosted, hostedName1, path), equalTo(false));
assertThat(nfsStorage1.exists(), equalTo(false));
client.content().store(group, gname, path, stream);
assertThat(client.content().exists(hosted, hostedName1, path), equalTo(true));
//TODO: seems that the nfs store is created here even if the store operation is on a group repo with a hosted repo in
// doubt that the store operation is recursively called on the sub constituent of this group, so the hosted repo
// in this group then do the store through the FastLocal, so the nfs one is created. Not sure if this is a right
// case.
assertThat(nfsStorage1.exists(), equalTo(true));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupMetaOverlapWithMetaOfHostedReposTest 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);
/* @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);
/* @formatter:off */
final String hostedMetaContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
client.content().store(hostedRepository.getKey(), path, new ByteArrayInputStream(hostedMetaContent.getBytes("UTF-8")));
final PathInfo p = client.content().getInfo(hosted, hostedRepo, path);
assertThat("hosted metadata 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();
final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s-%s/%s", fixture.getBootOptions().getHomeDir(), group.name(), g.getName(), path);
assertThat("group metadata should be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(false));
stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
metadata = IOUtils.toString(stream);
/* @formatter:off */
final String updGroupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(updGroupContent));
}
Aggregations