Skip to content

Commit

Permalink
example of a spring config that can parse heroku URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
sclasen committed Jun 7, 2011
1 parent 54b9a07 commit ded5d0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/context.xml
Expand Up @@ -16,7 +16,7 @@
</bean>

<bean id="rabbitMqUrlMatcher" factory-bean="rabbitMqUrlRegex" factory-method="matcher" init-method="find">
<constructor-arg value="${RABBITMQ_URL:amqp://guest:guest@localhost:5672}/"/>
<constructor-arg value="${RABBITMQ_URL:amqp://guest:guest@localhost:5672/}"/>
</bean>

<bean id="rabbitMqUser" factory-bean="rabbitMqUrlMatcher" factory-method="group">
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/URLRegexTest.java
Expand Up @@ -9,7 +9,6 @@ public class URLRegexTest {

@Test
public void testRegex(){
//Matcher matcher = Pattern.compile("amqp://(.+):(.+)@(.+):(.+)(/.+)").matcher("amqp://guest:guest@localhost:5672/");
Matcher matcher = Pattern.compile("amqp://(.*):(.*)@(.*):(.*)(/.*)").matcher("amqp://guest:guest@localhost:5672/");

matcher.find();
Expand All @@ -21,6 +20,14 @@ public void testRegex(){
Assert.assertEquals("5672", matcher.group(4));
Assert.assertEquals("/", matcher.group(5));

matcher = Pattern.compile("amqp://(.*):(.*)@(.*):(.*)(/.*)").matcher("amqp://lzuuornl:GaLybFV0m6nuIRBC@iauladza.heroku.srs.rabbitmq.com:16919/iauladza");
matcher.find();
Assert.assertEquals("lzuuornl", matcher.group(1));
Assert.assertEquals("GaLybFV0m6nuIRBC", matcher.group(2));
Assert.assertEquals("iauladza.heroku.srs.rabbitmq.com", matcher.group(3));
Assert.assertEquals("16919", matcher.group(4));
Assert.assertEquals("/iauladza", matcher.group(5));

}


Expand Down

0 comments on commit ded5d0a

Please sign in to comment.