I am new to JUnit testing. Can you please tell me how to do Junit Testing for void methods.
I have this class DemoPublisher
and this method demoPublishMessage()
which has return type void. How can I test this method?
package com.ge.health.gam.poc.publisher;
import javax.jms.JMSException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ge.health.gam.poc.consumer.DemoConsumer;
@Component
public class DemoPublisher {
@Autowired
JmsTemplate jmsTemplate;
public void demoPublishMessage(String message) throws JMSException{
jmsTemplate.convertAndSend("NewQueue", message);
System.out.println("Message sent");
}
}