View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.net.ftp;
18  
19  import static org.junit.jupiter.api.Assertions.assertArrayEquals;
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  import static org.junit.jupiter.api.Assertions.assertFalse;
22  import static org.junit.jupiter.api.Assertions.assertTrue;
23  
24  import org.junit.jupiter.api.Test;
25  
26  /**
27   * Tests the getters on {@link FTPSClient}.
28   */
29  public class FTPSClientGettersTest {
30  
31      @Test
32      public void testGetters() {
33          final FTPSClient testClient = new FTPSClient("SSL", true);
34          assertTrue(testClient.isImplicit());
35          assertEquals("SSL", testClient.getProtocol());
36  
37          final FTPSClient testClient2 = new FTPSClient("TLS", false);
38          assertFalse(testClient2.isImplicit());
39          assertEquals("TLS", testClient2.getProtocol());
40          final String[] protocols = {"123", "456"};
41          testClient2.setEnabledProtocols(protocols);
42          assertArrayEquals(protocols, testClient2.getProtocols());
43          testClient2.setNeedClientAuth(true);
44          assertTrue(testClient2.isNeedClientAuth());
45          testClient2.setNeedClientAuth(false);
46          assertFalse(testClient2.isNeedClientAuth());
47          testClient2.setWantClientAuth(true);
48          assertTrue(testClient2.isWantClientAuth());
49          testClient2.setWantClientAuth(false);
50          assertFalse(testClient2.isWantClientAuth());
51          final String[] suites = {"abc", "def"};
52          testClient2.setEnabledCipherSuites(suites);
53          assertArrayEquals(suites, testClient2.getSuites());
54          testClient2.setAuthValue("qwerty");
55          assertEquals("qwerty", testClient2.getAuthValue());
56          testClient2.setUseClientMode(true);
57          assertTrue(testClient2.isClientMode());
58          testClient2.setUseClientMode(false);
59          assertFalse(testClient2.isClientMode());
60          testClient2.setEnabledSessionCreation(true);
61          assertTrue(testClient2.isCreation());
62          testClient2.setEnabledSessionCreation(false);
63          assertFalse(testClient2.isCreation());
64      }
65  }
66