ActiveMQConnectionFactoryCreator implements ConnectionFactoryCreator { @Override public ConnectionFactory create(Map<String, String> properties) { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); if (properties.containsKey("brokerUrl")) { connectionFactory.setBrokerURL(properties.get("brokerUrl")); } if (properties.containsKey("username")) { connectionFactory.setUserName(properties.get("username")); } if (properties.containsKey("password")) { connectionFactory.setPassword(properties.get("password")); } return connectionFactory; }  @Override ConnectionFactory create(Map<String, String> properties); @Override boolean supports(Class<?> type);  }
@Test public void shouldCreate() { ConnectionFactory connectionFactory = connectionFactoryCreator.create(Collections.emptyMap()); Assertions.assertThat(ActiveMQConnectionFactory.class).isEqualTo(connectionFactory.getClass()); Assertions.assertThat(ActiveMQConnectionFactory.DEFAULT_BROKER_URL).isEqualTo(((ActiveMQConnectionFactory)connectionFactory).getBrokerURL()); }
@Test public void shouldCreateWithProperties() { Map<String, String> connectionSettings = new LinkedHashMap<>(); connectionSettings.put("brokerUrl", "typ: connectionSettings.put("username", "foo"); connectionSettings.put("password", "secret"); ConnectionFactory connectionFactory = connectionFactoryCreator.create(connectionSettings); Assertions.assertThat(ActiveMQConnectionFactory.class).isEqualTo(connectionFactory.getClass()); Assertions.assertThat("typ: Assertions.assertThat("foo").isEqualTo(((ActiveMQConnectionFactory)connectionFactory).getUserName()); Assertions.assertThat("secret").isEqualTo(((ActiveMQConnectionFactory)connectionFactory).getPassword()); }