@@ -0,0 +1,1391 @@
+package org.jdbi.v3.pg;%0A%0Aimport com.opentable.db.postgres.embedded.EmbeddedPostgreSQLRule;%0A%0Aimport org.jdbi.v3.DBI;%0Aimport org.jdbi.v3.Handle;%0Aimport org.junit.rules.TestRule;%0Aimport org.junit.runner.Description;%0Aimport org.junit.runners.model.Statement;%0A%0A/**%0A * Helper for a single, superuser privileged Postgres database.%0A */%0Apublic class PostgresDbRule implements TestRule %7B%0A%0A    public EmbeddedPostgreSQLRule pg = new EmbeddedPostgreSQLRule();%0A    private DBI dbi;%0A    private Handle h;%0A%0A    @Override%0A    public Statement apply(Statement base, Description description) %7B%0A        return pg.apply(new Statement() %7B%0A            @Override%0A            public void evaluate() throws Throwable %7B%0A                dbi = DBI.create(pg.getEmbeddedPostgreSQL().getDatabase(%22postgres%22, %22postgres%22))%0A                        .installPlugin(new PostgresJdbiPlugin());%0A                h = dbi.open();%0A%0A                try %7B%0A                    base.evaluate();%0A                %7D finally %7B%0A                    dbi = null;%0A                    h.close();%0A                    h = null;%0A                %7D%0A            %7D%0A        %7D, description);%0A    %7D%0A%0A    public DBI getDbi() %7B%0A        if (dbi == null) throw new AssertionError(%22Test not running%22);%0A        return dbi;%0A    %7D%0A%0A    public Handle getSharedHandle() %7B%0A        if (h == null) throw new AssertionError(%22Test not running%22);%0A        return h;%0A    %7D%0A%7D%0A

Add a Rule to make writing tests easy