1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.tck.property; |
8 | |
|
9 | |
import org.mule.api.MuleEventContext; |
10 | |
import org.mule.api.lifecycle.Callable; |
11 | |
|
12 | |
import java.util.HashMap; |
13 | |
import java.util.Map; |
14 | |
|
15 | |
import static org.hamcrest.core.Is.is; |
16 | |
import static org.junit.Assert.assertThat; |
17 | |
|
18 | 0 | public class SessionPropertiesValidatorComponent implements Callable |
19 | |
{ |
20 | |
|
21 | 0 | private Map<String,String> expectedProperties = new HashMap<String,String>(); |
22 | |
|
23 | |
public void setExpectedProperties(Map<String, String> expectedProperties) |
24 | |
{ |
25 | 0 | this.expectedProperties = expectedProperties; |
26 | 0 | } |
27 | |
|
28 | |
public Object onCall(MuleEventContext eventContext) throws Exception |
29 | |
{ |
30 | 0 | if (expectedProperties.isEmpty()) |
31 | |
{ |
32 | 0 | throw new IllegalStateException("you must set at least one expected property"); |
33 | |
} |
34 | 0 | for (String propertyName : expectedProperties.keySet()) |
35 | |
{ |
36 | 0 | assertThat((String) eventContext.getMessage().getSessionProperty(propertyName), is(expectedProperties.get(propertyName))); |
37 | |
} |
38 | 0 | return eventContext.getMessage(); |
39 | |
} |
40 | |
} |