use of com.yahoo.athenz.common.server.db.PoolableDataSource in project athenz by yahoo.
the class JDBCCertRecordStoreTest method testGetConnectionException.
@Test
public void testGetConnectionException() throws SQLException {
PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
Mockito.doThrow(new SQLException()).when(mockDataSrc).getConnection();
try {
JDBCCertRecordStore store = new JDBCCertRecordStore(mockDataSrc);
store.getConnection();
fail();
} catch (RuntimeException ex) {
assertTrue(true);
}
}
use of com.yahoo.athenz.common.server.db.PoolableDataSource in project athenz by yahoo.
the class JDBCCertRecordStoreTest method testGetConnection.
@Test
public void testGetConnection() throws SQLException {
PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
Connection mockConn = Mockito.mock(Connection.class);
Mockito.doReturn(mockConn).when(mockDataSrc).getConnection();
JDBCCertRecordStore store = new JDBCCertRecordStore(mockDataSrc);
assertNotNull(store.getConnection());
store.clearConnections();
}
use of com.yahoo.athenz.common.server.db.PoolableDataSource in project athenz by yahoo.
the class JDBCSSHRecordStoreTest method testGetConnectionException.
@Test
public void testGetConnectionException() throws SQLException {
PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
Mockito.doThrow(new SQLException()).when(mockDataSrc).getConnection();
try {
JDBCSSHRecordStore store = new JDBCSSHRecordStore(mockDataSrc);
store.getConnection();
fail();
} catch (RuntimeException ex) {
assertTrue(true);
}
}
use of com.yahoo.athenz.common.server.db.PoolableDataSource in project athenz by yahoo.
the class JDBCSSHRecordStoreTest method testLog.
@Test
public void testLog() {
PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
JDBCSSHRecordStore store = new JDBCSSHRecordStore(mockDataSrc);
Principal principal = SimplePrincipal.create("user", "joe", "creds");
// make sure no exceptions are thrown when processing log request
store.log(principal, "10.11.12.13", "athenz.api", "1234");
}
use of com.yahoo.athenz.common.server.db.PoolableDataSource in project athenz by yahoo.
the class JDBCSSHRecordStoreTest method testEnableNotifications.
@Test
public void testEnableNotifications() {
PoolableDataSource mockDataSrc = Mockito.mock(PoolableDataSource.class);
JDBCSSHRecordStore store = new JDBCSSHRecordStore(mockDataSrc);
boolean isEnabled = store.enableNotifications(null, null, null);
assertFalse(isEnabled);
NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
RolesProvider rolesProvider = Mockito.mock(RolesProvider.class);
String serverName = "testServer";
isEnabled = store.enableNotifications(notificationManager, rolesProvider, serverName);
// Not supported for FileCertStore even if all dependencies provided
assertFalse(isEnabled);
}
Aggregations