Search in sources :

Example 1 with JettyClientSlices

use of com.artipie.http.client.jetty.JettyClientSlices in project artipie by artipie.

the class RepositoriesFromStorageCacheTest method readAliasesFromCache.

@Test
void readAliasesFromCache() {
    final Key alias = new Key.From("_storages.yaml");
    final Key config = new Key.From("bin.yaml");
    new TestResource(alias.string()).saveTo(this.storage);
    new BlockingStorage(this.storage).save(config, "repo:\n  storage: default".getBytes());
    final ClientSlices http = new JettyClientSlices();
    new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join();
    this.storage.save(alias, Content.EMPTY).join();
    MatcherAssert.assertThat(new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join().storageOpt().isPresent(), new IsEqual<>(true));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) ClientSlices(com.artipie.http.client.ClientSlices) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) Test(org.junit.jupiter.api.Test)

Example 2 with JettyClientSlices

use of com.artipie.http.client.jetty.JettyClientSlices in project maven-adapter by artipie.

the class MavenProxyIT method setUp.

@BeforeEach
void setUp() throws Exception {
    final JettyClientSlices slices = new JettyClientSlices();
    slices.start();
    this.storage = new InMemoryStorage();
    this.server = new VertxSliceServer(MavenProxyIT.VERTX, new LoggingSlice(new MavenProxySlice(slices, URI.create("https://repo.maven.apache.org/maven2"), Authenticator.ANONYMOUS, new FromStorageCache(this.storage))));
    this.port = this.server.start();
    Testcontainers.exposeHostPorts(this.port);
    this.cntn = new GenericContainer<>("maven:3.6.3-jdk-11").withCommand("tail", "-f", "/dev/null").withWorkingDirectory("/home/").withFileSystemBind(this.tmp.toString(), "/home");
    this.cntn.start();
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) VertxSliceServer(com.artipie.vertx.VertxSliceServer) FromStorageCache(com.artipie.asto.cache.FromStorageCache) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) GenericContainer(org.testcontainers.containers.GenericContainer) MavenProxySlice(com.artipie.maven.http.MavenProxySlice) LoggingSlice(com.artipie.http.slice.LoggingSlice) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with JettyClientSlices

use of com.artipie.http.client.jetty.JettyClientSlices in project artipie by artipie.

the class RepositoriesFromStorageCacheTest method readConfigFromCacheAfterSavingNewValueInStorage.

@Test
void readConfigFromCacheAfterSavingNewValueInStorage() {
    final Key key = new Key.From("some-repo.yaml");
    final byte[] old = "some: data".getBytes();
    final byte[] upd = "some: new data".getBytes();
    new BlockingStorage(this.storage).save(key, old);
    final ClientSlices http = new JettyClientSlices();
    new RepositoriesFromStorage(http, this.storage).config(key.string()).toCompletableFuture().join();
    new BlockingStorage(this.storage).save(key, upd);
    MatcherAssert.assertThat(new RepositoriesFromStorage(http, this.storage).config(key.string()).toCompletableFuture().join().toString(), new IsEqual<>(new String(old)));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) Key(com.artipie.asto.Key) ClientSlices(com.artipie.http.client.ClientSlices) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) Test(org.junit.jupiter.api.Test)

Example 4 with JettyClientSlices

use of com.artipie.http.client.jetty.JettyClientSlices in project artipie by artipie.

the class VertxMain method main.

/**
 * Entry point.
 * @param args CLI args
 * @throws Exception If fails
 */
public static void main(final String... args) throws Exception {
    final Vertx vertx = Vertx.vertx();
    final Path config;
    final int port;
    final int defp = 80;
    final Options options = new Options();
    final String popt = "p";
    final String fopt = "f";
    options.addOption(popt, "port", true, "The port to start artipie on");
    options.addOption(fopt, "config-file", true, "The path to artipie configuration file");
    final CommandLineParser parser = new DefaultParser();
    final CommandLine cmd = parser.parse(options, args);
    if (cmd.hasOption(popt)) {
        port = Integer.parseInt(cmd.getOptionValue(popt));
    } else {
        Logger.info(VertxMain.class, "Using default port: %d", defp);
        port = defp;
    }
    if (cmd.hasOption(fopt)) {
        config = Path.of(cmd.getOptionValue(fopt));
    } else {
        throw new IllegalStateException("Storage is not configured");
    }
    Logger.info(VertxMain.class, "Used version of Artipie: %s", new ArtipieProperties().version());
    final JettyClientSlices http = new JettyClientSlices(new HttpClientSettings());
    http.start();
    new VertxMain(http, config, vertx, port).start();
}
Also used : Path(java.nio.file.Path) Options(org.apache.commons.cli.Options) Vertx(io.vertx.reactivex.core.Vertx) CommandLine(org.apache.commons.cli.CommandLine) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) ArtipieProperties(com.artipie.misc.ArtipieProperties) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)4 Key (com.artipie.asto.Key)2 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)2 ClientSlices (com.artipie.http.client.ClientSlices)2 Test (org.junit.jupiter.api.Test)2 FromStorageCache (com.artipie.asto.cache.FromStorageCache)1 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)1 TestResource (com.artipie.asto.test.TestResource)1 LoggingSlice (com.artipie.http.slice.LoggingSlice)1 MavenProxySlice (com.artipie.maven.http.MavenProxySlice)1 ArtipieProperties (com.artipie.misc.ArtipieProperties)1 VertxSliceServer (com.artipie.vertx.VertxSliceServer)1 Vertx (io.vertx.reactivex.core.Vertx)1 Path (java.nio.file.Path)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 GenericContainer (org.testcontainers.containers.GenericContainer)1