मैं स्प्रिंग एकता के लिए नया हूँ परीक्षण करने के लिए कैसे। मेरे पास 'प्रतिक्रियाक्यू' कहने के साथ ActiveMQ है। > PainResponseChannel - -> ट्रांसफार्मर -> processResponseChannel -> beanProcessing तो जब संदेश 'responseQ' पर आता है। मेरे पास निम्नलिखित सेटअप है:स्प्रिंग एकता
<jms:message-driven-channel-adapter extract-payload="true"
channel="painResponseChannel"
connection-factory="connectionFactory"
destination-name="responseQ"/>
<integration:channel id="painResponseChannel" />
<integration-xml:unmarshalling-transformer
id="defaultUnmarshaller"
input-channel="painResponseChannel"
output-channel="processResponseChannel"
unmarshaller="marshaller"/>
<integration:channel id="processResponseChannel" />
<integration:service-activator
input-channel="processResponseChannel"
ref="processResponseActivator"/>
<bean id="processResponseActivator" class="com.messaging.processor.PainResponseProcessor"/>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.domain.pain.Document</value>
</list>
</property>
</bean>
तो मेरा सवाल यह है कि मैं अंत में इस अंत का परीक्षण कैसे कर सकता हूं? मैं ट्रांसफॉर्मर के आउटपुट पर जोर कैसे दे सकता हूं या चैनल पर क्या कह सकता हूं? मैंने कोशिश की लेकिन असफल रहा ... उम्मीद है कि कोई मदद कर सकता है।
अग्रिम धन्यवाद। जीएम
मैं इस तरह परीक्षण कर रहा था: मेरे परीक्षण-संदर्भ में एक आउटबाउंड-चैनल-एडाप्टर बनाया गया जो testJmsQueue चैनल का उपयोग कर सक्रिय एमक्यू पर एक संदेश डालने शुरू करता है। और प्रक्रिया के लिए एक ब्रिज भी बनाया ResponseChannel -> testChannel। मैं मुझे कुछ वापस देने के लिए प्राप्त() विधि की उम्मीद कर रहा था। लेकिन मुझे लगता है कि मुद्दा यह है कि यह बहुत तेज़ है और जब तक यह प्राप्त() विधि प्राप्त होता है तो पाइपलाइन समाप्त हो जाती है।
परीक्षण संदर्भ इस तरह दिखता है:
<integration:bridge input-channel="processResponseChannel" output-channel="testChannel"/>
<jms:outbound-channel-adapter id="jmsOut" destination-name="responseQ" channel="testJmsQueue"/>
<integration:channel id="testJmsQueue"/>
<integration:channel id="testChannel">
<integration:queue/>
</integration:channel>
और उसके बाद इकाई परीक्षण में मैं इस है:
@ContextConfiguration(locations = "classpath*:PainResponseTest-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class PainResponseTest {
private String painResponseXML;
@Autowired
MessageChannel testJmsQueue;
@Autowired
QueueChannel testChannel;
@Before
public void setup() throws Exception {
ClassPathResource cpr = new ClassPathResource("painResponse.xml");
InputStream is = cpr.getInputStream();
StringWriter writer = new StringWriter();
IOUtils.copy(is, writer, "UTF-8");
painResponseXML = writer.toString();
}
@Test
@SuppressWarnings("unchecked")
public void shouldDoSomething() throws InterruptedException {
testJmsQueue.send(MessageBuilder.withPayload(painResponseXML).build());
Message<String> reply = (Message<String>) testChannel.receive(0);
Assert.assertNotNull("reply should not be null", reply);
String out = reply.getPayload();
System.out.println(out);
}
}
==================== TEST OUTPUT =====================
java.lang.AssertionError: reply should not be null
हो रही जबाब शून्य के रूप में
चैनलों और सेवा activators के बाहर देखें अनुरेखण लॉग देता है [मूल] (https://github.com/garyrussell/spring-integration-samples/tree/master/basic/testing-examples) और [उन्नत] (https://github.com/garyrussell/spring-integration-samples/पेड़/मास्टर/उन्नत/उन्नत परीक्षण-उदाहरण) परीक्षण नमूने। इसके अलावा, [एक्शन में स्प्रिंग इंटीग्रेशन] (http://www.manning.com/fisher/) परीक्षण पर एक अध्याय है, जो [मैनिंग] पर एक नमूना अध्याय होता है (http://www.manning.com/ फिशर /)। –
मैं इस – user2279337
गैरी की तरह परीक्षण कर रहा था, उत्तर के लिए धन्यवाद। कृपया ऊपर मेरा अद्यतन प्रश्न देखें। मैंने परीक्षण-संदर्भ और यूनिट परीक्षण शामिल किया है जिसका मैं उपयोग कर रहा हूं। आगे सलाह या कोड नमूना उपयोगी होगा। – user2279337