2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 package org
.apache
.thrift
.transport
;
22 import java
.util
.ArrayList
;
23 import java
.util
.List
;
25 import org
.apache
.thrift
.TProcessor
;
26 import org
.apache
.thrift
.protocol
.TBinaryProtocol
;
27 import org
.apache
.thrift
.protocol
.TProtocolFactory
;
28 import org
.apache
.thrift
.server
.ServerTestBase
;
29 import org
.apache
.thrift
.server
.TServer
;
30 import org
.apache
.thrift
.server
.TSimpleServer
;
31 import org
.apache
.thrift
.server
.TServer
.Args
;
33 public class TestTSSLTransportFactory
extends ServerTestBase
{
34 private Thread serverThread
;
35 private TServer server
;
37 private static final List
<TProtocolFactory
> protocols
= new ArrayList
<TProtocolFactory
>();
39 // TODO: Only supported on TBinaryProtocol. Doesn't work for TCompactProtocol
40 protocols
.add(new TBinaryProtocol
.Factory());
44 public TTransport
getClientTransport(TTransport underlyingTransport
)
46 return TSSLTransportFactory
.getClientSocket(HOST
, PORT
);
49 protected TServerSocket
getServerTransport() throws Exception
{
50 return TSSLTransportFactory
.getServerSocket(PORT
);
54 public void startServer(final TProcessor processor
, final TProtocolFactory protoFactory
, final TTransportFactory factory
)
56 serverThread
= new Thread() {
59 TServerTransport serverTransport
= getServerTransport();
60 final Args args
= new Args(serverTransport
).processor(processor
);
61 server
= new TSimpleServer(args
);
63 } catch (Exception e
) {
71 Thread
.sleep(SLEEP_DELAY
);
75 public void stopServer() throws Exception
{
81 public void open(TTransport transport
) throws Exception
{}
84 public List
<TProtocolFactory
> getProtocols() {
89 public void testTransportFactory() throws Exception
{
90 // this test doesn't really apply to this suite, so let's skip it.