Package com.asakusafw.testdriver.core

Examples of com.asakusafw.testdriver.core.DataModelSource


    @Test
    public void open_importer() throws Exception {
        DataModelSourceProvider provider = new SpiDataModelSourceProvider(getClass().getClassLoader());
        URI uri = new URI("windgate:" + MockImporter.class.getName());
        ValueDefinition<String> definition = ValueDefinition.of(String.class);
        DataModelSource source = provider.open(definition, uri, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(definition.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(definition.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(definition.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here


    @Test
    public void open_exporter() throws Exception {
        DataModelSourceProvider provider = new SpiDataModelSourceProvider(getClass().getClassLoader());
        URI uri = new URI("windgate:" + MockExporter.class.getName());
        ValueDefinition<String> definition = ValueDefinition.of(String.class);
        DataModelSource source = provider.open(definition, uri, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(definition.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(definition.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(definition.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

    @Test
    public void invalid_scheme() throws Exception {
        DataModelSourceProvider provider = new WindGateSourceProvider();
        URI uri = new URI("INVALIDwindgate:" + MockExporter.class.getName());
        ValueDefinition<String> definition = ValueDefinition.of(String.class);
        DataModelSource source = provider.open(definition, uri, EMPTY);
        assertThat(source, is(nullValue()));
    }
View Full Code Here

                String.class,
                "testing",
                driver);
        WindGateExporterRetriever retriever = new WindGateExporterRetriever();
        ValueDefinition<String> stringDef = ValueDefinition.of(String.class);
        DataModelSource source = retriever.createSource(stringDef, description, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(stringDef.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(stringDef.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(stringDef.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void simple() throws Exception {
        JsonSourceProvider provider = new JsonSourceProvider();
        DataModelSource source = provider.open(SIMPLE, uri("simple.json"), new TestContext.Empty());
        assertThat(source, not(nullValue()));
        try {
            Simple s1 = SIMPLE.toObject(source.next());
            assertThat(s1.number, is(100));
            assertThat(source.next(), is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void spi() throws Exception {
        DataModelSourceProvider provider = new SpiDataModelSourceProvider(JsonSourceProvider.class.getClassLoader());
        DataModelSource source = provider.open(SIMPLE, uri("simple.json"), new TestContext.Empty());
        assertThat(source, not(nullValue()));
        try {
            Simple s1 = SIMPLE.toObject(source.next());
            assertThat(s1.number, is(100));
            assertThat(source.next(), is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void invalid_extension() throws Exception {
        JsonSourceProvider provider = new JsonSourceProvider();
        DataModelSource source = provider.open(SIMPLE, uri("simple.txt"), new TestContext.Empty());
        assertThat(source, is(nullValue()));
    }
View Full Code Here

        profile.put();

        put("base/output.txt", "Hello, world!");

        DirectFileOutputRetriever testee = new DirectFileOutputRetriever();
        DataModelSource input = testee.createSource(
                new MockTextDefinition(),
                new MockOutputDescription("base", "output.txt", format),
                profile.getTextContext());
        List<String> list = get(input);
        assertThat(list, is(Arrays.asList("Hello, world!")));
View Full Code Here

        profile.put();

        put("base/output.txt", "Hello1", "Hello2", "Hello3");

        DirectFileOutputRetriever testee = new DirectFileOutputRetriever();
        DataModelSource input = testee.createSource(
                new MockTextDefinition(),
                new MockOutputDescription("base", "output.txt", format),
                profile.getTextContext());

        List<String> list = get(input);
View Full Code Here

        put("base/output-1.txt", "Hello1");
        put("base/output-2.txt", "Hello2");
        put("base/output-3.txt", "Hello3");

        DirectFileOutputRetriever testee = new DirectFileOutputRetriever();
        DataModelSource input = testee.createSource(
                new MockTextDefinition(),
                new MockOutputDescription("base", "{value}.txt", format),
                profile.getTextContext());

        List<String> list = get(input);
View Full Code Here

TOP

Related Classes of com.asakusafw.testdriver.core.DataModelSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.