Search in sources :

Example 6 with Servers

use of com.github.fabriciofx.cactoos.jdbc.Servers in project cactoos-jdbc by fabriciofx.

the class PhonebookTest method renameContact.

@Test
public void renameContact() throws Exception {
    try (Servers servers = new Servers(new ServerH2(new ScriptSql(new ResourceOf(new Joined("/", "com/github/fabriciofx/cactoos/jdbc/phonebook", "phonebook-h2.sql")))), new ServerPgsql(new ScriptSql(new ResourceOf(new Joined("/", "com/github/fabriciofx/cactoos/jdbc/phonebook", "phonebook-pgsql.sql")))))) {
        for (final Session session : servers.sessions()) {
            final Phonebook phonebook = new PhonebookSql(session);
            final Contact contact = phonebook.filter("maria").iterator().next();
            contact.update(new MapOf<String, String>(new MapEntry<>("name", "Maria Lima")));
            MatcherAssert.assertThat(XhtmlMatchers.xhtml(new PhonebookSql(session).filter("maria").iterator().next().about()), XhtmlMatchers.hasXPaths("/contact/name[text()='Maria Lima']"));
        }
    }
}
Also used : ServerH2(com.github.fabriciofx.cactoos.jdbc.server.ServerH2) MapEntry(org.cactoos.map.MapEntry) PhonebookSql(com.github.fabriciofx.cactoos.jdbc.phonebook.sql.PhonebookSql) Servers(com.github.fabriciofx.cactoos.jdbc.Servers) ServerPgsql(com.github.fabriciofx.cactoos.jdbc.server.ServerPgsql) Contact(com.github.fabriciofx.cactoos.jdbc.phonebook.Contact) ScriptSql(com.github.fabriciofx.cactoos.jdbc.script.ScriptSql) Phonebook(com.github.fabriciofx.cactoos.jdbc.phonebook.Phonebook) ResourceOf(org.cactoos.io.ResourceOf) Joined(org.cactoos.text.Joined) Session(com.github.fabriciofx.cactoos.jdbc.Session) Test(org.junit.Test)

Aggregations

Servers (com.github.fabriciofx.cactoos.jdbc.Servers)6 Session (com.github.fabriciofx.cactoos.jdbc.Session)6 ServerH2 (com.github.fabriciofx.cactoos.jdbc.server.ServerH2)6 ServerPgsql (com.github.fabriciofx.cactoos.jdbc.server.ServerPgsql)6 Joined (org.cactoos.text.Joined)6 Test (org.junit.Test)6 ParamInt (com.github.fabriciofx.cactoos.jdbc.param.ParamInt)4 ParamText (com.github.fabriciofx.cactoos.jdbc.param.ParamText)4 QuerySimple (com.github.fabriciofx.cactoos.jdbc.query.QuerySimple)4 ServerMysql (com.github.fabriciofx.cactoos.jdbc.server.ServerMysql)4 ParamsNamed (com.github.fabriciofx.cactoos.jdbc.params.ParamsNamed)3 QueryBatch (com.github.fabriciofx.cactoos.jdbc.query.QueryBatch)3 ParamBool (com.github.fabriciofx.cactoos.jdbc.param.ParamBool)2 ParamDate (com.github.fabriciofx.cactoos.jdbc.param.ParamDate)2 ParamDecimal (com.github.fabriciofx.cactoos.jdbc.param.ParamDecimal)2 Contact (com.github.fabriciofx.cactoos.jdbc.phonebook.Contact)2 Phonebook (com.github.fabriciofx.cactoos.jdbc.phonebook.Phonebook)2 PhonebookSql (com.github.fabriciofx.cactoos.jdbc.phonebook.sql.PhonebookSql)2 ScriptSql (com.github.fabriciofx.cactoos.jdbc.script.ScriptSql)2 ResourceOf (org.cactoos.io.ResourceOf)2