Polish RabbitMQ Changes

Fix the formatting which was messed up in commit ad1636fd. Also
simplify the RabbitProperties.setVirtualHost logic a little

See gh-1128
pull/1129/head
Phillip Webb 11 years ago
parent ad1636fd34
commit 445589a5d2

@ -21,7 +21,7 @@ import org.springframework.util.StringUtils;
/**
* Configuration properties for Rabbit.
*
*
* @author Greg Turnquist
* @author Dave Syer
*/
@ -110,15 +110,11 @@ public class RabbitProperties {
}
public void setVirtualHost(String virtualHost) {
if ("".equals(virtualHost) || virtualHost.equals("/")) {
this.virtualHost = "/";
} else {
// remove all trailing /
while (virtualHost.startsWith("/") && virtualHost.length() > 0) {
virtualHost = virtualHost.substring(1);
}
this.virtualHost = virtualHost;
}
while (virtualHost.startsWith("/") && virtualHost.length() > 0) {
virtualHost = virtualHost.substring(1);
}
this.virtualHost = ("".equals(virtualHost) ? "/" : virtualHost);
}
}

@ -16,9 +16,6 @@
package org.springframework.boot.autoconfigure.amqp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@ -33,9 +30,12 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Tests for {@link RabbitAutoConfiguration}.
*
*
* @author Greg Turnquist
*/
public class RabbitAutoconfigurationTests {
@ -74,7 +74,7 @@ public class RabbitAutoconfigurationTests {
.getBean(CachingConnectionFactory.class);
assertEquals("remote-server", connectionFactory.getHost());
assertEquals(9000, connectionFactory.getPort());
assertEquals("vhost", connectionFactory.getVirtualHost());
assertEquals("vhost", connectionFactory.getVirtualHost());
}
@Test

@ -16,14 +16,14 @@
package org.springframework.boot.autoconfigure.amqp;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
/**
* Tests for {@link RabbitProperties}.
*
*
* @author Dave Syer
*/
public class RabbitPropertiesTests {
@ -50,28 +50,28 @@ public class RabbitPropertiesTests {
assertEquals(9999, this.properties.getPort());
}
@Test
public void testDefaultVirtualHost() {
this.properties.setVirtualHost("/");
assertEquals("/", this.properties.getVirtualHost());
}
@Test
public void testDefaultVirtualHost() {
this.properties.setVirtualHost("/");
assertEquals("/", this.properties.getVirtualHost());
}
@Test
public void testemptyVirtualHost() {
this.properties.setVirtualHost("");
assertEquals("/", this.properties.getVirtualHost());
}
@Test
public void testemptyVirtualHost() {
this.properties.setVirtualHost("");
assertEquals("/", this.properties.getVirtualHost());
}
@Test
public void testCustomVirtualHost() {
this.properties.setVirtualHost("myvHost");
assertEquals("myvHost", this.properties.getVirtualHost());
}
@Test
public void testCustomVirtualHost() {
this.properties.setVirtualHost("myvHost");
assertEquals("myvHost", this.properties.getVirtualHost());
}
@Test
public void testCustomFalsyVirtualHost() {
this.properties.setVirtualHost("/myvHost");
assertEquals("myvHost", this.properties.getVirtualHost());
}
@Test
public void testCustomFalsyVirtualHost() {
this.properties.setVirtualHost("/myvHost");
assertEquals("myvHost", this.properties.getVirtualHost());
}
}

Loading…
Cancel
Save