Polish contribution

pull/5641/merge
Phillip Webb 9 years ago
parent d0ccea1b26
commit 0c0be1e626

@ -61,17 +61,21 @@ class ActiveMQConnectionFactoryFactory {
String password = this.properties.getPassword();
T activeMqConnectionFactory;
if (StringUtils.hasLength(user) && StringUtils.hasLength(password)) {
activeMqConnectionFactory =
factoryClass.getConstructor(String.class, String.class, String.class)
activeMqConnectionFactory = factoryClass
.getConstructor(String.class, String.class, String.class)
.newInstance(user, password, brokerUrl);
}
else {
activeMqConnectionFactory =
factoryClass.getConstructor(String.class).newInstance(brokerUrl);
activeMqConnectionFactory = factoryClass.getConstructor(String.class)
.newInstance(brokerUrl);
}
Packages packages = this.properties.getPackages();
activeMqConnectionFactory.setTrustAllPackages(packages.isTrustAll());
activeMqConnectionFactory.setTrustedPackages(packages.getTrusted());
if (packages.getTrustAll() != null) {
activeMqConnectionFactory.setTrustAllPackages(packages.getTrustAll());
}
if (!packages.getTrusted().isEmpty()) {
activeMqConnectionFactory.setTrustedPackages(packages.getTrusted());
}
return activeMqConnectionFactory;
}

@ -123,10 +123,6 @@ public class ActiveMQProperties {
return this.packages;
}
public void setPackages(Packages packages) {
this.packages = packages;
}
public static class Pool {
/**
@ -186,17 +182,21 @@ public class ActiveMQProperties {
public static class Packages {
/** Whether security check for trusted packages should be turned off. */
private boolean trustAll = false;
/**
* Trust all packages.
*/
private Boolean trustAll;
/** The packages to trust. */
/**
* The specific packages to trust (when not trusting all packages).
*/
private List<String> trusted = new ArrayList<String>();
public boolean isTrustAll() {
public Boolean getTrustAll() {
return this.trustAll;
}
public void setTrustAll(boolean trustAll) {
public void setTrustAll(Boolean trustAll) {
this.trustAll = trustAll;
}

@ -17,12 +17,10 @@
package org.springframework.boot.autoconfigure.jms.activemq;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ActiveMQProperties} and {@link ActiveMQConnectionFactoryFactory}.
*
@ -67,7 +65,7 @@ public class ActiveMQPropertiesTests {
}
@Test
public void testPackagesTrustAllSetToTrue() {
public void setTrustAllPackages() {
this.properties.getPackages().setTrustAll(true);
assertThat(new ActiveMQConnectionFactoryFactory(this.properties)
.createConnectionFactory(ActiveMQConnectionFactory.class)
@ -75,12 +73,11 @@ public class ActiveMQPropertiesTests {
}
@Test
public void testPackagesToTrust() {
public void setTrustedPackages() {
this.properties.getPackages().setTrustAll(false);
this.properties.getPackages().getTrusted().add("trusted.package");
ActiveMQConnectionFactory factory =
new ActiveMQConnectionFactoryFactory(this.properties)
.createConnectionFactory(ActiveMQConnectionFactory.class);
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactoryFactory(
this.properties).createConnectionFactory(ActiveMQConnectionFactory.class);
assertThat(factory.isTrustAllPackages()).isEqualTo(false);
assertThat(factory.getTrustedPackages().size()).isEqualTo(1);
assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package");

@ -770,6 +770,8 @@ content into your application; rather pick only the properties that you need.
spring.activemq.pool.expiry-timeout=0 # Connection expiration timeout in milliseconds.
spring.activemq.pool.idle-timeout=30000 # Connection idle timeout in milliseconds.
spring.activemq.pool.max-connections=1 # Maximum number of pooled connections.
spring.activemq.packages.trust-all= # Trust all packages
spring.activemq.packages.trusted= # The specific packages to trust (when not trusting all packages).
# ARTEMIS ({sc-spring-boot-autoconfigure}/jms/artemis/ArtemisProperties.{sc-ext}[ArtemisProperties])
spring.artemis.embedded.cluster-password= # Cluster password. Randomly generated on startup by default.

Loading…
Cancel
Save