Source code: org/finj/test/InformationTest.java
1 package org.finj.test;
2
3 import java.io.IOException;
4
5 import junit.framework.Test;
6 import junit.framework.TestSuite;
7
8 import org.finj.RemoteFile;
9 import org.finj.test.FinjTestCase;
10 import org.finj.test.FTPClientTest;
11
12 /**
13 * Tests functionalities related to server information in FTP commands.
14 *
15 *
16 *
17 * Copyright (C)
18 *
19 * This library is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public
21 * License as published by the Free Software Foundation; either
22 * version 2.1 of the License, or (at your option) any later version.
23 *
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 *
33 * @author Javier Iglesias -- jiglesias@users.sourceforge.net
34 * @version $Id: InformationTest.java,v 1.3 2003/10/22 08:26:26 jiglesia Exp $
35 * @since v1.0.2
36 */
37 public class InformationTest extends FinjTestCase {
38
39 /**
40 *
41 *
42 * @since v1.0.2
43 */
44 public InformationTest ( String name ) {
45 super(name);
46 }
47
48 /**
49 *
50 *
51 * @since v1.0.2
52 */
53 public static Test suite ( ) {
54 TestSuite suite = new TestSuite("tests concerning server informations in FTP commands");
55 suite.addTestSuite(InformationTest.class);
56 return suite;
57 }
58
59 /**
60 *
61 *
62 * @since v1.0.2
63 */
64 public void testFileNames ( ) throws IOException {
65 String[] names = null;
66
67 /* FIXME: only passive mode...
68 names = client.getFileNames(false);
69 assertTrue(true);
70 printFileNames(names);
71 //*/
72
73 names = client.getFileNames(true);
74 printFileNames(names);
75 assertTrue(true);
76
77 names = client.getFileNames("/etc", true);
78 printFileNames(names);
79 assertTrue(true);
80
81 }
82
83 /**
84 *
85 *
86 * @since v1.0.2
87 */
88 private void printFileNames ( String[] names ) {
89 for ( int index = 0;
90 index < names.length;
91 index++ ) {
92 System.err.println("file n°" + (index+1) + ": '" + names[index] + "'");
93 }
94 }
95
96 /**
97 *
98 *
99 * @since v1.0.2
100 */
101 public void testSystemName ( ) throws IOException {
102 client.getServerSystemName();
103 assertTrue(true);
104 }
105
106 /**
107 *
108 *
109 * @since v1.0.2
110 */
111 public void testServerStatus ( ) throws IOException {
112 client.getServerStatus();
113 assertTrue(true);
114 }
115
116 /**
117 *
118 *
119 * @since v1.0.2
120 */
121 public void testFileDescriptors ( ) throws IOException {
122 RemoteFile[] files = null;
123
124 files = client.getFileDescriptors(true);
125 printFileDetails(files);
126 assertTrue(true);
127
128 files = client.getFileDescriptors("/etc", true);
129 printFileDetails(files);
130 assertTrue(true);
131 }
132
133 /**
134 *
135 *
136 * @since v1.0.2
137 */
138 private void printFileDetails ( RemoteFile[] files ) {
139 for ( int index = 0;
140 index < files.length;
141 index++ ) {
142 System.err.println("file n°" + (index+1) + ": '" + files[index] + "'");
143 }
144 }
145
146 /**
147 *
148 *
149 * @since v1.0.2
150 */
151 public static void main ( String[] args ) {
152 new InformationTest("").runTestInterface(args);
153 }
154 }