Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9df356ec
Commit
9df356ec
authored
Sep 23, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix destination checking in Artemis auto-configuration tests
Closes gh-18319
parent
7533bfd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
38 deletions
+26
-38
ArtemisAutoConfigurationTests.java
...oconfigure/jms/artemis/ArtemisAutoConfigurationTests.java
+26
-38
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java
View file @
9df356ec
...
...
@@ -21,14 +21,15 @@ import java.io.IOException;
import
java.util.UUID
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.Destination
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.TextMessage
;
import
org.apache.activemq.artemis.api.core.RoutingType
;
import
org.apache.activemq.artemis.api.core.SimpleString
;
import
org.apache.activemq.artemis.api.core.TransportConfiguration
;
import
org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory
;
import
org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory
;
import
org.apache.activemq.artemis.core.server.BindingQueryResult
;
import
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
;
import
org.apache.activemq.artemis.jms.server.config.JMSConfiguration
;
import
org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration
;
...
...
@@ -50,9 +51,6 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jms.connection.CachingConnectionFactory
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.SessionCallback
;
import
org.springframework.jms.support.destination.DestinationResolver
;
import
org.springframework.jms.support.destination.DynamicDestinationResolver
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -208,9 +206,9 @@ public class ArtemisAutoConfigurationTests {
DestinationChecker
checker
=
new
DestinationChecker
(
context
);
checker
.
checkQueue
(
"Queue1"
,
true
);
checker
.
checkQueue
(
"Queue2"
,
true
);
checker
.
checkQueue
(
"
QueueWillNotBeAutoCreated"
,
tru
e
);
checker
.
checkQueue
(
"
NonExistentQueue"
,
fals
e
);
checker
.
checkTopic
(
"Topic1"
,
true
);
checker
.
checkTopic
(
"
TopicWillBeAutoCreated"
,
tru
e
);
checker
.
checkTopic
(
"
NonExistentTopic"
,
fals
e
);
});
}
...
...
@@ -230,8 +228,8 @@ public class ArtemisAutoConfigurationTests {
.
withPropertyValues
(
"spring.artemis.embedded.queues=Queue1,Queue2"
).
run
((
context
)
->
{
DestinationChecker
checker
=
new
DestinationChecker
(
context
);
checker
.
checkQueue
(
"custom"
,
true
);
// See CustomJmsConfiguration
checker
.
checkQueue
(
"Queue1"
,
tru
e
);
checker
.
checkQueue
(
"Queue2"
,
tru
e
);
checker
.
checkQueue
(
"Queue1"
,
fals
e
);
checker
.
checkQueue
(
"Queue2"
,
fals
e
);
});
}
...
...
@@ -275,10 +273,10 @@ public class ArtemisAutoConfigurationTests {
.
isLessThan
(
secondProperties
.
getEmbedded
().
getServerId
());
DestinationChecker
firstChecker
=
new
DestinationChecker
(
first
);
firstChecker
.
checkQueue
(
"Queue1"
,
true
);
firstChecker
.
checkQueue
(
"Queue2"
,
tru
e
);
firstChecker
.
checkQueue
(
"Queue2"
,
fals
e
);
DestinationChecker
secondChecker
=
new
DestinationChecker
(
second
);
secondChecker
.
checkQueue
(
"Queue1"
,
false
);
secondChecker
.
checkQueue
(
"Queue2"
,
true
);
secondChecker
.
checkQueue
(
"Queue1"
,
true
);
});
});
}
...
...
@@ -295,10 +293,9 @@ public class ArtemisAutoConfigurationTests {
// Do not start a specific one
"spring.artemis.embedded.enabled=false"
)
.
run
((
secondContext
)
->
{
DestinationChecker
firstChecker
=
new
DestinationChecker
(
first
);
firstChecker
.
checkQueue
(
"Queue1"
,
true
);
DestinationChecker
secondChecker
=
new
DestinationChecker
(
secondContext
);
secondChecker
.
checkQueue
(
"Queue1"
,
true
);
first
.
getBean
(
JmsTemplate
.
class
).
convertAndSend
(
"Queue1"
,
"test"
);
assertThat
(
secondContext
.
getBean
(
JmsTemplate
.
class
).
receiveAndConvert
(
"Queue1"
))
.
isEqualTo
(
"test"
);
});
});
}
...
...
@@ -394,40 +391,31 @@ public class ArtemisAutoConfigurationTests {
private
static
final
class
DestinationChecker
{
private
final
JmsTemplate
jmsTemplate
;
private
final
DestinationResolver
destinationResolver
;
private
final
EmbeddedJMS
embeddedJms
;
private
DestinationChecker
(
ApplicationContext
applicationContext
)
{
this
.
jmsTemplate
=
applicationContext
.
getBean
(
JmsTemplate
.
class
);
this
.
destinationResolver
=
new
DynamicDestinationResolver
();
this
.
embeddedJms
=
applicationContext
.
getBean
(
EmbeddedJMS
.
class
);
}
public
void
checkQueue
(
String
name
,
boolean
shouldExist
)
{
checkDestination
(
name
,
false
,
shouldExist
);
checkDestination
(
name
,
RoutingType
.
ANYCAST
,
shouldExist
);
}
public
void
checkTopic
(
String
name
,
boolean
shouldExist
)
{
checkDestination
(
name
,
true
,
shouldExist
);
checkDestination
(
name
,
RoutingType
.
MULTICAST
,
shouldExist
);
}
public
void
checkDestination
(
String
name
,
final
boolean
pubSub
,
final
boolean
shouldExist
)
{
this
.
jmsTemplate
.
execute
((
SessionCallback
<
Void
>)
(
session
)
->
{
try
{
Destination
destination
=
this
.
destinationResolver
.
resolveDestinationName
(
session
,
name
,
pubSub
);
if
(!
shouldExist
)
{
throw
new
IllegalStateException
(
"Destination '"
+
name
+
"' was not expected but got "
+
destination
);
}
}
catch
(
JMSException
ex
)
{
if
(
shouldExist
)
{
throw
new
IllegalStateException
(
"Destination '"
+
name
+
"' was expected but got "
+
ex
.
getMessage
());
}
public
void
checkDestination
(
String
name
,
RoutingType
routingType
,
boolean
shouldExist
)
{
try
{
BindingQueryResult
result
=
this
.
embeddedJms
.
getActiveMQServer
().
bindingQuery
(
new
SimpleString
(
name
));
assertThat
(
result
.
isExists
()).
isEqualTo
(
shouldExist
);
if
(
shouldExist
)
{
assertThat
(
result
.
getAddressInfo
().
getRoutingType
()).
isEqualTo
(
routingType
);
}
return
null
;
});
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment