|
Commons Net example source code file (FTPClientConfigFunctionalTest.java)
The Commons Net FTPClientConfigFunctionalTest.java source code
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.net.ftp;
import java.io.IOException;
import java.net.SocketException;
import java.util.Calendar;
import java.util.Comparator;
import java.util.TreeSet;
import junit.framework.TestCase;
/*
* This test was contributed in a different form by W. McDonald Buck
* of Boulder, Colorado, to help fix some bugs with the FTPClientConfig
* in a real world setting. It is a perfect functional test for the
* Time Zone functionality of FTPClientConfig.
*
* A publicly accessible FTP server at the US National Oceanographic and
* Atmospheric Adminstration houses a directory which contains
* 300 files, named sn.0000 to sn.0300. Every ten minutes or so
* the next file in sequence is rewritten with new data. Thus the directory
* contains observations for more than 24 hours of data. Since the server
* has its clock set to GMT this is an excellent functional test for any
* machine in a different time zone.
*
* Noteworthy is the fact that the ftp routines in some web browsers don't
* work as well as this. They can't, since they have no way of knowing the
* server's time zone. Depending on the local machine's position relative
* to GMT and the time of day, the browsers may decide that a timestamp
* would be in the future if given the current year, so they assume the
* year to be last year. This illustrates the value of FTPClientConfig's
* time zone functionality.
*/
public class FTPClientConfigFunctionalTest extends TestCase {
private FTPClient FTP = new FTPClient();
private FTPClientConfig FTPConf;
/**
*
*/
public FTPClientConfigFunctionalTest() {
super();
}
/*
* @throws java.lang.Exception
*/
@Override
protected void setUp() throws Exception {
super.setUp();
FTPConf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
FTPConf.setServerTimeZoneId("GMT");
FTP.configure(FTPConf);
try {
FTP.connect("tgftp.nws.noaa.gov");
FTP.login("anonymous","testing@apache.org");
FTP.changeWorkingDirectory("SL.us008001/DF.an/DC.sflnd/DS.metar");
FTP.enterLocalPassiveMode();
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* @throws java.lang.Exception
*/
@Override
protected void tearDown() throws Exception {
FTP.disconnect();
super.tearDown();
}
/**
* @param arg0
*/
public FTPClientConfigFunctionalTest(String arg0) {
super(arg0);
}
private TreeSet<FTPFile> getSortedList(FTPFile[] files) {
// create a TreeSet which will sort each element
// as it is added.
TreeSet<FTPFile> sorted = new TreeSet
Other Commons Net examples (source code examples)Here is a short list of links related to this Commons Net FTPClientConfigFunctionalTest.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.