use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerTest method contextInitialized_waitUntilStartedReturnsFalse_ExcThrown.
@Test(expected = BrokerLifecycleException.class)
public void contextInitialized_waitUntilStartedReturnsFalse_ExcThrown() throws Exception {
ServletContext sc = mock(ServletContext.class);
BrokerService broker = mock(BrokerService.class);
doReturn(false).when(broker).waitUntilStarted();
WebBrokerInitializer i = spy(WebBrokerInitializer.class);
doReturn(broker).when(i).createBroker(sc);
i.contextInitialized(new ServletContextEvent(sc));
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class KahaDBSupportTest method create.
@Test
public void create() throws Exception {
final String path = "target/kahatest" + System.currentTimeMillis();
final BrokerService broker = BrokerFactory.createBroker(new URI("openejb:broker:(tcp://localhost:" + NetworkUtil.getNextAvailablePort() + ")?usekahadb=true&kahadb.directory=" + path));
try {
assertThat(broker.getPersistenceAdapter(), instanceOf(KahaDBPersistenceAdapter.class));
final KahaDBPersistenceAdapter adapter = KahaDBPersistenceAdapter.class.cast(broker.getPersistenceAdapter());
assertEquals(new File(path), adapter.getDirectory());
} finally {
broker.stop();
}
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class OpenEjbBrokerFactoryTest method testLookupDataSource.
public void testLookupDataSource() throws Exception {
final Properties properties = new Properties();
final JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setDatabase("jdbc:hsqldb:mem:testdb" + System.currentTimeMillis());
dataSource.setUser("sa");
dataSource.setPassword("");
dataSource.getConnection().close();
MockInitialContextFactory.install(Collections.singletonMap("openejb/Resource/TestDs", dataSource));
assertSame(dataSource, new InitialContext().lookup("openejb/Resource/TestDs"));
final CoreContainerSystem containerSystem = new CoreContainerSystem(new IvmJndiFactory());
containerSystem.getJNDIContext().bind("openejb/Resource/TestDs", dataSource);
SystemInstance.get().setComponent(ContainerSystem.class, containerSystem);
properties.put("DataSource", "TestDs");
properties.put("UseDatabaseLock", "false");
properties.put("StartupTimeout", "10000");
ActiveMQFactory.setThreadProperties(properties);
BrokerService broker = null;
try {
broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
assertNotNull("broker is null", broker);
final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
assertNotNull("persistenceAdapter is null", persistenceAdapter);
assertTrue("persistenceAdapter should be an instance of JDBCPersistenceAdapter", persistenceAdapter instanceof JDBCPersistenceAdapter);
final JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter) persistenceAdapter;
assertSame(dataSource, jdbcPersistenceAdapter.getDataSource());
} finally {
stopBroker(broker);
ActiveMQFactory.setThreadProperties(null);
}
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class ActiveMQ5FactoryTest method duplex.
@Test
public void duplex() throws Exception {
final int port = getNextAvailablePort();
for (final boolean b : asList(true, false)) {
// broker:(tcp://localhost:${port})?networkConnectorURIs=static%3A%2F%2Ftcp%3A%2F%2Flocalhost%3A${port}%3Fduplex%3Dtrue
final URI brokerURI = new URI("amq5factory:broker:(tcp://localhost:" + port + ")?" + "networkConnectorURIs=" + URLEncoder.encode("static://tcp://localhost:" + port + "?duplex=" + b, "UTF-8"));
final BrokerService bs = new ActiveMQ5Factory().createBroker(brokerURI);
bs.stop();
ActiveMQ5Factory.brokers.remove(brokerURI);
final NetworkConnector nc = bs.getNetworkConnectors().iterator().next();
assertEquals("duplex is " + b, b, nc.isDuplex());
}
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class OpenEjbBrokerFactoryTest method testNoDataSource.
public void testNoDataSource() throws Exception {
final BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:" + brokerPort + ")?useJmx=false")));
assertNotNull("broker is null", broker);
final PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
assertNotNull("persistenceAdapter is null", persistenceAdapter);
assertTrue("persistenceAdapter should be an instance of MemoryPersistenceAdapter", persistenceAdapter instanceof MemoryPersistenceAdapter);
stopBroker(broker);
}
Aggregations