use of org.sql2o.quirks.NoQuirks in project sql2o by aaberg.
the class ConnectionTransactionTest method beginTransaction.
@Test
public void beginTransaction() throws Exception {
final DataSource dataSource = mock(DataSource.class);
final java.sql.Connection connectionMock = mock(Connection.class);
// mocked behaviour
when(dataSource.getConnection()).thenReturn(connectionMock);
when(connectionMock.getAutoCommit()).thenReturn(true);
when(connectionMock.isClosed()).thenReturn(false);
final Sql2o sql2o = new Sql2o(dataSource, new NoQuirks());
final org.sql2o.Connection sql2oConnection = sql2o.beginTransaction();
sql2oConnection.close();
// Verifications
verify(dataSource).getConnection();
verify(connectionMock, atLeastOnce()).getAutoCommit();
// called on beginTransaction
verify(connectionMock, times(1)).setAutoCommit(eq(false));
// called on closeConnection to reset autocommit state
verify(connectionMock, times(1)).setAutoCommit(eq(true));
verify(connectionMock, atLeastOnce()).setTransactionIsolation(anyInt());
verify(connectionMock, times(1)).isClosed();
verify(connectionMock, times(1)).close();
verifyNoMoreInteractions(connectionMock, dataSource);
}
use of org.sql2o.quirks.NoQuirks in project sql2o by aaberg.
the class BidirectionalConverterTest method setUp.
@Before
public void setUp() {
Quirks quirks = new NoQuirks() {
{
this.converters.put(UUID.class, new CustomUUIDConverter());
}
};
this.sql2o = new Sql2o("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "", quirks);
this.wrappers = randomWrappers();
this.createAndFillTable(this.wrappers);
}
use of org.sql2o.quirks.NoQuirks in project runelite by runelite.
the class SpringBootWebApplicationTest method cacheSql2o.
@Bean("Runelite Cache SQL2O")
Sql2o cacheSql2o() throws NamingException {
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/cache", "runelite", "runelite", new NoQuirks(converters));
}
use of org.sql2o.quirks.NoQuirks in project runelite by runelite.
the class SpringBootWebApplicationTest method xpSql2o.
@Bean("Runelite XP Tracker SQL2O")
Sql2o xpSql2o() throws NamingException {
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/xptracker", "runelite", "runelite", new NoQuirks(converters));
}
use of org.sql2o.quirks.NoQuirks in project runelite by runelite.
the class SpringBootWebApplicationTest method sql2o.
@Bean("Runelite SQL2O")
Sql2o sql2o() {
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/runelite", "runelite", "runelite", new NoQuirks(converters));
}
Aggregations