Package com.asakusafw.testdriver.core

Examples of com.asakusafw.testdriver.core.DataModelSink


        File file = temp.newFile("example.xls");
        file.delete();

        DataModelSinkFactory factory = repo.getDataModelSinkFactory(file.toURI());
        DataModelSink sink = factory.createSink(SIMPLE, new TestContext.Empty());
        try {
            Simple model = new Simple();
            model.text = "expected";
            sink.put(SIMPLE.toReflection(model));
        } finally {
            sink.close();
        }
        assertThat(file.exists(), is(true));
    }
View Full Code Here


        File file = temp.newFile("example.INVALID");
        file.delete();

        DataModelSinkFactory factory = repo.getDataModelSinkFactory(file.toURI());
        try {
            DataModelSink sink = factory.createSink(SIMPLE, new TestContext.Empty());
            sink.close();
            fail();
        } catch (IOException e) {
            // ok.
        }
    }
View Full Code Here

        assertThat(container.delete(), is(true));

        assertThat(file.isFile(), is(false));

        ExcelSheetSinkFactory factory = new ExcelSheetSinkFactory(file);
        DataModelSink sink = factory.createSink(SIMPLE, new TestContext.Empty());
        try {
            sink.put(SIMPLE.toReflection(new Simple()));
        } finally {
            sink.close();
        }
        assertThat(file.isFile(), is(true));
    }
View Full Code Here

        }
        ArrayModelDefinition def = new ArrayModelDefinition(map);

        File file = folder.newFile("temp.xls");
        ExcelSheetSinkFactory factory = new ExcelSheetSinkFactory(file);
        DataModelSink sink = factory.createSink(def, new TestContext.Empty());
        try {
            sink.put(def.toReflection(value));
        } finally {
            sink.close();
        }

        InputStream in = new FileInputStream(file);
        try {
            Workbook workbook = Util.openWorkbookFor(file.getPath(), in);
View Full Code Here

    private void verify(String file, String extension) throws IOException {
        Set<DataModelReflection> expected = collect(open(file));
        File temp = folder.newFile("temp" + extension);
        ExcelSheetSinkFactory factory = new ExcelSheetSinkFactory(temp);
        DataModelSink sink = factory.createSink(SIMPLE, new TestContext.Empty());
        try {
            for (DataModelReflection model : expected) {
                sink.put(model);
            }
        } finally {
            sink.close();
        }

        Set<DataModelReflection> actual = collect(open(temp.toURI().toURL()));
        assertThat(actual, is(expected));
    }
View Full Code Here

        }
    }

    private void insert(DataModelSinkFactory sinkFactory, String... values) {
        try {
            DataModelSink sink = sinkFactory.createSink(DEFINITION, CONTEXT);
            try {
                for (Text text : list(values)) {
                    sink.put(DEFINITION.toReflection(text));
                }
            } finally {
                sink.close();
            }
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    }
View Full Code Here

        }
    }

    private void checkInstance(DataModelSinkFactory factory, DataModelSink instance) {
        try {
            DataModelSink sink = factory.createSink(DEFINITION, CONTEXT);
            try {
                assertThat(sink, is(sameInstance(instance)));
            } finally {
                sink.close();
            }
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    }
View Full Code Here

TOP

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

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.