use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.
the class BDBVirtualHostImplTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
Broker broker = BrokerTestHelper.createBrokerMock();
TaskExecutor taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
when(broker.getTaskExecutor()).thenReturn(taskExecutor);
when(broker.getChildExecutor()).thenReturn(taskExecutor);
_storePath = TestFileUtils.createTestDirectory();
_node = mock(VirtualHostNode.class);
when(_node.getParent()).thenReturn(broker);
when(_node.getModel()).thenReturn(BrokerModel.getInstance());
when(_node.getTaskExecutor()).thenReturn(taskExecutor);
when(_node.getChildExecutor()).thenReturn(taskExecutor);
when(_node.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
when(_node.getId()).thenReturn(UUID.randomUUID());
}
use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.
the class OAuth2AuthenticationProviderImplTest method setUp.
@Before
public void setUp() throws Exception {
Path keyStore = TLS_RESOURCE.createSelfSignedKeyStore("CN=foo");
_server = new OAuth2MockEndpointHolder(keyStore.toFile().getAbsolutePath(), TLS_RESOURCE.getSecret(), TLS_RESOURCE.getKeyStoreType());
_server.start();
Broker broker = BrokerTestHelper.createBrokerMock();
TaskExecutor taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
when(broker.getTaskExecutor()).thenReturn(taskExecutor);
when(broker.getChildExecutor()).thenReturn(taskExecutor);
final Map<String, Object> authProviderAttributes = new HashMap<>();
authProviderAttributes.put(ConfiguredObject.NAME, "testOAuthProvider");
authProviderAttributes.put("clientId", TEST_CLIENT_ID);
authProviderAttributes.put("clientSecret", TEST_CLIENT_SECRET);
authProviderAttributes.put("identityResolverType", TEST_IDENTITY_RESOLVER_TYPE);
authProviderAttributes.put("authorizationEndpointURI", String.format(TEST_AUTHORIZATION_ENDPOINT_URI_PATTERN, TEST_ENDPOINT_HOST, _server.getPort(), TEST_AUTHORIZATION_ENDPOINT_PATH));
authProviderAttributes.put("tokenEndpointURI", String.format(TEST_TOKEN_ENDPOINT_URI_PATTERN, TEST_ENDPOINT_HOST, _server.getPort(), TEST_TOKEN_ENDPOINT_PATH));
authProviderAttributes.put("tokenEndpointNeedsAuth", TEST_AUTHORIZATION_ENDPOINT_NEEDS_AUTH);
authProviderAttributes.put("identityResolverEndpointURI", String.format(TEST_IDENTITY_RESOLVER_ENDPOINT_URI_PATTERN, TEST_ENDPOINT_HOST, _server.getPort(), TEST_IDENTITY_RESOLVER_ENDPOINT_PATH));
authProviderAttributes.put("postLogoutURI", String.format(TEST_POST_LOGOUT_URI_PATTERN, TEST_ENDPOINT_HOST, _server.getPort(), TEST_POST_LOGOUT_PATH));
authProviderAttributes.put("scope", TEST_SCOPE);
authProviderAttributes.put("trustStore", TEST_TRUST_STORE_NAME);
setTestSystemProperty(CachingAuthenticationProvider.AUTHENTICATION_CACHE_MAX_SIZE, "0");
_authProvider = new OAuth2AuthenticationProviderImpl(authProviderAttributes, broker);
_authProvider.open();
assertEquals("Could not successfully open authProvider", State.ACTIVE, _authProvider.getState());
final TrustManager[] trustingTrustManager = new TrustManager[] { new TrustingTrustManager() };
final SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustingTrustManager, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new BlindHostnameVerifier());
}
use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.
the class AbstractDurableConfigurationStoreTestCase method createTestExchange.
private Exchange<?> createTestExchange() {
Exchange exchange = mock(Exchange.class);
Map<String, Object> actualAttributes = new HashMap<>();
actualAttributes.put("name", getTestName());
actualAttributes.put("type", getTestName() + "Type");
actualAttributes.put("lifetimePolicy", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
when(exchange.getName()).thenReturn(getTestName());
when(exchange.getType()).thenReturn(getTestName() + "Type");
when(exchange.isAutoDelete()).thenReturn(true);
when(exchange.getId()).thenReturn(_exchangeId);
when(exchange.getCategoryClass()).thenReturn(Exchange.class);
when(exchange.isDurable()).thenReturn(true);
when(exchange.getObjectFactory()).thenReturn(_factory);
when(exchange.getModel()).thenReturn(_factory.getModel());
TaskExecutor taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
when(exchange.getTaskExecutor()).thenReturn(taskExecutor);
when(exchange.getChildExecutor()).thenReturn(taskExecutor);
ConfiguredObjectRecord exchangeRecord = mock(ConfiguredObjectRecord.class);
when(exchangeRecord.getId()).thenReturn(_exchangeId);
when(exchangeRecord.getType()).thenReturn(Exchange.class.getSimpleName());
when(exchangeRecord.getAttributes()).thenReturn(actualAttributes);
when(exchangeRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord.getId()));
when(exchange.asObjectRecord()).thenReturn(exchangeRecord);
when(exchange.getEventLogger()).thenReturn(new EventLogger());
return exchange;
}
use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.
the class BDBVirtualHostNodeTest method setUp.
@Before
public void setUp() throws Exception {
assumeThat(getVirtualHostNodeStoreType(), is(equalTo(VirtualHostNodeStoreType.BDB)));
_broker = BrokerTestHelper.createBrokerMock();
TaskExecutor taskExecutor = CurrentThreadTaskExecutor.newStartedInstance();
when(_broker.getTaskExecutor()).thenReturn(taskExecutor);
when(_broker.getChildExecutor()).thenReturn(taskExecutor);
_storePath = TestFileUtils.createTestDirectory();
}
use of org.apache.qpid.server.configuration.updater.TaskExecutor in project qpid-broker-j by apache.
the class ProtocolEngine_1_0_0Test method setUp.
@Before
public void setUp() throws Exception {
_networkConnection = mock(ServerNetworkConnection.class);
when(_networkConnection.getLocalAddress()).thenReturn(new InetSocketAddress(0));
when(_networkConnection.getSelectedHost()).thenReturn("localhost");
_broker = mock(Broker.class);
when(_broker.getModel()).thenReturn(BrokerModel.getInstance());
when(_broker.getNetworkBufferSize()).thenReturn(256 * 1026);
final TaskExecutor taskExecutor = new TaskExecutorImpl();
taskExecutor.start();
when(_broker.getChildExecutor()).thenReturn(taskExecutor);
when(_broker.getTaskExecutor()).thenReturn(taskExecutor);
when(_broker.getId()).thenReturn(UUID.randomUUID());
when(_broker.getEventLogger()).thenReturn(new EventLogger());
when(((Broker) _broker).getCategoryClass()).thenReturn(Broker.class);
_port = mock(AmqpPort.class);
when(_port.getChildExecutor()).thenReturn(taskExecutor);
when(_port.getCategoryClass()).thenReturn(Port.class);
when(_port.getModel()).thenReturn(BrokerModel.getInstance());
final SubjectCreator subjectCreator = mock(SubjectCreator.class);
_authenticationProvider = mock(AuthenticationProvider.class);
when(_port.getAuthenticationProvider()).thenReturn(_authenticationProvider);
_virtualHost = mock(VirtualHost.class);
when(_virtualHost.getChildExecutor()).thenReturn(taskExecutor);
when(_virtualHost.getModel()).thenReturn(BrokerModel.getInstance());
when(_virtualHost.getState()).thenReturn(State.ACTIVE);
when(_virtualHost.isActive()).thenReturn(true);
final ArgumentCaptor<AMQPConnection> connectionCaptor = ArgumentCaptor.forClass(AMQPConnection.class);
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
_connection = connectionCaptor.getValue();
throw new SoleConnectionEnforcementPolicyException(null, Collections.emptySet(), "abc1");
}
}).when(_virtualHost).registerConnection(connectionCaptor.capture());
when(_virtualHost.getPrincipal()).thenReturn(mock(VirtualHostPrincipal.class));
when(_port.getAddressSpace(anyString())).thenReturn(_virtualHost);
when(_port.getSubjectCreator(anyBoolean(), anyString())).thenReturn(subjectCreator);
final ArgumentCaptor<Principal> userCaptor = ArgumentCaptor.forClass(Principal.class);
when(subjectCreator.createSubjectWithGroups(userCaptor.capture())).then(new Answer<Subject>() {
@Override
public Subject answer(final InvocationOnMock invocation) throws Throwable {
Subject subject = new Subject();
subject.getPrincipals().add(userCaptor.getValue());
return subject;
}
});
final ByteBufferSender sender = mock(ByteBufferSender.class);
when(_networkConnection.getSender()).thenReturn(sender);
AMQPDescribedTypeRegistry registry = AMQPDescribedTypeRegistry.newInstance().registerTransportLayer().registerMessagingLayer().registerTransactionLayer().registerSecurityLayer();
_frameWriter = new FrameWriter(registry, new ByteBufferSender() {
@Override
public boolean isDirectBufferPreferred() {
return false;
}
@Override
public void send(final QpidByteBuffer msg) {
_protocolEngine_1_0_0.received(msg);
}
@Override
public void flush() {
}
@Override
public void close() {
}
});
}
Aggregations