001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Boris V. Kuznetsov
020: * @version $Revision$
021: */package javax.net.ssl;
022:
023: import java.io.IOException;
024: import java.net.InetAddress;
025: import java.net.Socket;
026: import java.net.SocketException;
027:
028: import junit.framework.TestCase;
029:
030: /**
031: * Tests for <code>DefaultSSLSocketFactory</code> class constructors and
032: * methods.
033: *
034: */
035: public class DefaultSSLSocketFactoryTest extends TestCase {
036:
037: /*
038: * Class under test for Socket createSocket(String, int)
039: */
040: public void testCreateSocketStringint() {
041: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
042: try {
043: f.createSocket("localhost", 0);
044: fail("No expected SocketException");
045: } catch (SocketException e) {
046: } catch (IOException e) {
047: fail(e.toString());
048: }
049:
050: }
051:
052: /*
053: * Class under test for Socket createSocket(String, int, InetAddress, int)
054: */
055: public void testCreateSocketStringintInetAddressint() {
056: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
057: try {
058: f.createSocket("localhost", 0, InetAddress.getLocalHost(),
059: 1);
060: fail("No expected SocketException");
061: } catch (SocketException e) {
062: } catch (IOException e) {
063: fail(e.toString());
064: }
065: }
066:
067: /*
068: * Class under test for Socket createSocket(InetAddress, int)
069: */
070: public void testCreateSocketInetAddressint() {
071: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
072: try {
073: f.createSocket(InetAddress.getLocalHost(), 1);
074: fail("No expected SocketException");
075: } catch (SocketException e) {
076: } catch (IOException e) {
077: fail(e.toString());
078: }
079: }
080:
081: /*
082: * Class under test for Socket createSocket(InetAddress, int, InetAddress,
083: * int)
084: */
085: public void testCreateSocketInetAddressintInetAddressint() {
086: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
087: try {
088: f.createSocket(InetAddress.getLocalHost(), 1, InetAddress
089: .getLocalHost(), 2);
090: fail("No expected SocketException");
091: } catch (SocketException e) {
092: } catch (IOException e) {
093: fail(e.toString());
094: }
095: }
096:
097: public void testGetDefaultCipherSuites() {
098: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
099: String[] res = f.getDefaultCipherSuites();
100: if (res == null || res.length != 0) {
101: fail("incorrect result");
102: }
103: }
104:
105: public void testGetSupportedCipherSuites() {
106: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
107: String[] res = f.getSupportedCipherSuites();
108: if (res == null || res.length != 0) {
109: fail("incorrect result");
110: }
111: }
112:
113: /*
114: * Class under test for Socket createSocket(Socket, String, int, boolean)
115: */
116: public void testCreateSocketSocketStringintboolean() {
117: DefaultSSLSocketFactory f = new DefaultSSLSocketFactory("ERROR");
118: try {
119: f.createSocket(new Socket(), "localhost", 1, true);
120: fail("No expected SocketException");
121: } catch (SocketException e) {
122: } catch (IOException e) {
123: fail(e.toString());
124: }
125: }
126: }
|