Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/finj/test/DataTest.java


1   package org.finj.test;
2   
3   import java.io.FileOutputStream;
4   
5   import junit.framework.Test;
6   import junit.framework.TestSuite;
7   
8   import org.finj.test.FinjTestCase;
9   
10  /**
11   * Tests functionalities related to data handling in FTP commands.
12   *
13   *
14   *
15   * Copyright (C)
16   *
17   * This library is free software; you can redistribute it and/or
18   * modify it under the terms of the GNU Lesser General Public
19   * License as published by the Free Software Foundation; either
20   * version 2.1 of the License, or (at your option) any later version.
21   *
22   * This library is distributed in the hope that it will be useful,
23   * but WITHOUT ANY WARRANTY; without even the implied warranty of
24   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25   * Lesser General Public License for more details.
26   *
27   * You should have received a copy of the GNU Lesser General Public
28   * License along with this library; if not, write to the Free Software
29   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30   *
31   * @author  Javier Iglesias -- jiglesias@users.sourceforge.net
32   * @version $Id: DataTest.java,v 1.3 2003/10/22 08:26:26 jiglesia Exp $
33   */
34  public class DataTest extends FinjTestCase {
35  
36    /**
37     *
38     *
39     * @since v1.0.2
40     */
41    public DataTest ( String name ) {
42      super(name);
43      System.err.println("DataTest : testing ...");
44    }
45    
46    /**
47     *
48     *
49     * @since v1.0.2
50     */
51    public static Test suite ( ) {
52      TestSuite suite = new TestSuite("tests concerning data handling in FTP commands");
53      suite.addTestSuite(DataTest.class);
54      return suite;
55    }
56    
57    /**
58     *
59     *
60     * @since v1.0.2
61     */
62    public void testUploadCreateTransfert ( ) throws Exception {
63  //    client.putFile(new java.io.FileInputStream("./org/finj/test/resources/ascii.mix.txt"), "asciifile.txt", true);
64      client.putFile(new java.io.FileInputStream("./test.txt"), "asciifile.txt", true);
65  //    client.putFile(getClass().getResourceAsStream("org/finj/test/resources/ascii.mix.txt"), "asciifile.txt", true);
66      assertTrue(true);
67    }
68  
69    /**
70     *
71     *
72     * @since v1.0.2
73     */
74    public void testUploadAppendTransfert ( ) throws Exception {
75      client.appendToFile(new java.io.FileInputStream("./test.txt"), "asciifile.txt", true);
76      assertTrue(true);
77    }
78  
79    /**
80     *
81     *
82     * @since v1.0.2
83     */
84    public void testDeleteFile ( ) throws Exception {
85      client.deleteFile("asciifile.txt");
86      assertTrue(true);
87    }
88  
89    /**
90     *
91     *
92     * @since v1.0.2
93     */
94    public void testUploadUniqueTransfert ( ) throws Exception {
95      String name = client.putUniqueFile(new java.io.FileInputStream("./test.txt"), true);
96      System.err.println("NEW FILE IS : " + name);
97      assertTrue(name!=null && name.length()>0);
98    }
99    
100   /**
101    *
102    *
103    * @since v1.0.2
104    */
105   public void testDownloadTransfert ( ) throws Exception {
106     try {
107       client.getFile(new FileOutputStream("test.txt"), "asdfasdftest", true);
108       fail("should throw an exception when file to retrieve doesn't exist");
109     } catch ( Exception e ) {
110       assertTrue(true);
111     }
112     
113     client.getFile(new FileOutputStream("test.txt"), "test.txt", true);
114     assertTrue(true);
115   }
116   
117   /**
118    *
119    *
120    * @since v1.0.2
121    */
122   public static void main ( String[] args ) {
123     new DataTest("").runTestInterface(args);
124   }
125 }