-
Notifications
You must be signed in to change notification settings - Fork 0
/
GatewaySampleTest.java
executable file
·55 lines (40 loc) · 1.82 KB
/
GatewaySampleTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.github.aheusingfeld.talks.eai;
import com.github.aheusingfeld.talks.eai.gateways.CustomGateway;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:spring/gateway-sample.xml")
public class GatewaySampleTest
{
@Autowired
private CustomGateway partnerGatewaySend;
@Test
public void matchingCall() throws Exception
{
final String message = "<ROWSET><ROW><DATA>my sample content</DATA></ROW></ROWSET>";
System.out.println(System.currentTimeMillis() + " - Request started.");
String response = partnerGatewaySend.sendMessage(message);
System.out.println(System.currentTimeMillis() + " - Reply timeout reached.");
// don't expect response as 'sample content' is sent
assertThat(response, is(nullValue()));
}
@Test
public void nonMatchingContent() throws Exception
{
final String message = "<ROWSET><ROW><USER_ORGANIZATION>1991919</USER_ORGANIZATION><USERTOKEN>nothing</USERTOKEN></ROW></ROWSET>";
String response = partnerGatewaySend.sendMessage(message);
// expect response as message doesn't match the filter
assertThat(response, notNullValue());
// make sure the response equals the message send
assertThat(String.valueOf(response), equalTo(message));
}
}