View Javadoc
1   /*
2    * Copyright 2015 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.ihe.xds.dispatch;
17  
18  import org.apache.cxf.transport.servlet.CXFServlet;
19  import org.junit.BeforeClass;
20  import org.junit.Test;
21  import org.openehealth.ipf.commons.audit.model.AuditMessage;
22  import org.openehealth.ipf.commons.audit.queue.AbstractMockedAuditMessageQueue;
23  import org.openehealth.ipf.commons.ihe.xds.core.SampleData;
24  import org.openehealth.ipf.platform.camel.ihe.xds.XdsStandardTestContainer;
25  
26  import java.util.List;
27  
28  import static org.junit.Assert.assertEquals;
29  
30  public class TestDispatch extends XdsStandardTestContainer {
31      
32      static final String CONTEXT_DESCRIPTOR = "dispatch/dispatch-test-context.xml";
33  
34      final String ITI_18_SERVICE_URI = "xds-iti18://localhost:8888/xdsRegistry";
35      final String ITI_42_SERVICE_URI = "xds-iti42://localhost:8888/xdsRegistry";
36  
37      public static void main(String... args) {
38          startServer(new CXFServlet(), CONTEXT_DESCRIPTOR, false, 8889);
39      }
40      
41      @BeforeClass
42      public static void classSetUp() {
43          startServer(new CXFServlet(), CONTEXT_DESCRIPTOR);
44      }
45  
46  
47      @Test
48      public void testXdsDispatch() {
49          send(ITI_42_SERVICE_URI, SampleData.createRegisterDocumentSet());
50          send(ITI_18_SERVICE_URI, SampleData.createFindDocumentsQuery());
51          AbstractMockedAuditMessageQueue queue = getAuditSender();
52          List<AuditMessage> messages = queue.getMessages();
53          assertEquals(4, messages.size());
54      }
55  }