Search in sources :

Example 1 with Content

use of io.nosqlbench.nb.api.content.Content in project nosqlbench by nosqlbench.

the class ResolverForURLTest method testCPResource.

@Test
public void testCPResource() {
    String cprootForTestContext = "target/test-classes/";
    String resourcePathWithinClasspathRoots = "nesteddir1/nesteddir2/testcsv12.csv";
    ResolverForClasspath r = new ResolverForClasspath();
    List<Content<?>> c = r.resolve(resourcePathWithinClasspathRoots);
    assertThat(c).isNotNull();
    Object location = c.get(0).getLocation();
    assertThat(location.toString()).isEqualTo(cprootForTestContext + resourcePathWithinClasspathRoots);
    String q = "src/test/resources/nesteddir1/nesteddir2/testcsv12.csv";
    List<Content<?>> notfound = r.resolve(q);
    assertThat(notfound).isEmpty();
}
Also used : Content(io.nosqlbench.nb.api.content.Content) ResolverForClasspath(io.nosqlbench.nb.api.content.ResolverForClasspath) Test(org.junit.jupiter.api.Test)

Example 2 with Content

use of io.nosqlbench.nb.api.content.Content in project nosqlbench by nosqlbench.

the class ResolverForURLTest method testFileResource.

@Test
public void testFileResource() {
    String p = "src/test/resources/nesteddir1/nesteddir2/testcsv12.csv";
    ResolverForFilesystem r = new ResolverForFilesystem();
    List<Content<?>> c = r.resolve(p);
    assertThat(c).isNotNull();
    Object location = c.get(0).getLocation();
    assertThat(location).isInstanceOf(Path.class);
    assertThat(location.toString()).isEqualTo(p);
    String q = "nesteddir1/nesteddir2/testcsv12.csv";
    List<Content<?>> notfound = r.resolve(q);
    assertThat(notfound).isEmpty();
}
Also used : Content(io.nosqlbench.nb.api.content.Content) ResolverForFilesystem(io.nosqlbench.nb.api.content.ResolverForFilesystem) Test(org.junit.jupiter.api.Test)

Example 3 with Content

use of io.nosqlbench.nb.api.content.Content in project nosqlbench by nosqlbench.

the class ResolverForURLTest method testUrlResource.

@Test
public void testUrlResource() {
    ResolverForURL r = new ResolverForURL();
    List<Content<?>> c = r.resolve("http://google.com");
    assertThat(c).isNotNull();
    Object location = c.get(0).getLocation();
    assertThat(location).isInstanceOf(URL.class);
    assertThat(location.toString()).isEqualTo("http://google.com");
}
Also used : Content(io.nosqlbench.nb.api.content.Content) ResolverForURL(io.nosqlbench.nb.api.content.ResolverForURL) Test(org.junit.jupiter.api.Test)

Example 4 with Content

use of io.nosqlbench.nb.api.content.Content in project nosqlbench by nosqlbench.

the class DocsRootDirectory method getMarkdownInfo.

@Override
public List<Content<?>> getMarkdownInfo() {
    List<Content<?>> list = NBIO.local().name(getRootPathName()).list();
    NBIOWalker.CollectVisitor capture = new NBIOWalker.CollectVisitor(true, false);
    NBIOWalker.RegexFilter filter = new NBIOWalker.RegexFilter("\\.md", true);
    for (Content<?> content : list) {
        Path path = content.asPath();
        NBIOWalker.walkFullPath(path, capture, filter);
    }
    List<Content<?>> content = new ArrayList<>();
    for (Path path : capture.get()) {
        content.add(new PathContent(path));
    }
    return content;
}
Also used : Path(java.nio.file.Path) Content(io.nosqlbench.nb.api.content.Content) PathContent(io.nosqlbench.nb.api.content.PathContent) NBIOWalker(io.nosqlbench.nb.api.content.NBIOWalker) ArrayList(java.util.ArrayList) PathContent(io.nosqlbench.nb.api.content.PathContent)

Example 5 with Content

use of io.nosqlbench.nb.api.content.Content in project nosqlbench by nosqlbench.

the class WorkSpace method getWorkloadsWithScenarioScripts.

public List<WorkloadDesc> getWorkloadsWithScenarioScripts() {
    List<Content<?>> candidates = NBIO.fs().prefix(this.getWorkspacePath().toString()).extension(RawStmtsLoader.YAML_EXTENSIONS).list();
    List<WorkloadDesc> workloads = NBCLIScenarioParser.filterForScenarios(candidates);
    List<WorkloadDesc> relativized = new ArrayList<>();
    for (WorkloadDesc workload : workloads) {
        WorkloadDesc relative = workload.relativize(getWorkspacePath());
        relativized.add(relative);
    }
    return relativized;
}
Also used : Content(io.nosqlbench.nb.api.content.Content) ArrayList(java.util.ArrayList) WorkloadDesc(io.nosqlbench.engine.api.scenarios.WorkloadDesc)

Aggregations

Content (io.nosqlbench.nb.api.content.Content)12 BasicError (io.nosqlbench.nb.api.errors.BasicError)5 Path (java.nio.file.Path)5 NBIO (io.nosqlbench.nb.api.content.NBIO)3 Files (java.nio.file.Files)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 Test (org.junit.jupiter.api.Test)3 StatementsLoader (io.nosqlbench.engine.api.activityconfig.StatementsLoader)2 StmtsDocList (io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 CqlSessionBuilder (com.datastax.oss.driver.api.core.CqlSessionBuilder)1 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)1 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)1 OptionsMap (com.datastax.oss.driver.api.core.config.OptionsMap)1 TypedDriverOption (com.datastax.oss.driver.api.core.config.TypedDriverOption)1