Search in sources :

Example 1 with JDBCContainer

use of org.apache.qpid.server.store.jdbc.JDBCContainer in project qpid-broker-j by apache.

the class JDBCVirtualHostNodeTest method testDeleteAction.

@Test
public void testDeleteAction() {
    _connectionURL = "jdbc:derby:memory:/" + getTestName();
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(ConfiguredObject.NAME, getTestName());
    attributes.put(ConfiguredObject.TYPE, JDBCVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE);
    attributes.put("connectionUrl", _connectionURL + ";create=true");
    Broker<?> broker = BrokerTestHelper.createBrokerMock();
    final VirtualHostNode virtualHostNode = broker.getObjectFactory().create(VirtualHostNode.class, attributes, broker);
    virtualHostNode.start();
    AtomicBoolean deleted = new AtomicBoolean();
    ((JDBCContainer) virtualHostNode).addDeleteAction(object -> deleted.set(true));
    virtualHostNode.delete();
    assertEquals("Delete action was not invoked", true, deleted.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) JDBCContainer(org.apache.qpid.server.store.jdbc.JDBCContainer) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) Test(org.junit.Test)

Example 2 with JDBCContainer

use of org.apache.qpid.server.store.jdbc.JDBCContainer in project qpid-broker-j by apache.

the class JDBCLinkStoreTest method createLinkStore.

@Override
protected LinkStore createLinkStore() {
    final JDBCDetails details = mock(JDBCDetails.class);
    when(details.getBlobType()).thenReturn("blob");
    when(details.getTimestampType()).thenReturn("timestamp");
    when(details.isUseBytesMethodsForBlob()).thenReturn(false);
    JDBCContainer jdbcContainer = mock(JDBCContainer.class);
    when(jdbcContainer.getJDBCDetails()).thenReturn(details);
    when(jdbcContainer.getTableNamePrefix()).thenReturn("testTablePrefix");
    when(jdbcContainer.getConnection()).thenAnswer(invocation -> DriverManager.getConnection(getUrl() + ";create=true"));
    return new JDBCLinkStore(jdbcContainer);
}
Also used : JDBCDetails(org.apache.qpid.server.store.jdbc.JDBCDetails) JDBCContainer(org.apache.qpid.server.store.jdbc.JDBCContainer)

Example 3 with JDBCContainer

use of org.apache.qpid.server.store.jdbc.JDBCContainer in project qpid-broker-j by apache.

the class JDBCVirtualHostTest method testDeleteAction.

@Test
public void testDeleteAction() {
    _connectionURL = "jdbc:derby:memory:/" + getTestName();
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(ConfiguredObject.NAME, getTestName());
    attributes.put(ConfiguredObject.TYPE, JDBCVirtualHostImpl.VIRTUAL_HOST_TYPE);
    attributes.put("connectionUrl", _connectionURL + ";create=true");
    final VirtualHost vh = BrokerTestHelper.createVirtualHost(attributes, this);
    AtomicBoolean deleted = new AtomicBoolean();
    ((JDBCContainer) vh).addDeleteAction(object -> deleted.set(true));
    vh.delete();
    assertEquals("Delete action was not invoked", true, deleted.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) JDBCContainer(org.apache.qpid.server.store.jdbc.JDBCContainer) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost) Test(org.junit.Test)

Aggregations

JDBCContainer (org.apache.qpid.server.store.jdbc.JDBCContainer)3 HashMap (java.util.HashMap)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 Test (org.junit.Test)2 VirtualHost (org.apache.qpid.server.model.VirtualHost)1 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)1 JDBCDetails (org.apache.qpid.server.store.jdbc.JDBCDetails)1