1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider.ftp;
18
19 import static org.apache.commons.vfs2.VfsTestUtils.getTestDirectory;
20
21 import java.io.IOException;
22 import java.net.SocketException;
23
24 import org.apache.commons.net.ftp.FTPClient;
25 import org.apache.commons.vfs2.FileObject;
26 import org.apache.commons.vfs2.FileSystemException;
27 import org.apache.commons.vfs2.VFS;
28 import org.apache.ftpserver.ftplet.FtpException;
29 import org.junit.jupiter.api.AfterAll;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.Test;
32
33 public class MultipleConnectionTest {
34
35 @BeforeAll
36 public static void setUpClass() throws FtpException {
37 FtpProviderTestCase.setUpClass(getTestDirectory(), null, null);
38 }
39
40 @AfterAll
41 public static void tearDownClass() {
42 FtpProviderTestCase.tearDownClass();
43 }
44
45 private FileObject resolveRoot() throws FileSystemException {
46 return VFS.getManager().resolveFile(FtpProviderTestCase.getConnectionUri());
47 }
48
49 @Test
50 public void testConnectRoot() throws IOException {
51 resolveRoot();
52 resolveRoot();
53 }
54
55 @Test
56 public void testUnderlyingConnect() throws SocketException, IOException {
57 final FTPClient client1 = new FTPClient();
58 final FTPClient client2 = new FTPClient();
59 try {
60 final String hostname = "localhost";
61 client1.connect(hostname, FtpProviderTestCase.getSocketPort());
62 client2.connect(hostname, FtpProviderTestCase.getSocketPort());
63 } finally {
64 client1.disconnect();
65 client2.disconnect();
66 }
67 }
68
69 }