Examples of ParameterizationBuilder


Examples of com.foundationdb.junit.ParameterizationBuilder

@RunWith(NamedParameterizedRunner.class)
public final class RowDataFormatTest {

    @NamedParameterizedRunner.TestParameters
    public static Collection<Parameterization> params() {
        ParameterizationBuilder builder = new ParameterizationBuilder();

        // fixed length
        builder.add(
                "id int => 1",
                new TableMaker() { public void make(NewTableBuilder b) { b.colInt("id"); } },
                fields(1L),
                "0x1B00 0000 4142 0200 0100 0000 0001 0000 0001 0000 0042 411B 0000 00"
        );
        builder.add(
                "id int => null",
                new TableMaker() { public void make(NewTableBuilder b) { b.colInt("id"); } },
                fields(NULL),
                "0x1700 0000 4142 0200 0100 0000 0201 0000 0042 4117 0000 00"
        );
        // var length
        builder.add(
                "name varchar(32) => str(1)",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32); } },
                fields(str(1)),
                "0x1A00 0000 4142 0200 0100 0000 0001 0000 0002 0130 4241 1A00 0000"
        );
        builder.add(
                "name varchar(32) => null",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32); } },
                fields(NULL),
                "0x1700 0000 4142 0200 0100 0000 0201 0000 0042 4117 0000 00"
        );
        builder.add(
                "name varchar(32) => str(32)",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32); } },
                fields(str(32)),
                "0x3900 0000 4142 0200 0100 0000 0001 0000 0021 2030 3132 3334 3536 3738 3930 3132 3334 3536 3738 "
                        +"3930 3132 3334 3536 3738 3930 3142 4139 0000 00"
        );
        builder.add(
                "name varchar(1024) => str(1)",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 1024); } },
                fields(str(1)),
                "0x1C00 0000 4142 0200 0100 0000 0001 0000 0003 0001 0030 4241 1C00 0000"
        );
        // mixed
        builder.add(
                "name varchar(32), id int => str(1), 1",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32).colInt("id"); } },
                fields(str(1), 1L),
                "0x1E00 0000 4142 0300 0100 0000 0001 0000 0002 0100 0000 0130 4241 1E00 0000"
        );
        builder.add(
                "id int, name varchar(32) => 1, str(1)",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32).colInt("id"); } },
                fields(str(1), 1L),
                "0x1E00 0000 4142 0300 0100 0000 0001 0000 0002 0100 0000 0130 4241 1E00 0000"
        );
        builder.add(
                "name varchar(32), id int => null, 1",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32).colInt("id"); } },
                fields(NULL, 1L),
                "0x1B00 0000 4142 0300 0100 0000 0201 0000 0001 0000 0042 411B 0000 00"
        );
        builder.add(
                "id int, name varchar(32) => 1, null",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32).colInt("id"); } },
                fields(NULL, 1L),
                "0x1B00 0000 4142 0300 0100 0000 0201 0000 0001 0000 0042 411B 0000 00"
        );
        builder.add(
                "id int, name varchar(32) => null, null",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32).colInt("id"); } },
                fields(NULL, NULL),
                "0x1700 0000 4142 0300 0100 0000 0601 0000 0042 4117 0000 00"
        );

        // charset
        builder.add(
                "name varchar(32) UTF => abc",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32, false, "UTF-8"); } },
                fields("abc"),
                "0x1C00 0000 4142 0200 0100 0000 0001 0000 0004 0361 6263 4241 1C00 0000"
        );
        builder.add(
                "name varchar(32) latin-1 => abc",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32, false, "ISO-8859-1"); } },
                fields("abc"),
                "0x1C00 0000 4142 0200 0100 0000 0001 0000 0004 0361 6263 4241 1C00 0000"
        );
        builder.add(
                "name varchar(32) UTF => cliche",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32, false, "UTF-8"); } },
                fields("cliché"),
                "0x2000 0000 4142 0200 0100 0000 0001 0000 0008 0763 6C69 6368 C3A9 4241 2000 0000"
        );
        builder.add(
                "name varchar(32) latin-1 => cliche",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32, false, "ISO-8859-1"); } },
                fields("cliché"),
                "0x1F00 0000 4142 0200 0100 0000 0001 0000 0007 0663 6C69 6368 E942 411F 0000 00"
        );
        builder.add(
                "name varchar(32) UTF => snowman",
                new TableMaker() { public void make(NewTableBuilder b) { b.colString("name", 32, false, "UTF-8"); } },
                fields("☃"),
                "0x1C00 0000 4142 0200 0100 0000 0001 0000 0004 03E2 9883 4241 1C00 0000"
        );

        return builder.asList();
    }
View Full Code Here

Examples of com.foundationdb.junit.ParameterizationBuilder

    @NamedParameterizedRunner.TestParameters
    public static Collection<Parameterization> statements() throws Exception {
        FileReader fileReader = new FileReader(SIMPLE_TEST);
        try {
            ParameterizationBuilder pb = new ParameterizationBuilder();
            BufferedReader buffered = new BufferedReader(fileReader);
            Yaml yaml = new Yaml();
            for (Object objRaw : yaml.loadAll(buffered)) {
                List<?> asList = (List<?>) objRaw;
                for (Object lineRaw : asList) {
                    Map<?,?> line = (Map<?,?>) lineRaw;
                    if (line.size() != 1)
                        throw new RuntimeException("need key-val pair:" + line);
                    String actionStr = (String) line.keySet().iterator().next();
                    String sql = (String) line.get(actionStr);

                    String name = sql;
                    if (name.startsWith("SELECT DISTINCT"))
                        name = name.substring("SELECT DISTINCT".length());

                    KeepOrOptimize action = KeepOrOptimize.valueOf(actionStr.toUpperCase());
                    pb.create(name, action != KeepOrOptimize.IGNORED, sql,  action);
                }
            }
            return pb.asList();
        }
        finally {
            fileReader.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.