congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
BrokerRunning.getConnectionFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
getConnectionFactory
method
in
org.springframework.amqp.rabbit.junit.BrokerRunning

Best Java code snippets using org.springframework.amqp.rabbit.junit.BrokerRunning.getConnectionFactory (Showing top 20 results out of 315)

origin: spring-projects/spring-integration

@Bean
public ConnectionFactory connectionFactory() {
  return new CachingConnectionFactory(brokerRunning.getConnectionFactory());
}
origin: spring-projects/spring-amqp

public RabbitAvailableCTORInjectionTests(BrokerRunning brokerRunning) {
  this.connectionFactory = brokerRunning.getConnectionFactory();
}
origin: eclipse/hawkbit

@Bean
BrokerRunning brokerRunning(final RabbitMqSetupService rabbitmqSetupService) {
  final BrokerRunning brokerRunning = BrokerRunning.isRunning();
  brokerRunning.setHostName(rabbitmqSetupService.getHostname());
  brokerRunning.getConnectionFactory().setUsername(rabbitmqSetupService.getUsername());
  brokerRunning.getConnectionFactory().setPassword(rabbitmqSetupService.getPassword());
  return brokerRunning;
}
origin: spring-projects/spring-amqp

public void isUp() throws IOException, TimeoutException, URISyntaxException {
  Connection connection = getConnectionFactory().newConnection(); // NOSONAR - closeResources()
  Channel channel = null;
  try {
    channel = createQueues(connection);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: org.springframework.amqp/spring-rabbit-junit

public void isUp() throws IOException, TimeoutException, URISyntaxException {
  Connection connection = getConnectionFactory().newConnection(); // NOSONAR - closeResources()
  Channel channel = null;
  try {
    channel = createQueues(connection);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: org.eclipse.hawkbit/hawkbit-dmf-rabbitmq-test

@Bean
BrokerRunning brokerRunning(final RabbitMqSetupService rabbitmqSetupService) {
  final BrokerRunning brokerRunning = BrokerRunning.isRunning();
  brokerRunning.setHostName(rabbitmqSetupService.getHostname());
  brokerRunning.getConnectionFactory().setUsername(rabbitmqSetupService.getUsername());
  brokerRunning.getConnectionFactory().setPassword(rabbitmqSetupService.getPassword());
  return brokerRunning;
}
origin: spring-projects/spring-amqp

@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context)
    throws ParameterResolutionException {
  // in parent for method injection, Composite key causes a store miss
  BrokerRunning brokerRunning =
      getParentStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class) == null
        ? getStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class)
        : getParentStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class);
  Assert.state(brokerRunning != null, "Could not find brokerRunning instance");
  Class<?> type = parameterContext.getParameter().getType();
  return type.equals(ConnectionFactory.class) ? brokerRunning.getConnectionFactory()
      : brokerRunning;
}
origin: org.springframework.amqp/spring-rabbit-junit

@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context)
    throws ParameterResolutionException {
  // in parent for method injection, Composite key causes a store miss
  BrokerRunning brokerRunning =
      getParentStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class) == null
        ? getStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class)
        : getParentStore(context).get(BROKER_RUNNING_BEAN, BrokerRunning.class);
  Assert.state(brokerRunning != null, "Could not find brokerRunning instance");
  Class<?> type = parameterContext.getParameter().getType();
  return type.equals(ConnectionFactory.class) ? brokerRunning.getConnectionFactory()
      : brokerRunning;
}
origin: spring-projects/spring-amqp

@Bean
public CachingConnectionFactory cf() {
  return new CachingConnectionFactory(
      RabbitAvailableCondition.getBrokerRunning().getConnectionFactory());
}
origin: spring-projects/spring-amqp

@Bean
public CachingConnectionFactory cf() {
  return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning()
      .getConnectionFactory());
}
origin: spring-projects/spring-amqp

@Bean
public ConnectionFactory connectionFactory() {
  return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning().getConnectionFactory());
}
origin: spring-projects/spring-amqp

@Bean
public CachingConnectionFactory ccf() {
  return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning().getConnectionFactory());
}
origin: spring-projects/spring-amqp

/**
 * Delete arbitrary exchanges from the broker.
 * @param exchanges the exchanges to delete.
 */
public void deleteExchanges(String... exchanges) {
  Connection connection = null; // NOSONAR (closeResources())
  Channel channel = null;
  try {
    connection = getConnection(getConnectionFactory());
    connection.setId(generateId() + ".exchangeDelete");
    channel = connection.createChannel();
    for (String exchange : exchanges) {
      channel.exchangeDelete(exchange);
    }
  }
  catch (Exception e) {
    logger.warn("Failed to delete queues", e);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: org.springframework.amqp/spring-rabbit-junit

/**
 * Delete arbitrary exchanges from the broker.
 * @param exchanges the exchanges to delete.
 */
public void deleteExchanges(String... exchanges) {
  Connection connection = null; // NOSONAR (closeResources())
  Channel channel = null;
  try {
    connection = getConnection(getConnectionFactory());
    connection.setId(generateId() + ".exchangeDelete");
    channel = connection.createChannel();
    for (String exchange : exchanges) {
      channel.exchangeDelete(exchange);
    }
  }
  catch (Exception e) {
    logger.warn("Failed to delete queues", e);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: spring-projects/spring-amqp

/**
 * Delete arbitrary queues from the broker.
 * @param queues the queues to delete.
 */
public void deleteQueues(String... queues) {
  Connection connection = null; // NOSONAR (closeResources())
  Channel channel = null;
  try {
    connection = getConnection(getConnectionFactory());
    connection.setId(generateId() + ".queueDelete");
    channel = connection.createChannel();
    for (String queue : queues) {
      channel.queueDelete(queue);
    }
  }
  catch (Exception e) {
    logger.warn("Failed to delete queues", e);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: org.springframework.amqp/spring-rabbit-junit

/**
 * Delete arbitrary queues from the broker.
 * @param queues the queues to delete.
 */
public void deleteQueues(String... queues) {
  Connection connection = null; // NOSONAR (closeResources())
  Channel channel = null;
  try {
    connection = getConnection(getConnectionFactory());
    connection.setId(generateId() + ".queueDelete");
    channel = connection.createChannel();
    for (String queue : queues) {
      channel.queueDelete(queue);
    }
  }
  catch (Exception e) {
    logger.warn("Failed to delete queues", e);
  }
  finally {
    closeResources(connection, channel);
  }
}
origin: spring-projects/spring-amqp

@Test
public void testEnvironmentVars() {
  Map<String, String> vars = new HashMap<>();
  vars.put("RABBITMQ_TEST_ADMIN_PASSWORD", "FOO");
  vars.put("RABBITMQ_TEST_ADMIN_URI", "http://foo/bar");
  vars.put("RABBITMQ_TEST_ADMIN_USER", "BAR");
  vars.put("RABBITMQ_TEST_HOSTNAME", "BAZ");
  vars.put("RABBITMQ_TEST_PASSWORD", "QUX");
  vars.put("RABBITMQ_TEST_PORT", "2345");
  vars.put("RABBITMQ_TEST_USER", "FIZ");
  BrokerRunning.setEnvironmentVariableOverrides(vars);
  BrokerRunning brokerRunning = BrokerRunning.isBrokerAndManagementRunning();
  assertEquals("http://foo/bar", brokerRunning.getAdminUri());
  ConnectionFactory connectionFactory = brokerRunning.getConnectionFactory();
  assertEquals("BAZ", connectionFactory.getHost());
  assertEquals(2345, connectionFactory.getPort());
  assertEquals("FIZ", connectionFactory.getUsername());
  assertEquals("QUX", connectionFactory.getPassword());
  DirectFieldAccessor dfa = new DirectFieldAccessor(brokerRunning);
  assertEquals("BAR", dfa.getPropertyValue("adminUser"));
  assertEquals("FOO", dfa.getPropertyValue("adminPassword"));
  BrokerRunning.clearEnvironmentVariableOverrides();
}
origin: spring-projects/spring-amqp

@Test
public void testArgumentsQueue() throws Exception {
  Queue queue = beanFactory.getBean("arguments", Queue.class);
  assertNotNull(queue);
  CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
      brokerIsRunning.getConnectionFactory());
  RabbitTemplate template = new RabbitTemplate(connectionFactory);
  RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
  rabbitAdmin.deleteQueue(queue.getName());
  rabbitAdmin.declareQueue(queue);
  assertEquals(100L, queue.getArguments().get("x-message-ttl"));
  template.convertAndSend(queue.getName(), "message");
  Properties props = rabbitAdmin.getQueueProperties("arguments");
  if (props != null) {
    int n = 0;
    while (n++ < 200 && (Integer) props.get(RabbitAdmin.QUEUE_MESSAGE_COUNT) > 0) {
      Thread.sleep(50);
      props = rabbitAdmin.getQueueProperties("arguments");
    }
    assertThat((Integer) props.get(RabbitAdmin.QUEUE_MESSAGE_COUNT), equalTo(0));
  }
  connectionFactory.destroy();
  brokerIsRunning.deleteQueues("arguments");
}
origin: spring-projects/spring-amqp

@Test
public void testMasterLocator() throws Exception {
  CachingConnectionFactory cf = new CachingConnectionFactory(brokerIsRunning.getConnectionFactory());
  RabbitAdmin admin = new RabbitAdmin(cf);
  AnonymousQueue queue = new AnonymousQueue();
  admin.declareQueue(queue);
  Client client = new Client("http://guest:guest@localhost:15672/api");
  QueueInfo info = client.getQueue("?", queue.getName());
  int n = 0;
  while (n++ < 100 && info == null) {
    Thread.sleep(100);
    info = client.getQueue("/", queue.getName());
  }
  assertNotNull(info);
  assertThat(info.getArguments().get(Queue.X_QUEUE_MASTER_LOCATOR), equalTo("client-local"));
  queue = new AnonymousQueue();
  queue.setMasterLocator(null);
  admin.declareQueue(queue);
  info = client.getQueue("?", queue.getName());
  n = 0;
  while (n++ < 100 && info == null) {
    Thread.sleep(100);
    info = client.getQueue("/", queue.getName());
  }
  assertNotNull(info);
  assertNull(info.getArguments().get(Queue.X_QUEUE_MASTER_LOCATOR));
  cf.destroy();
}
origin: spring-projects/spring-amqp

@Test
public void testVars() {
  BrokerRunning brokerRunning = BrokerRunning.isBrokerAndManagementRunning();
  brokerRunning.setAdminPassword("foo");
  brokerRunning.setAdminUser("bar");
  brokerRunning.setHostName("baz");
  brokerRunning.setPassword("qux");
  brokerRunning.setPort(1234);
  brokerRunning.setUser("fiz");
  assertEquals("http://baz:15672/api/", brokerRunning.getAdminUri());
  ConnectionFactory connectionFactory = brokerRunning.getConnectionFactory();
  assertEquals("baz", connectionFactory.getHost());
  assertEquals(1234, connectionFactory.getPort());
  assertEquals("fiz", connectionFactory.getUsername());
  assertEquals("qux", connectionFactory.getPassword());
}
org.springframework.amqp.rabbit.junitBrokerRunninggetConnectionFactory

Javadoc

Get the connection factory used by this rule.

Popular methods of BrokerRunning

  • removeTestQueues
    Remove any test queues that were created by an #isRunningWithEmptyQueues(String...) method.
  • getAdminUri
    Return the admin uri.
  • setPort
  • <init>
  • closeResources
  • createQueues
  • deleteExchanges
    Delete arbitrary exchanges from the broker.
  • fatal
  • generateId
    Generate the connection id for the connection used by the rule's connection factory.
  • getConnection
  • isBrokerAndManagementRunningWithEmptyQueues
  • isDefaultQueue
  • isBrokerAndManagementRunningWithEmptyQueues,
  • isDefaultQueue,
  • isRunningWithEmptyQueues,
  • isUp,
  • setHostName,
  • clearEnvironmentVariableOverrides,
  • deleteQueues,
  • getHostName,
  • getPassword

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getResourceAsStream (ClassLoader)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • BoxLayout (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now