View Javadoc
1   /*
2    * Copyright 2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.platform.camel.core.adapter;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  import java.io.ByteArrayInputStream;
21  import java.io.StringReader;
22  
23  import javax.xml.transform.stream.StreamSource;
24  
25  import org.apache.camel.ExchangePattern;
26  import org.junit.Test;
27  import org.openehealth.ipf.platform.camel.core.AbstractRouteTest;
28  
29  
30  /**
31   * @author Martin Krasser
32   */
33  public class ParserRouteTest extends AbstractRouteTest {
34  
35      @Test
36      public void testParser1() throws InterruptedException {
37          String result = (String) producerTemplate.sendBody("direct:parser-test",
38                  ExchangePattern.InOut, "input");
39          assertEquals("string: input", result);
40      }
41  
42      @Test
43      public void testParser2() throws InterruptedException {
44          String result = (String) producerTemplate.sendBody("direct:parser-test",
45                  ExchangePattern.InOut, new ByteArrayInputStream("input".getBytes()));
46          assertEquals("stream: input", result);
47      }
48  
49      @Test
50      public void testParser3() throws InterruptedException {
51          String result = (String) producerTemplate.sendBody("direct:parser-test",
52                  ExchangePattern.InOut, new StringReader("input"));
53          assertEquals("reader: input", result);
54      }
55  
56      @Test
57      public void testParser4() throws InterruptedException {
58          String result = (String) producerTemplate.sendBody("direct:parser-test",
59                  ExchangePattern.InOut, new StreamSource(new StringReader("input")));
60          assertEquals("source: input", result);
61      }
62  
63  }