#define TEST_FILECONF
#define TEST_FILENAME
#define TEST_FILETIME
- #define TEST_FTP
#define TEST_INFO_FUNCTIONS
#define TEST_LOCALE
#define TEST_LOG
#define TEST_SCOPEGUARD
#define TEST_SNGLINST
// #define TEST_SOCKETS --FIXME! (RN)
- #define TEST_STACKWALKER
- #define TEST_STDPATHS
#else // #if TEST_ALL
#define TEST_DATETIME
#define TEST_VOLUME
+ #define TEST_STDPATHS
+ #define TEST_STACKWALKER
+ #define TEST_FTP
#endif
// some tests are interactive, define this to run them
static wxFTP *ftp;
#ifdef FTP_ANONYMOUS
+ static const wxChar *hostname = wxT("ftp.wxwidgets.org");
static const wxChar *directory = wxT("/pub");
static const wxChar *filename = wxT("welcome.msg");
#else
+ static const wxChar *hostname = "localhost";
static const wxChar *directory = wxT("/etc");
static const wxChar *filename = wxT("issue");
#endif
wxPuts(wxT("*** Testing FTP connect ***"));
#ifdef FTP_ANONYMOUS
- static const wxChar *hostname = wxT("ftp.wxwidgets.org");
-
wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
#else // !FTP_ANONYMOUS
- static const wxChar *hostname = "localhost";
-
wxChar user[256];
wxFgets(user, WXSIZEOF(user), stdin);
user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
return true;
}
-static void TestFtpList()
-{
- wxPuts(wxT("*** Testing wxFTP file listing ***\n"));
-
- // test CWD
- if ( !ftp->ChDir(directory) )
- {
- wxPrintf(wxT("ERROR: failed to cd to %s\n"), directory);
- }
-
- wxPrintf(wxT("Current directory is '%s'\n"), ftp->Pwd().c_str());
-
- // test NLIST and LIST
- wxArrayString files;
- if ( !ftp->GetFilesList(files) )
- {
- wxPuts(wxT("ERROR: failed to get NLIST of files"));
- }
- else
- {
- wxPrintf(wxT("Brief list of files under '%s':\n"), ftp->Pwd().c_str());
- size_t count = files.GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- wxPrintf(wxT("\t%s\n"), files[n].c_str());
- }
- wxPuts(wxT("End of the file list"));
- }
-
- if ( !ftp->GetDirList(files) )
- {
- wxPuts(wxT("ERROR: failed to get LIST of files"));
- }
- else
- {
- wxPrintf(wxT("Detailed list of files under '%s':\n"), ftp->Pwd().c_str());
- size_t count = files.GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- wxPrintf(wxT("\t%s\n"), files[n].c_str());
- }
- wxPuts(wxT("End of the file list"));
- }
-
- if ( !ftp->ChDir(wxT("..")) )
- {
- wxPuts(wxT("ERROR: failed to cd to .."));
- }
-
- wxPrintf(wxT("Current directory is '%s'\n"), ftp->Pwd().c_str());
-}
-
-static void TestFtpDownload()
-{
- wxPuts(wxT("*** Testing wxFTP download ***\n"));
-
- // test RETR
- wxInputStream *in = ftp->GetInputStream(filename);
- if ( !in )
- {
- wxPrintf(wxT("ERROR: couldn't get input stream for %s\n"), filename);
- }
- else
- {
- size_t size = in->GetSize();
- wxPrintf(wxT("Reading file %s (%u bytes)..."), filename, size);
- fflush(stdout);
-
- wxChar *data = new wxChar[size];
- if ( !in->Read(data, size) )
- {
- wxPuts(wxT("ERROR: read error"));
- }
- else
- {
- wxPrintf(wxT("\nContents of %s:\n%s\n"), filename, data);
- }
-
- delete [] data;
- delete in;
- }
-}
-
-static void TestFtpFileSize()
-{
- wxPuts(wxT("*** Testing FTP SIZE command ***"));
-
- if ( !ftp->ChDir(directory) )
- {
- wxPrintf(wxT("ERROR: failed to cd to %s\n"), directory);
- }
-
- wxPrintf(wxT("Current directory is '%s'\n"), ftp->Pwd().c_str());
-
- if ( ftp->FileExists(filename) )
- {
- int size = ftp->GetFileSize(filename);
- if ( size == -1 )
- wxPrintf(wxT("ERROR: couldn't get size of '%s'\n"), filename);
- else
- wxPrintf(wxT("Size of '%s' is %d bytes.\n"), filename, size);
- }
- else
- {
- wxPrintf(wxT("ERROR: '%s' doesn't exist\n"), filename);
- }
-}
-
-static void TestFtpMisc()
-{
- wxPuts(wxT("*** Testing miscellaneous wxFTP functions ***"));
-
- if ( ftp->SendCommand(wxT("STAT")) != '2' )
- {
- wxPuts(wxT("ERROR: STAT failed"));
- }
- else
- {
- wxPrintf(wxT("STAT returned:\n\n%s\n"), ftp->GetLastResult().c_str());
- }
-
- if ( ftp->SendCommand(wxT("HELP SITE")) != '2' )
- {
- wxPuts(wxT("ERROR: HELP SITE failed"));
- }
- else
- {
- wxPrintf(wxT("The list of site-specific commands:\n\n%s\n"),
- ftp->GetLastResult().c_str());
- }
-}
-
-#if TEST_INTERACTIVE
-
static void TestFtpInteractive()
{
wxPuts(wxT("\n*** Interactive wxFTP test ***"));
for ( ;; )
{
- wxPrintf(wxT("Enter FTP command: "));
+ wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
break;
wxPuts(wxT("--- End of the file list"));
}
}
+ else if ( start == wxT("QUIT") )
+ {
+ break; // get out of here!
+ }
else // !list
{
wxChar ch = ftp->SendCommand(buf);
wxPuts(wxT("\n*** done ***"));
}
-#endif // TEST_INTERACTIVE
-
-static void TestFtpUpload()
-{
- wxPuts(wxT("*** Testing wxFTP uploading ***\n"));
-
- // upload a file
- static const wxChar *file1 = wxT("test1");
- static const wxChar *file2 = wxT("test2");
- wxOutputStream *out = ftp->GetOutputStream(file1);
- if ( out )
- {
- wxPrintf(wxT("--- Uploading to %s ---\n"), file1);
- out->Write("First hello", 11);
- delete out;
- }
-
- // send a command to check the remote file
- if ( ftp->SendCommand(wxString(wxT("STAT ")) + file1) != '2' )
- {
- wxPrintf(wxT("ERROR: STAT %s failed\n"), file1);
- }
- else
- {
- wxPrintf(wxT("STAT %s returned:\n\n%s\n"),
- file1, ftp->GetLastResult().c_str());
- }
-
- out = ftp->GetOutputStream(file2);
- if ( out )
- {
- wxPrintf(wxT("--- Uploading to %s ---\n"), file1);
- out->Write("Second hello", 12);
- delete out;
- }
-}
-
#endif // TEST_FTP
// ----------------------------------------------------------------------------
StackDump dump(argv0);
dump.Walk();
+
+ wxPuts("\n");
}
#endif // wxUSE_STACKWALKER
wxT("fr"),
wxStandardPaths::ResourceCat_Messages
).c_str());
+
+ wxPuts("\n");
}
#endif // TEST_STDPATHS
vol.GetFlags() & wxFS_VOL_REMOVABLE ? wxT("removable")
: wxT("fixed"));
}
+
+ wxPuts("\n");
}
#endif // TEST_VOLUME
for ( ;; )
{
- wxPrintf(wxT("Enter a date: "));
+ wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
break;
// kill the last '\n'
buf[wxStrlen(buf) - 1] = 0;
+
+ if ( wxString(buf).CmpNoCase("quit") == 0 )
+ break;
wxDateTime dt;
const wxChar *p = dt.ParseDate(buf);
dt.GetWeekOfMonth(wxDateTime::Sunday_First),
dt.GetWeekOfYear(wxDateTime::Monday_First));
}
-
- wxPuts(wxT("\n*** done ***"));
+
+ wxPuts("\n");
}
#endif // TEST_INTERACTIVE
if ( TestFtpConnect() )
{
- #if TEST_ALL
- TestFtpList();
- TestFtpDownload();
- TestFtpMisc();
- TestFtpFileSize();
- TestFtpUpload();
- #endif // TEST_ALL
-
- #if TEST_INTERACTIVE
- //TestFtpInteractive();
- #endif
+ TestFtpInteractive();
}
//else: connecting to the FTP server failed
test_misc.o \
test_queue.o \
test_tls.o \
+ test_ftp.o \
test_uris.o \
test_url.o \
test_vectors.o \
test_tls.o: $(srcdir)/thread/tls.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/thread/tls.cpp
+test_ftp.o: $(srcdir)/uris/ftp.cpp $(TEST_ODEP)
+ $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/uris/ftp.cpp
+
test_uris.o: $(srcdir)/uris/uris.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/uris/uris.cpp
$(OBJS)\test_misc.obj \\r
$(OBJS)\test_queue.obj \\r
$(OBJS)\test_tls.obj \\r
+ $(OBJS)\test_ftp.obj \\r
$(OBJS)\test_uris.obj \\r
$(OBJS)\test_url.obj \\r
$(OBJS)\test_vectors.obj \\r
$(OBJS)\test_tls.obj: .\thread\tls.cpp\r
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\thread\tls.cpp\r
\r
+$(OBJS)\test_ftp.obj: .\uris\ftp.cpp\r
+ $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\uris\ftp.cpp\r
+\r
$(OBJS)\test_uris.obj: .\uris\uris.cpp\r
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\uris\uris.cpp\r
\r
$(OBJS)\test_misc.o \\r
$(OBJS)\test_queue.o \\r
$(OBJS)\test_tls.o \\r
+ $(OBJS)\test_ftp.o \\r
$(OBJS)\test_uris.o \\r
$(OBJS)\test_url.o \\r
$(OBJS)\test_vectors.o \\r
$(OBJS)\test_tls.o: ./thread/tls.cpp\r
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
\r
+$(OBJS)\test_ftp.o: ./uris/ftp.cpp\r
+ $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
+\r
$(OBJS)\test_uris.o: ./uris/uris.cpp\r
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
\r
$(OBJS)\test_misc.obj \\r
$(OBJS)\test_queue.obj \\r
$(OBJS)\test_tls.obj \\r
+ $(OBJS)\test_ftp.obj \\r
$(OBJS)\test_uris.obj \\r
$(OBJS)\test_url.obj \\r
$(OBJS)\test_vectors.obj \\r
$(OBJS)\test_tls.obj: .\thread\tls.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\thread\tls.cpp\r
\r
+$(OBJS)\test_ftp.obj: .\uris\ftp.cpp\r
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\uris\ftp.cpp\r
+\r
$(OBJS)\test_uris.obj: .\uris\uris.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\uris\uris.cpp\r
\r
$(OBJS)\test_misc.obj &\r
$(OBJS)\test_queue.obj &\r
$(OBJS)\test_tls.obj &\r
+ $(OBJS)\test_ftp.obj &\r
$(OBJS)\test_uris.obj &\r
$(OBJS)\test_url.obj &\r
$(OBJS)\test_vectors.obj &\r
$(OBJS)\test_tls.obj : .AUTODEPEND .\thread\tls.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
\r
+$(OBJS)\test_ftp.obj : .AUTODEPEND .\uris\ftp.cpp\r
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
+\r
$(OBJS)\test_uris.obj : .AUTODEPEND .\uris\uris.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
\r
thread/misc.cpp
thread/queue.cpp
thread/tls.cpp
+ uris/ftp.cpp
uris/uris.cpp
uris/url.cpp
vectors/vectors.cpp
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\uris\ftp.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\hashes\hashes.cpp\r
# End Source File\r
# Begin Source File\r
<File\r
RelativePath=".\fswatcher\fswatchertest.cpp">\r
</File>\r
+ <File\r
+ RelativePath=".\uris\ftp.cpp">\r
+ </File>\r
<File\r
RelativePath=".\hashes\hashes.cpp">\r
</File>\r
RelativePath=".\fswatcher\fswatchertest.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\uris\ftp.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\hashes\hashes.cpp"\r
>\r
<?xml version="1.0" encoding="Windows-1252"?>\r
-<!--\r
-\r
- This project was generated by\r
- Bakefile 0.2.8 (http://www.bakefile.org)\r
- Do not modify, all changes will be overwritten!\r
-\r
--->\r
<VisualStudioProject\r
ProjectType="Visual C++"\r
- Version="9.00"\r
+ Version="9,00"\r
Name="test"\r
ProjectGUID="{2F45723C-ED6B-5F60-8BFF-6B3609464A7B}"\r
+ TargetFrameworkVersion="0"\r
>\r
<Platforms>\r
<Platform\r
/>\r
</Platforms>\r
<ToolFiles>\r
- \r
</ToolFiles>\r
<Configurations>\r
<Configuration\r
Name="VCCLCompilerTool"\r
AdditionalOptions="/MP"\r
Optimization="0"\r
- AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;."\r
+ AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;F:\cppunit\include;."\r
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;_UNICODE;_CONSOLE;wxUSE_GUI=0"\r
ExceptionHandling="1"\r
BasicRuntimeChecks="3"\r
OutputFile="vc_mswud\test.exe"\r
LinkIncremental="2"\r
SuppressStartupBanner="true"\r
- AdditionalLibraryDirectories=".\..\lib\vc_lib"\r
+ AdditionalLibraryDirectories=".\..\lib\vc_lib;F:\cppunit\lib"\r
GenerateManifest="true"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswud\test.pdb"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswud\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswud\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswu\test.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswu\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswu\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivud\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivud\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswunivu\test.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivu\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivu\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswuddll\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswuddll\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswudll\test.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswudll\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswudll\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivuddll\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivuddll\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswunivudll\test.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivudll\test_vc9_test.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivudll\test_vc9_test.bsc"\r
/>\r
<Tool\r
Name="VCFxCopTool"\r
</Configuration>\r
</Configurations>\r
<References>\r
- \r
</References>\r
<Files>\r
<Filter\r
RelativePath=".\fswatcher\fswatchertest.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\uris\ftp.cpp"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\hashes\hashes.cpp"\r
>\r
</Filter>\r
</Files>\r
<Globals>\r
- \r
</Globals>\r
</VisualStudioProject>\r
-\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/uris/ftp.cpp
+// Purpose: wxFTP unit test
+// Author: Francesco Montorsi (extracted from console sample)
+// Created: 2010-05-23
+// RCS-ID: $Id$
+// Copyright: (c) 2010 wxWidgets team
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif // WX_PRECOMP
+
+#include <wx/protocol/ftp.h>
+
+#define FTP_ANONYMOUS
+
+#ifdef FTP_ANONYMOUS
+ static const char *hostname = "ftp.wxwidgets.org";
+ static const char *directory = "/pub/2.8.11";
+ static const char *invalid_filename = "a_file_which_does_not_exist";
+ static const char *valid_filename = "MD5SUM";
+ // NOTE: choose a small file or otherwise the FTPTestCase::Download()
+ // function will take (a lot of) time to complete!
+#else
+ static const char *hostname = "localhost";
+ static const char *user = "guest";
+ static const char *password = "";
+ static const char *directory = "/etc";
+ static const char *invalid_filename = "issue";
+ static const char *valid_filename = "hosts";
+#endif
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class FTPTestCase : public CppUnit::TestCase
+{
+public:
+ FTPTestCase() {}
+
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ CPPUNIT_TEST_SUITE( FTPTestCase );
+ CPPUNIT_TEST( List );
+ CPPUNIT_TEST( Download );
+ CPPUNIT_TEST( FileSize );
+ CPPUNIT_TEST( Misc );
+#ifndef FTP_ANONYMOUS
+ CPPUNIT_TEST( Upload );
+#endif
+ CPPUNIT_TEST_SUITE_END();
+
+ void List();
+ void Download();
+ void FileSize();
+ void Misc();
+ void Upload();
+
+ wxFTP *m_ftp;
+
+ DECLARE_NO_COPY_CLASS(FTPTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( FTPTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FTPTestCase, "FTPTestCase" );
+
+
+void FTPTestCase::setUp()
+{
+ wxSocketBase::Initialize();
+
+ // wxFTP cannot be a static variable as its ctor needs to access
+ // wxWidgets internals after it has been initialized
+ m_ftp = new wxFTP;
+
+#ifndef FTP_ANONYMOUS
+ m_ftp->SetUser(user);
+ m_ftp->SetPassword(password);
+#endif // FTP_ANONYMOUS/!FTP_ANONYMOUS
+}
+
+void FTPTestCase::tearDown()
+{
+ delete m_ftp;
+
+ wxSocketBase::Shutdown();
+}
+
+void FTPTestCase::List()
+{
+ CPPUNIT_ASSERT( m_ftp->Connect(hostname) );
+
+ // test CWD
+ CPPUNIT_ASSERT( m_ftp->ChDir(directory) );
+
+ // test NLIST and LIST
+ wxArrayString files;
+ CPPUNIT_ASSERT( m_ftp->GetFilesList(files) );
+ CPPUNIT_ASSERT( m_ftp->GetDirList(files) );
+
+ CPPUNIT_ASSERT( m_ftp->ChDir(wxT("..")) );
+}
+
+void FTPTestCase::Download()
+{
+ CPPUNIT_ASSERT( m_ftp->Connect(hostname) );
+ CPPUNIT_ASSERT( m_ftp->ChDir(directory) );
+
+ // test RETR
+ wxInputStream *in1 = m_ftp->GetInputStream(invalid_filename);
+ CPPUNIT_ASSERT( in1 == NULL );
+ delete in1;
+
+ wxInputStream *in2 = m_ftp->GetInputStream(valid_filename);
+ CPPUNIT_ASSERT( in2 != NULL );
+
+ size_t size = in2->GetSize();
+ wxChar *data = new wxChar[size];
+ CPPUNIT_ASSERT( in2->Read(data, size).GetLastError() == wxSTREAM_NO_ERROR );
+
+ delete [] data;
+ delete in2;
+}
+
+void FTPTestCase::FileSize()
+{
+ CPPUNIT_ASSERT( m_ftp->Connect(hostname) );
+
+ CPPUNIT_ASSERT( m_ftp->ChDir(directory) );
+
+ CPPUNIT_ASSERT( m_ftp->FileExists(valid_filename) );
+
+ int size = m_ftp->GetFileSize(valid_filename);
+ CPPUNIT_ASSERT( size != -1 );
+}
+
+void FTPTestCase::Misc()
+{
+ CPPUNIT_ASSERT( m_ftp->Connect(hostname) );
+
+ CPPUNIT_ASSERT( m_ftp->SendCommand(wxT("STAT")) == '2' );
+ CPPUNIT_ASSERT( m_ftp->SendCommand(wxT("HELP SITE")) == '2' );
+}
+
+#ifndef FTP_ANONYMOUS
+void FTPTestCase::Upload()
+{
+ CPPUNIT_ASSERT( m_ftp->Connect(hostname) );
+
+ // upload a file
+ static const wxChar *file1 = wxT("test1");
+ wxOutputStream *out = m_ftp->GetOutputStream(file1);
+ CPPUNIT_ASSERT( out != NULL );
+ CPPUNIT_ASSERT( out->Write("First hello", 11).GetLastError() == wxSTREAM_NO_ERROR );
+ delete out;
+
+ // send a command to check the remote file
+ CPPUNIT_ASSERT( m_ftp->SendCommand(wxString(wxT("STAT ")) + file1) == '2' );
+ CPPUNIT_ASSERT( m_ftp->GetLastResult() == "11" );
+}
+#endif
+
+