View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  package org.fourthline.cling.test.transport;
16  
17  import org.fourthline.cling.UpnpServiceConfiguration;
18  import org.fourthline.cling.transport.impl.AsyncServletStreamServerConfigurationImpl;
19  import org.fourthline.cling.transport.impl.AsyncServletStreamServerImpl;
20  import org.fourthline.cling.transport.impl.jetty.JettyServletContainer;
21  import org.fourthline.cling.transport.impl.jetty.StreamClientConfigurationImpl;
22  import org.fourthline.cling.transport.impl.jetty.StreamClientImpl;
23  import org.fourthline.cling.transport.spi.StreamClient;
24  import org.fourthline.cling.transport.spi.StreamServer;
25  
26  import javax.servlet.http.HttpServletRequest;
27  
28  /**
29   * @author Christian Bauer
30   */
31  public class JettyServerJettyClientTest extends StreamServerClientTest {
32  
33      @Override
34      public StreamServer createStreamServer(int port) {
35          AsyncServletStreamServerConfigurationImpl configuration =
36              new AsyncServletStreamServerConfigurationImpl(
37                  JettyServletContainer.INSTANCE,
38                  port
39              );
40  
41          return new AsyncServletStreamServerImpl(
42              configuration
43          ) {
44              @Override
45              protected boolean isConnectionOpen(HttpServletRequest request) {
46                  return JettyServletContainer.isConnectionOpen(request);
47              }
48          };
49      }
50  
51      @Override
52      public StreamClient createStreamClient(UpnpServiceConfiguration configuration) {
53          return new StreamClientImpl(
54              new StreamClientConfigurationImpl(
55                  configuration.getSyncProtocolExecutorService(),
56                  3
57              )
58          );
59      }
60  }