use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testListRolesInvalidDomain.
@Test
public void testListRolesInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(// this one is for domain id
false);
try {
jdbcConn.listRoles("my-domain");
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testCountPoliciesNoResult.
@Test
public void testCountPoliciesNoResult() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
// return domain/count
Mockito.when(mockResultSet.getInt(1)).thenReturn(5);
Mockito.when(mockResultSet.next()).thenReturn(true).thenReturn(false);
assertEquals(jdbcConn.countPolicies("my-domain"), 0);
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testProcessInsertUriValue.
@Test
public void testProcessInsertUriValue() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
assertEquals("http://server.athenzcompany.com", jdbcConn.processInsertValue("http://server.athenzcompany.com"));
assertEquals("", jdbcConn.processInsertValue((String) null));
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testCountEntitiesInvalidDomain.
@Test
public void testCountEntitiesInvalidDomain() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
Mockito.when(mockResultSet.next()).thenReturn(// this one is for domain id
false);
try {
jdbcConn.countEntities("my-domain");
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
use of com.yahoo.athenz.zms.store.jdbc.JDBCConnection in project athenz by yahoo.
the class JDBCConnectionTest method testUpdatePublicKeyEntryException.
@Test
public void testUpdatePublicKeyEntryException() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
PublicKeyEntry publicKey = new PublicKeyEntry().setId("zms1").setKey("Value1");
Mockito.when(mockResultSet.getInt(1)).thenReturn(// domain id
5).thenReturn(// service id
7);
Mockito.when(mockResultSet.next()).thenReturn(// this one is for domain id
true).thenReturn(// this one is for service id
true);
Mockito.when(mockPrepStmt.executeUpdate()).thenThrow(new SQLException("failed operation", "state", 1001));
try {
jdbcConn.updatePublicKeyEntry("my-domain", "service1", publicKey);
fail();
} catch (Exception ex) {
assertTrue(true);
}
jdbcConn.close();
}
Aggregations