protected void mockMessage() throws JMSException { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" // + "<testMethodHeaderOnly>\n" // + " <arg0>foo</arg0>\n" // + "</testMethodHeaderOnly>\n"; when(message.getText()).thenReturn(xml); when(message.getPropertyNames()).thenReturn(new StringTokenizer("arg1")); }
@Test public void shouldSetHeaderOnlyArrayPropertyAnnotation() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<testMethodHeaderOnly>\n" // + " <arg0>foo</arg0>\n" // + "</testMethodHeaderOnly>\n"; when(message.getText()).thenReturn(xml); when(message.getPropertyNames()).thenReturn(new StringTokenizer("arg1[0] arg1[1] arg1[2]")); when(message.getStringProperty("arg1[0]")).thenReturn("one"); when(message.getStringProperty("arg1[1]")).thenReturn("two"); when(message.getStringProperty("arg1[2]")).thenReturn("three"); XmlMessageDecoder<TestInterfaceHeaderOnlyArray> decoder = XmlMessageDecoder.of(TestInterfaceHeaderOnlyArray.class, implArray); decoder.onMessage(message); verify(implArray).testMethodHeaderOnly("foo", new String[] {"one", "two", "three"}); }
@Test public void shouldSetHeaderOnlyMapPropertyAnnotation() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<testMethodHeaderOnly>\n" // + " <arg0>foo</arg0>\n" // + "</testMethodHeaderOnly>\n"; when(message.getText()).thenReturn(xml); when(message.getPropertyNames()).thenReturn(new StringTokenizer("arg1[A] arg1[B] arg1[C]")); when(message.getStringProperty("arg1[A]")).thenReturn("one"); when(message.getStringProperty("arg1[B]")).thenReturn("two"); when(message.getStringProperty("arg1[C]")).thenReturn("three"); XmlMessageDecoder<TestInterfaceHeaderOnlyMap> decoder = XmlMessageDecoder.of(TestInterfaceHeaderOnlyMap.class, implMap); decoder.onMessage(message); Map<String, String> map = new HashMap<String, String>(); map.put("A", "one"); map.put("B", "two"); map.put("C", "three"); verify(implMap).testMethodHeaderOnly("foo", map); }