I have a spring boot JMS application that during startup up loads up multiple WebShpere MQ queues and copies the messages from those queues to another queue. Everything works, but I'm starting some unit testing and I think there a couple things I'm not understanding. So I have a config class that holds a bunch of annotated beans, one of those beans are the class that does the message loading before my JMSListener starts up. I have simple Unit test:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ErrorQueueReportApplication.class)
@ActiveProfiles(profiles = "DEV")
public class CastsApplicationTests {
static Logger logger = LogManager.getLogger(CastsApplicationTests.class.getName());
@Value("${hostname}")
String host;
@Test
public void testEcsProps(){
System.out.println("Running test");
assertEquals("hostname.someTLD", host);
}
}
This test passes, but I only expected to simply check my @Value see that they are equal and done. But running this as a unit test starts up my whole application, and since I have a bean that makes queue connections and loads up a queue, this unit test makes the queue connections and loads up a queue. But then my JMSListener is never kicked off so everything just stays on the queue and I have to manually clear it. This is unacceptable.
From what I understand about Spring Boot, @SpringApplicationConfiguration() takes the main class that will have the Application Context and the test runner starts up the application like it normally would. If this is the case I'm not sure how to go about Unit testing if it's going to load up my queue every time and never reads them off. Any suggestions or concepts to clarify to help me see more clearly?
Aucun commentaire:
Enregistrer un commentaire