Search in sources :

Example 26 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class ProxyRemoteKojiContentTest method proxyRemoteKojiArtifact.

/**
     * Accessing an existing external Koji site and retrieve artifact. This is disabled by default. In order to run it,
     * you need an external Koji instance and start Indy via:
     * 1. export TEST_ETC=<your-koji-config-dir> => with proper settings for Koji url, pem, etc
     * 2. bin/test-setup.sh => to start Indy
     * 3. run this test
     */
@Ignore
@Test
public void proxyRemoteKojiArtifact() throws Exception {
    final String path = "org/dashbuilder/dashbuilder-all/0.4.0.Final-redhat-10/dashbuilder-all-0.4.0.Final-redhat-10.pom";
    Indy client = new Indy("http://localhost:8080/api", new IndyObjectMapper(Collections.emptySet()), Collections.emptySet()).connect();
    // would be slow the first time to get an artifact
    long elapse = getContent("build-x", client, path);
    logger.debug("Get (first) use " + elapse + " milliseconds");
    // the following get should have been cached and fast
    elapse = getContent("build-x", client, path);
    logger.debug("Get (second) use " + elapse + " milliseconds");
    // the remote store should have been added to builds-untested group
    StoreListingDTO<RemoteRepository> repos = client.stores().listRemoteRepositories();
    for (RemoteRepository repo : repos.getItems()) {
        logger.debug("Repo " + repo.getName());
        if (repo.getName().startsWith(KOJI_ORIGIN)) {
            logger.debug("Koji repo patterns: " + repo.getPathMaskPatterns());
        }
    }
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) Indy(org.commonjava.indy.client.core.Indy) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class PromotionManagerTest method setup.

@Before
public void setup() throws Exception {
    contentMetadata.clear();
    galleyParts = new GalleyMavenFixture(true, temp);
    galleyParts.initMissingComponents();
    storeManager = new MemoryStoreDataManager(true);
    downloadManager = new DefaultDownloadManager(storeManager, galleyParts.getTransferManager(), new IndyLocationExpander(storeManager), new MockInstance<>(new MockContentAdvisor()));
    DirectContentAccess dca = new DefaultDirectContentAccess(downloadManager, Executors.newSingleThreadExecutor());
    ContentDigester contentDigester = new DefaultContentDigester(dca, new CacheHandle<String, TransferMetadata>("content-metadata", contentMetadata));
    contentManager = new DefaultContentManager(storeManager, downloadManager, new IndyObjectMapper(true), new SpecialPathManagerImpl(), new MemoryNotFoundCache(), contentDigester, Collections.<ContentGenerator>emptySet());
    dataManager = new DataFileManager(temp.newFolder("data"), new DataFileEventManager());
    validationsManager = new PromoteValidationsManager(dataManager, new PromoteConfig(), new ValidationRuleParser(new ScriptEngine(dataManager), new IndyObjectMapper(true)));
    MavenModelProcessor modelProcessor = new MavenModelProcessor();
    validator = new PromotionValidator(validationsManager, new PromotionValidationTools(contentManager, storeManager, galleyParts.getPomReader(), galleyParts.getMavenMetadataReader(), modelProcessor, galleyParts.getTypeMapper(), galleyParts.getTransferManager(), contentDigester), storeManager);
    PromoteConfig config = new PromoteConfig();
    manager = new PromotionManager(validator, contentManager, downloadManager, storeManager, config);
    executor = Executors.newCachedThreadPool();
}
Also used : ValidationRuleParser(org.commonjava.indy.promote.validate.ValidationRuleParser) GalleyMavenFixture(org.commonjava.maven.galley.testing.maven.GalleyMavenFixture) DefaultContentManager(org.commonjava.indy.core.content.DefaultContentManager) MavenModelProcessor(org.commonjava.maven.galley.maven.rel.MavenModelProcessor) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) ContentGenerator(org.commonjava.indy.content.ContentGenerator) DirectContentAccess(org.commonjava.indy.content.DirectContentAccess) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) MockInstance(org.commonjava.indy.test.fixture.core.MockInstance) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) MemoryStoreDataManager(org.commonjava.indy.mem.data.MemoryStoreDataManager) IndyLocationExpander(org.commonjava.indy.content.IndyLocationExpander) DefaultDownloadManager(org.commonjava.indy.core.content.DefaultDownloadManager) PromotionValidator(org.commonjava.indy.promote.validate.PromotionValidator) ContentDigester(org.commonjava.indy.content.ContentDigester) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) PromotionValidationTools(org.commonjava.indy.promote.validate.PromotionValidationTools) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) PromoteConfig(org.commonjava.indy.promote.conf.PromoteConfig) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) ScriptEngine(org.commonjava.indy.subsys.template.ScriptEngine) PromoteValidationsManager(org.commonjava.indy.promote.validate.PromoteValidationsManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) MockContentAdvisor(org.commonjava.indy.test.fixture.core.MockContentAdvisor) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) Before(org.junit.Before)

Example 28 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class PackageMetadataMergerTest method mergeWhenOneTransferIsInvalidXml.

@Test
public void mergeWhenOneTransferIsInvalidXml() throws Exception {
    String path = "jquery/package.json";
    HostedRepository h1 = new HostedRepository("test-hosted-1");
    HostedRepository h2 = new HostedRepository("test-hosted-2");
    Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
    initTestData(t1, VERSION_META + "package-1.json");
    Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
    initTestData(t2, VERSION_META + "invalid.json");
    Group g = new Group("test-group", h1.getKey(), h2.getKey());
    List<Transfer> sources = Arrays.asList(t1, t2);
    byte[] output = new PackageMetadataMerger(Collections.emptyList()).merge(sources, g, path);
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
    // normal object fields merging verification
    assertThat(merged.getName(), equalTo("jquery"));
    assertThat(merged.getAuthor().getName(), equalTo("JS Foundation and other contributors"));
    assertThat(merged.getRepository().getType(), equalTo("git"));
    assertThat(merged.getRepository().getUrl(), equalTo("git+https://github.com/jquery1/jquery1.git"));
    assertThat(merged.getReadmeFilename(), equalTo("README1.md"));
    assertThat(merged.getHomepage(), equalTo("https://jquery1.com"));
    assertThat(merged.getBugs().getUrl(), equalTo("https://github.com/jquery1/jquery1/issues"));
    assertThat(merged.getLicense(), equalTo("MIT1"));
    // dist-tags object merging verification
    assertThat(merged.getDistTags().getBeta(), equalTo("2.2.1"));
    assertThat(merged.getDistTags().getLatest(), equalTo("2.2.1"));
    // error, versions map merging verification
    Map<String, VersionMetadata> versions = merged.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.size(), equalTo(1));
    assertThat(versions.get("1.5.1").getVersion(), equalTo("1.5.1"));
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) ByteArrayInputStream(java.io.ByteArrayInputStream) VersionMetadata(org.commonjava.indy.pkg.npm.model.VersionMetadata) PackageMetadata(org.commonjava.indy.pkg.npm.model.PackageMetadata) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 29 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class PackageMetadataMergerTest method mergeOneTransferWithProviderContent.

@Test
public void mergeOneTransferWithProviderContent() throws Exception {
    String path = "jquery/package.json";
    HostedRepository h1 = new HostedRepository("test-hosted-1");
    HostedRepository h2 = new HostedRepository("test-hosted-2");
    Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
    initTestData(t1, VERSION_META + "package-1.json");
    Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
    initTestData(t2, VERSION_META + "package-2.json");
    Group g = new Group("test-group", h1.getKey(), h2.getKey());
    List<Transfer> sources = Arrays.asList(t1, t2);
    PackageMetadata provided = new PackageMetadata("jquery");
    provided.setDescription("provider description test");
    provided.setRepository(new Repository("svn", "svn+https://svn.host/jquery"));
    provided.setBugs(new Bugs("https://github.com/jquery2/jquery2/issues", "jquery2@bug.com"));
    List<UserInfo> added = new ArrayList<UserInfo>();
    added.add(new UserInfo("testa", "testa@test.com"));
    provided.setMaintainers(added);
    TestPackageMetadataProvider testProvider = new TestPackageMetadataProvider(provided);
    byte[] output = new PackageMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
    // normal object fields merging verification
    assertThat(merged.getName(), equalTo("jquery"));
    assertThat(merged.getDescription(), equalTo("provider description test"));
    assertThat(merged.getRepository().getType(), equalTo("svn"));
    assertThat(merged.getRepository().getUrl(), equalTo("svn+https://svn.host/jquery"));
    assertThat(merged.getBugs().getUrl(), equalTo("https://github.com/jquery2/jquery2/issues"));
    assertThat(merged.getBugs().getEmail(), equalTo("jquery2@bug.com"));
    // maintainers list merging verification
    List<UserInfo> maintainers = merged.getMaintainers();
    assertThat(maintainers, notNullValue());
    assertThat(maintainers.size(), equalTo(4));
    assertThat(maintainers.get(0).getName(), equalTo("dmethvin"));
    assertThat(maintainers.get(1).getName(), equalTo("mgol"));
    assertThat(maintainers.get(2).getName(), equalTo("scott.gonzalez"));
    assertThat(maintainers.get(3).getName(), equalTo("testa"));
}
Also used : Bugs(org.commonjava.indy.pkg.npm.model.Bugs) Group(org.commonjava.indy.model.core.Group) ArrayList(java.util.ArrayList) UserInfo(org.commonjava.indy.pkg.npm.model.UserInfo) Repository(org.commonjava.indy.pkg.npm.model.Repository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) ByteArrayInputStream(java.io.ByteArrayInputStream) PackageMetadata(org.commonjava.indy.pkg.npm.model.PackageMetadata) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 30 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class PackageMetadataMergerTest method mergeProviderWithSameVersionMetadata.

@Test
public void mergeProviderWithSameVersionMetadata() throws Exception {
    String path = "jquery/package.json";
    HostedRepository h1 = new HostedRepository("test-hosted-1");
    Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
    initTestData(t1, VERSION_META + "package-1.json");
    Group g = new Group("test-group", h1.getKey());
    List<Transfer> sources = Arrays.asList(t1);
    PackageMetadata provided = new PackageMetadata("jquery");
    VersionMetadata versionMetadata = new VersionMetadata("jquery", "1.5.1");
    versionMetadata.setUrl("jquery.new.com");
    TestPackageMetadataProvider testProvider = new TestPackageMetadataProvider(provided);
    byte[] output = new PackageMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
    assertThat(merged.getVersions().get("1.5.1"), notNullValue());
    assertThat(merged.getVersions().get("1.5.1").getUrl(), equalTo("jquery.com"));
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) ByteArrayInputStream(java.io.ByteArrayInputStream) VersionMetadata(org.commonjava.indy.pkg.npm.model.VersionMetadata) PackageMetadata(org.commonjava.indy.pkg.npm.model.PackageMetadata) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Aggregations

IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)59 Test (org.junit.Test)41 StoreKey (org.commonjava.indy.model.core.StoreKey)16 HostedRepository (org.commonjava.indy.model.core.HostedRepository)10 Group (org.commonjava.indy.model.core.Group)9 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)8 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)8 Transfer (org.commonjava.maven.galley.model.Transfer)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 MemoryStoreDataManager (org.commonjava.indy.mem.data.MemoryStoreDataManager)7 DataFileManager (org.commonjava.indy.subsys.datafile.DataFileManager)6 DataFileEventManager (org.commonjava.indy.subsys.datafile.change.DataFileEventManager)6 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)6 Before (org.junit.Before)6 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)5 MemoryNotFoundCache (org.commonjava.maven.galley.nfc.MemoryNotFoundCache)5 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)4 Indy (org.commonjava.indy.client.core.Indy)4 DirectContentAccess (org.commonjava.indy.content.DirectContentAccess)4 DefaultContentDigester (org.commonjava.indy.core.content.DefaultContentDigester)4