Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.StringOption


     * stringの値を解析するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void fillString() throws Exception {
        StringOption value = new StringOption();
        create("string");

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.getAsString(), is(""));
        parser.fill(value);
        assertThat(value.getAsString(), is("Hello, world!"));
        parser.fill(value);
        assertThat(value.getAsString(), is("こんにちは、世界!"));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.getAsString(), is("\n\t\\"));
        parser.fill(value);
        assertThat(value.getAsString(), is(LONG_STRING));
        parser.endRecord();

        assertThat(parser.next(), is(false));
    }
View Full Code Here


        Mock() {
            super(StringOption.class, StringOption.class);
        }

        Mock(String group, String order) {
            super(new StringOption(group), new StringOption(order));
        }
View Full Code Here

        ((LongOption) tuple.get(1)).modify(200L);
        ((StringOption) tuple.get(2)).modify("Hello, world!");

        assertThat(tuple.get(0), is((Object) new IntOption(100)));
        assertThat(tuple.get(1), is((Object) new LongOption(200L)));
        assertThat(tuple.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

    @Test
    public void createFromObjects() throws Exception {
        WritableRawComparableTuple tuple = new WritableRawComparableTuple(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));

        assertThat(tuple.get(0), is((Object) new IntOption(100)));
        assertThat(tuple.get(1), is((Object) new LongOption(200L)));
        assertThat(tuple.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

    @Test
    public void serialize() throws Exception {
        WritableRawComparableTuple tuple = new WritableRawComparableTuple(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));

        WritableRawComparableTuple restored = new WritableRawComparableTuple(
                IntOption.class,
                LongOption.class,
                StringOption.class);

        byte[] serialized = ser(tuple);
        des(restored, serialized);

        assertThat(restored.get(0), is((Object) new IntOption(100)));
        assertThat(restored.get(1), is((Object) new LongOption(200L)));
        assertThat(restored.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void matrix() throws Exception {
        CsvEmitter emitter = createEmitter();
        emitter.emit(new StringOption("a-1"));
        emitter.emit(new StringOption("a-2"));
        emitter.emit(new StringOption("a-3"));
        emitter.endRecord();
        emitter.emit(new StringOption("b-1"));
        emitter.emit(new StringOption("b-2"));
        emitter.emit(new StringOption("b-3"));
        emitter.endRecord();
        emitter.emit(new StringOption("c-1"));
        emitter.emit(new StringOption("c-2"));
        emitter.emit(new StringOption("c-3"));
        emitter.endRecord();
        emitter.close();

        CsvParser parser = createParser();
        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("a-1")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("a-2")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("a-3")));
        parser.endRecord();
        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("b-1")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("b-2")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("b-3")));
        parser.endRecord();
        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("c-1")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("c-2")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("c-3")));
        parser.endRecord();

        assertThat(parser.next(), is(false));
        parser.close();
    }
View Full Code Here

     */
    @Test
    public void with_header() throws Exception {
        headers = Arrays.asList("key", "value");
        CsvEmitter emitter = createEmitter();
        emitter.emit(new StringOption("a"));
        emitter.emit(new StringOption("b"));
        emitter.endRecord();
        emitter.close();

        // directly read a header
        headers = Arrays.asList();
        CsvParser parser = createParser();

        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("key")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("value")));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("a")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("b")));
        parser.endRecord();

        assertThat(parser.next(), is(false));
        parser.close();
    }
View Full Code Here

     */
    @Test
    public void with_malformed_header() throws Exception {
        headers = Arrays.asList("\"malformed,\r\nheader\"", "");
        CsvEmitter emitter = createEmitter();
        emitter.emit(new StringOption("a"));
        emitter.emit(new StringOption("b"));
        emitter.endRecord();
        emitter.close();

        // directly read a header
        headers = Arrays.asList();
        CsvParser parser = createParser();

        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("\"malformed,\r\nheader\"")));
        assertThat(fill(parser, new StringOption()), is(new StringOption()));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("a")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("b")));
        parser.endRecord();

        assertThat(parser.next(), is(false));
        parser.close();
    }
View Full Code Here

        // directly read a header
        headers = Arrays.asList();
        CsvParser parser = createParser();

        assertThat(parser.next(), is(true));
        assertThat(fill(parser, new StringOption()), is(new StringOption("key")));
        assertThat(fill(parser, new StringOption()), is(new StringOption("value")));
        parser.endRecord();

        assertThat(parser.next(), is(false));
        parser.close();
    }
View Full Code Here

                path,
                0,
                fs.getFileStatus(path).getLen(),
                new Counter());
        try {
            StringOption value = new StringOption();
            for (int i = 0; i < count; i++) {
                String answer = "Hello, world at " + i;
                assertThat(answer, in.readTo(value), is(true));
                assertThat(value.getAsString(), is(answer));
            }
            assertThat("eof", in.readTo(value), is(false));
        } finally {
            in.close();
        }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.StringOption

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.