Search in sources :

Example 11 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost in project qpid-broker-j by apache.

the class TrustStoreMessageSourceTest method setUp.

@Before
public void setUp() throws Exception {
    VirtualHost vhost = mock(VirtualHost.class);
    MessageStore messageStore = new TestMemoryMessageStore();
    TrustStore trustStore = mock(TrustStore.class);
    Certificate certificate = mock(Certificate.class);
    _certificates = new Certificate[] { certificate };
    when(vhost.getMessageStore()).thenReturn(messageStore);
    when(trustStore.getState()).thenReturn(State.ACTIVE);
    when(trustStore.getCertificates()).thenReturn(_certificates);
    when(certificate.getEncoded()).thenReturn("my certificate".getBytes());
    _trustStoreMessageSource = new TrustStoreMessageSource(trustStore, vhost);
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) TestMemoryMessageStore(org.apache.qpid.server.store.TestMemoryMessageStore) VirtualHost(org.apache.qpid.server.model.VirtualHost) TrustStore(org.apache.qpid.server.model.TrustStore) TestMemoryMessageStore(org.apache.qpid.server.store.TestMemoryMessageStore) Certificate(java.security.cert.Certificate) Before(org.junit.Before)

Example 12 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost in project qpid-broker-j by apache.

the class HouseKeepingTaskTest method runExecuteThrowsConnectionScopeRuntimeException.

@Test
public void runExecuteThrowsConnectionScopeRuntimeException() {
    final VirtualHost virualHost = mock(VirtualHost.class);
    final AccessControlContext context = AccessController.getContext();
    final HouseKeepingTask task = new HouseKeepingTask(getTestName(), virualHost, context) {

        @Override
        public void execute() {
            throw new ConnectionScopedRuntimeException("Test");
        }
    };
    task.run();
}
Also used : AccessControlContext(java.security.AccessControlContext) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) VirtualHost(org.apache.qpid.server.model.VirtualHost) Test(org.junit.Test)

Example 13 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost in project qpid-broker-j by apache.

the class VirtualHostPropertiesNodeTest method setUp.

@Before
public void setUp() throws Exception {
    VirtualHost vhost = mock(VirtualHost.class);
    MessageStore messageStore = new TestMemoryMessageStore();
    when(vhost.getMessageStore()).thenReturn(messageStore);
    _virtualHostPropertiesNode = new VirtualHostPropertiesNode(vhost);
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) TestMemoryMessageStore(org.apache.qpid.server.store.TestMemoryMessageStore) VirtualHost(org.apache.qpid.server.model.VirtualHost) TestMemoryMessageStore(org.apache.qpid.server.store.TestMemoryMessageStore) Before(org.junit.Before)

Example 14 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost 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)

Example 15 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost in project qpid-broker-j by apache.

the class ContentServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response, final ConfiguredObject<?> managedObject) throws IOException {
    ConfiguredObject root = managedObject;
    String pathInfo = request.getPathInfo();
    if (managedObject instanceof Broker && null != pathInfo && !pathInfo.isEmpty()) {
        final ConfiguredObjectFinder finder = getConfiguredObjectFinder(managedObject);
        final ConfiguredObject virtualHost = finder.findObjectFromPath(pathInfo.substring(1), VirtualHost.class);
        if (null == virtualHost) {
            sendError(response, HttpServletResponse.SC_NOT_FOUND);
            return;
        } else {
            root = virtualHost;
        }
    } else if (managedObject instanceof VirtualHost && null != pathInfo && !pathInfo.isEmpty()) {
        sendError(response, HttpServletResponse.SC_BAD_REQUEST);
        return;
    }
    final Map<String, String[]> parameters = request.getParameterMap();
    Content content = _contentFactory.createContent(root, parameters);
    try {
        writeContent(content, request, response);
    } finally {
        content.release();
    }
}
Also used : Broker(org.apache.qpid.server.model.Broker) Content(org.apache.qpid.server.model.Content) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectFinder(org.apache.qpid.server.model.ConfiguredObjectFinder) VirtualHost(org.apache.qpid.server.model.VirtualHost)

Aggregations

VirtualHost (org.apache.qpid.server.model.VirtualHost)16 Broker (org.apache.qpid.server.model.Broker)5 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 Test (org.junit.Test)4 Exchange (org.apache.qpid.server.model.Exchange)3 Queue (org.apache.qpid.server.model.Queue)3 HashMap (java.util.HashMap)2 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)2 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)2 Binding (org.apache.qpid.server.model.Binding)2 TrustStore (org.apache.qpid.server.model.TrustStore)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)2 MessageStore (org.apache.qpid.server.store.MessageStore)2 TestMemoryMessageStore (org.apache.qpid.server.store.TestMemoryMessageStore)2 Before (org.junit.Before)2 Cache (com.google.common.cache.Cache)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1