Search in sources :

Example 1 with IndyObjectMapper

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

the class TrackedContentDTOTest method assertRoundTrip.

private void assertRoundTrip(final TrackedContentDTO in, final Consumer<TrackedContentDTO> extraAssertions) throws IOException {
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    String json = mapper.writeValueAsString(in);
    TrackedContentDTO out = mapper.readValue(json, TrackedContentDTO.class);
    assertThat(out, notNullValue());
    assertThat(out.getKey(), equalTo(in.getKey()));
    if (extraAssertions != null) {
        extraAssertions.accept(out);
    }
    assertThat(out, equalTo(in));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper)

Example 2 with IndyObjectMapper

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

the class TrackedContentEntryDTOTest method assertRoundTrip.

private void assertRoundTrip(final TrackedContentEntryDTO in, final Consumer<TrackedContentEntryDTO> extraAssertions) throws IOException {
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    String json = mapper.writeValueAsString(in);
    TrackedContentEntryDTO out = mapper.readValue(json, TrackedContentEntryDTO.class);
    assertThat(out, notNullValue());
    assertThat(out.getStoreKey(), equalTo(in.getStoreKey()));
    assertThat(out.getPath(), equalTo(in.getPath()));
    if (extraAssertions != null) {
        extraAssertions.accept(out);
    }
    assertThat(out, equalTo(in));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper)

Example 3 with IndyObjectMapper

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

the class ContentExpirationTest method roundTrip.

@Test
public void roundTrip() throws Exception {
    final ContentExpiration exp = new ContentExpiration(new StoreKey(StoreType.remote, "test"), "/path/to/something.good");
    final IndyObjectMapper mapper = new IndyObjectMapper(false);
    final String json = mapper.writeValueAsString(exp);
    System.out.println(json);
    final ContentExpiration result = mapper.readValue(json, ContentExpiration.class);
    assertThat(result, equalTo(exp));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 4 with IndyObjectMapper

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

the class DataFileTCKFixtureProvider method before.

@Override
protected void before() throws Throwable {
    super.before();
    configDir = newFolder("db");
    final IndyObjectMapper serializer = new IndyObjectMapper(true);
    dataManager = new TestFlatFileDataManager(new DataFileConfiguration().withDataBasedir(configDir), serializer);
    dataManager.install();
    dataManager.clear(new ChangeSummary(ChangeSummary.SYSTEM_USER, "Setting up test"));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileConfiguration(org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration) ChangeSummary(org.commonjava.indy.audit.ChangeSummary)

Example 5 with IndyObjectMapper

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

the class HttpProxyTest method setup.

@Before
public void setup() throws Exception {
    contentMetadata.clear();
    core.initGalley();
    final TransportManager transports = new TransportManagerImpl(new HttpClientTransport(new HttpImpl(new MemoryPasswordManager())));
    core.withTransportManager(transports);
    core.initMissingComponents();
    final HttproxConfig config = new HttproxConfig();
    config.setEnabled(true);
    proxyPort = config.getPort();
    final BootOptions bootOpts = new BootOptions();
    bootOpts.setBind(HOST);
    storeManager = new MemoryStoreDataManager(true);
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final DownloadManager downloadManager = new DefaultDownloadManager(storeManager, core.getTransferManager(), core.getLocationExpander(), new MockInstance<>(new MockContentAdvisor()));
    DirectContentAccess dca = new DefaultDirectContentAccess(downloadManager, Executors.newSingleThreadExecutor());
    ContentDigester contentDigester = new DefaultContentDigester(dca, new CacheHandle<String, TransferMetadata>("content-metadata", contentMetadata));
    final ContentManager contentManager = new DefaultContentManager(storeManager, downloadManager, mapper, new SpecialPathManagerImpl(), new MemoryNotFoundCache(), contentDigester, Collections.<ContentGenerator>emptySet());
    DataFileManager dfm = new DataFileManager(temp.newFolder(), new DataFileEventManager());
    final TemplatingEngine templates = new TemplatingEngine(new GStringTemplateEngine(), dfm);
    final ContentController contentController = new ContentController(storeManager, contentManager, templates, mapper, new MimeTyper());
    KeycloakConfig kcConfig = new KeycloakConfig();
    kcConfig.setEnabled(false);
    final KeycloakProxyAuthenticator auth = new KeycloakProxyAuthenticator(kcConfig, config);
    ScriptEngine scriptEngine = new ScriptEngine(dfm);
    proxy = new HttpProxy(config, bootOpts, new ProxyAcceptHandler(config, storeManager, contentController, auth, core.getCache(), scriptEngine));
    proxy.start();
}
Also used : DefaultContentManager(org.commonjava.indy.core.content.DefaultContentManager) DownloadManager(org.commonjava.indy.content.DownloadManager) DefaultDownloadManager(org.commonjava.indy.core.content.DefaultDownloadManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) HttproxConfig(org.commonjava.indy.httprox.conf.HttproxConfig) DirectContentAccess(org.commonjava.indy.content.DirectContentAccess) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) MemoryStoreDataManager(org.commonjava.indy.mem.data.MemoryStoreDataManager) KeycloakProxyAuthenticator(org.commonjava.indy.httprox.keycloak.KeycloakProxyAuthenticator) DefaultDownloadManager(org.commonjava.indy.core.content.DefaultDownloadManager) ContentDigester(org.commonjava.indy.content.ContentDigester) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) TransportManagerImpl(org.commonjava.maven.galley.transport.TransportManagerImpl) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) ContentController(org.commonjava.indy.core.ctl.ContentController) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) DefaultContentManager(org.commonjava.indy.core.content.DefaultContentManager) ContentManager(org.commonjava.indy.content.ContentManager) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) GStringTemplateEngine(groovy.text.GStringTemplateEngine) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) BootOptions(org.commonjava.indy.boot.BootOptions) MimeTyper(org.commonjava.indy.util.MimeTyper) ScriptEngine(org.commonjava.indy.subsys.template.ScriptEngine) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) TemplatingEngine(org.commonjava.indy.subsys.template.TemplatingEngine) MockContentAdvisor(org.commonjava.indy.test.fixture.core.MockContentAdvisor) TransportManager(org.commonjava.maven.galley.spi.transport.TransportManager) ProxyAcceptHandler(org.commonjava.indy.httprox.handler.ProxyAcceptHandler) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) KeycloakConfig(org.commonjava.indy.subsys.keycloak.conf.KeycloakConfig) Before(org.junit.Before)

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