move all non-interactive FTP tests from the console sample to a new CppUnit FTPTestCase test.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64422 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -114,7 +114,6 @@
|
|||||||
#define TEST_FILECONF
|
#define TEST_FILECONF
|
||||||
#define TEST_FILENAME
|
#define TEST_FILENAME
|
||||||
#define TEST_FILETIME
|
#define TEST_FILETIME
|
||||||
#define TEST_FTP
|
|
||||||
#define TEST_INFO_FUNCTIONS
|
#define TEST_INFO_FUNCTIONS
|
||||||
#define TEST_LOCALE
|
#define TEST_LOCALE
|
||||||
#define TEST_LOG
|
#define TEST_LOG
|
||||||
@@ -128,11 +127,12 @@
|
|||||||
#define TEST_SCOPEGUARD
|
#define TEST_SCOPEGUARD
|
||||||
#define TEST_SNGLINST
|
#define TEST_SNGLINST
|
||||||
// #define TEST_SOCKETS --FIXME! (RN)
|
// #define TEST_SOCKETS --FIXME! (RN)
|
||||||
#define TEST_STACKWALKER
|
|
||||||
#define TEST_STDPATHS
|
|
||||||
#else // #if TEST_ALL
|
#else // #if TEST_ALL
|
||||||
#define TEST_DATETIME
|
#define TEST_DATETIME
|
||||||
#define TEST_VOLUME
|
#define TEST_VOLUME
|
||||||
|
#define TEST_STDPATHS
|
||||||
|
#define TEST_STACKWALKER
|
||||||
|
#define TEST_FTP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// some tests are interactive, define this to run them
|
// some tests are interactive, define this to run them
|
||||||
@@ -2367,9 +2367,11 @@ static void TestSocketClient()
|
|||||||
static wxFTP *ftp;
|
static wxFTP *ftp;
|
||||||
|
|
||||||
#ifdef FTP_ANONYMOUS
|
#ifdef FTP_ANONYMOUS
|
||||||
|
static const wxChar *hostname = wxT("ftp.wxwidgets.org");
|
||||||
static const wxChar *directory = wxT("/pub");
|
static const wxChar *directory = wxT("/pub");
|
||||||
static const wxChar *filename = wxT("welcome.msg");
|
static const wxChar *filename = wxT("welcome.msg");
|
||||||
#else
|
#else
|
||||||
|
static const wxChar *hostname = "localhost";
|
||||||
static const wxChar *directory = wxT("/etc");
|
static const wxChar *directory = wxT("/etc");
|
||||||
static const wxChar *filename = wxT("issue");
|
static const wxChar *filename = wxT("issue");
|
||||||
#endif
|
#endif
|
||||||
@@ -2379,12 +2381,8 @@ static bool TestFtpConnect()
|
|||||||
wxPuts(wxT("*** Testing FTP connect ***"));
|
wxPuts(wxT("*** Testing FTP connect ***"));
|
||||||
|
|
||||||
#ifdef FTP_ANONYMOUS
|
#ifdef FTP_ANONYMOUS
|
||||||
static const wxChar *hostname = wxT("ftp.wxwidgets.org");
|
|
||||||
|
|
||||||
wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
|
wxPrintf(wxT("--- Attempting to connect to %s:21 anonymously...\n"), hostname);
|
||||||
#else // !FTP_ANONYMOUS
|
#else // !FTP_ANONYMOUS
|
||||||
static const wxChar *hostname = "localhost";
|
|
||||||
|
|
||||||
wxChar user[256];
|
wxChar user[256];
|
||||||
wxFgets(user, WXSIZEOF(user), stdin);
|
wxFgets(user, WXSIZEOF(user), stdin);
|
||||||
user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
|
user[wxStrlen(user) - 1] = '\0'; // chop off '\n'
|
||||||
@@ -2415,140 +2413,6 @@ static bool TestFtpConnect()
|
|||||||
return true;
|
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()
|
static void TestFtpInteractive()
|
||||||
{
|
{
|
||||||
wxPuts(wxT("\n*** Interactive wxFTP test ***"));
|
wxPuts(wxT("\n*** Interactive wxFTP test ***"));
|
||||||
@@ -2557,7 +2421,7 @@ static void TestFtpInteractive()
|
|||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
wxPrintf(wxT("Enter FTP command: "));
|
wxPrintf(wxT("Enter FTP command (or 'quit' to escape): "));
|
||||||
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
|
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2590,6 +2454,10 @@ static void TestFtpInteractive()
|
|||||||
wxPuts(wxT("--- End of the file list"));
|
wxPuts(wxT("--- End of the file list"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( start == wxT("QUIT") )
|
||||||
|
{
|
||||||
|
break; // get out of here!
|
||||||
|
}
|
||||||
else // !list
|
else // !list
|
||||||
{
|
{
|
||||||
wxChar ch = ftp->SendCommand(buf);
|
wxChar ch = ftp->SendCommand(buf);
|
||||||
@@ -2606,43 +2474,6 @@ static void TestFtpInteractive()
|
|||||||
wxPuts(wxT("\n*** done ***"));
|
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
|
#endif // TEST_FTP
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -2710,6 +2541,8 @@ static void TestStackWalk(const char *argv0)
|
|||||||
|
|
||||||
StackDump dump(argv0);
|
StackDump dump(argv0);
|
||||||
dump.Walk();
|
dump.Walk();
|
||||||
|
|
||||||
|
wxPuts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_STACKWALKER
|
#endif // wxUSE_STACKWALKER
|
||||||
@@ -2750,6 +2583,8 @@ static void TestStandardPaths()
|
|||||||
wxT("fr"),
|
wxT("fr"),
|
||||||
wxStandardPaths::ResourceCat_Messages
|
wxStandardPaths::ResourceCat_Messages
|
||||||
).c_str());
|
).c_str());
|
||||||
|
|
||||||
|
wxPuts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TEST_STDPATHS
|
#endif // TEST_STDPATHS
|
||||||
@@ -2809,6 +2644,8 @@ static void TestFSVolume()
|
|||||||
vol.GetFlags() & wxFS_VOL_REMOVABLE ? wxT("removable")
|
vol.GetFlags() & wxFS_VOL_REMOVABLE ? wxT("removable")
|
||||||
: wxT("fixed"));
|
: wxT("fixed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPuts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TEST_VOLUME
|
#endif // TEST_VOLUME
|
||||||
@@ -2832,12 +2669,15 @@ static void TestDateTimeInteractive()
|
|||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
wxPrintf(wxT("Enter a date: "));
|
wxPrintf(wxT("Enter a date (or 'quit' to escape): "));
|
||||||
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
|
if ( !wxFgets(buf, WXSIZEOF(buf), stdin) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// kill the last '\n'
|
// kill the last '\n'
|
||||||
buf[wxStrlen(buf) - 1] = 0;
|
buf[wxStrlen(buf) - 1] = 0;
|
||||||
|
|
||||||
|
if ( wxString(buf).CmpNoCase("quit") == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
wxDateTime dt;
|
wxDateTime dt;
|
||||||
const wxChar *p = dt.ParseDate(buf);
|
const wxChar *p = dt.ParseDate(buf);
|
||||||
@@ -2859,8 +2699,8 @@ static void TestDateTimeInteractive()
|
|||||||
dt.GetWeekOfMonth(wxDateTime::Sunday_First),
|
dt.GetWeekOfMonth(wxDateTime::Sunday_First),
|
||||||
dt.GetWeekOfYear(wxDateTime::Monday_First));
|
dt.GetWeekOfYear(wxDateTime::Monday_First));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPuts(wxT("\n*** done ***"));
|
wxPuts("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TEST_INTERACTIVE
|
#endif // TEST_INTERACTIVE
|
||||||
@@ -3056,17 +2896,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if ( TestFtpConnect() )
|
if ( TestFtpConnect() )
|
||||||
{
|
{
|
||||||
#if TEST_ALL
|
TestFtpInteractive();
|
||||||
TestFtpList();
|
|
||||||
TestFtpDownload();
|
|
||||||
TestFtpMisc();
|
|
||||||
TestFtpFileSize();
|
|
||||||
TestFtpUpload();
|
|
||||||
#endif // TEST_ALL
|
|
||||||
|
|
||||||
#if TEST_INTERACTIVE
|
|
||||||
//TestFtpInteractive();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//else: connecting to the FTP server failed
|
//else: connecting to the FTP server failed
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ TEST_OBJECTS = \
|
|||||||
test_misc.o \
|
test_misc.o \
|
||||||
test_queue.o \
|
test_queue.o \
|
||||||
test_tls.o \
|
test_tls.o \
|
||||||
|
test_ftp.o \
|
||||||
test_uris.o \
|
test_uris.o \
|
||||||
test_url.o \
|
test_url.o \
|
||||||
test_vectors.o \
|
test_vectors.o \
|
||||||
@@ -546,6 +547,9 @@ test_queue.o: $(srcdir)/thread/queue.cpp $(TEST_ODEP)
|
|||||||
test_tls.o: $(srcdir)/thread/tls.cpp $(TEST_ODEP)
|
test_tls.o: $(srcdir)/thread/tls.cpp $(TEST_ODEP)
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/thread/tls.cpp
|
$(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)
|
test_uris.o: $(srcdir)/uris/uris.cpp $(TEST_ODEP)
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/uris/uris.cpp
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/uris/uris.cpp
|
||||||
|
|
||||||
|
@@ -101,6 +101,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_misc.obj \
|
$(OBJS)\test_misc.obj \
|
||||||
$(OBJS)\test_queue.obj \
|
$(OBJS)\test_queue.obj \
|
||||||
$(OBJS)\test_tls.obj \
|
$(OBJS)\test_tls.obj \
|
||||||
|
$(OBJS)\test_ftp.obj \
|
||||||
$(OBJS)\test_uris.obj \
|
$(OBJS)\test_uris.obj \
|
||||||
$(OBJS)\test_url.obj \
|
$(OBJS)\test_url.obj \
|
||||||
$(OBJS)\test_vectors.obj \
|
$(OBJS)\test_vectors.obj \
|
||||||
@@ -588,6 +589,9 @@ $(OBJS)\test_queue.obj: .\thread\queue.cpp
|
|||||||
$(OBJS)\test_tls.obj: .\thread\tls.cpp
|
$(OBJS)\test_tls.obj: .\thread\tls.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\thread\tls.cpp
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\thread\tls.cpp
|
||||||
|
|
||||||
|
$(OBJS)\test_ftp.obj: .\uris\ftp.cpp
|
||||||
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\uris\ftp.cpp
|
||||||
|
|
||||||
$(OBJS)\test_uris.obj: .\uris\uris.cpp
|
$(OBJS)\test_uris.obj: .\uris\uris.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\uris\uris.cpp
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\uris\uris.cpp
|
||||||
|
|
||||||
|
@@ -93,6 +93,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_misc.o \
|
$(OBJS)\test_misc.o \
|
||||||
$(OBJS)\test_queue.o \
|
$(OBJS)\test_queue.o \
|
||||||
$(OBJS)\test_tls.o \
|
$(OBJS)\test_tls.o \
|
||||||
|
$(OBJS)\test_ftp.o \
|
||||||
$(OBJS)\test_uris.o \
|
$(OBJS)\test_uris.o \
|
||||||
$(OBJS)\test_url.o \
|
$(OBJS)\test_url.o \
|
||||||
$(OBJS)\test_vectors.o \
|
$(OBJS)\test_vectors.o \
|
||||||
@@ -569,6 +570,9 @@ $(OBJS)\test_queue.o: ./thread/queue.cpp
|
|||||||
$(OBJS)\test_tls.o: ./thread/tls.cpp
|
$(OBJS)\test_tls.o: ./thread/tls.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_ftp.o: ./uris/ftp.cpp
|
||||||
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
$(OBJS)\test_uris.o: ./uris/uris.cpp
|
$(OBJS)\test_uris.o: ./uris/uris.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
|
@@ -95,6 +95,7 @@ TEST_OBJECTS = \
|
|||||||
$(OBJS)\test_misc.obj \
|
$(OBJS)\test_misc.obj \
|
||||||
$(OBJS)\test_queue.obj \
|
$(OBJS)\test_queue.obj \
|
||||||
$(OBJS)\test_tls.obj \
|
$(OBJS)\test_tls.obj \
|
||||||
|
$(OBJS)\test_ftp.obj \
|
||||||
$(OBJS)\test_uris.obj \
|
$(OBJS)\test_uris.obj \
|
||||||
$(OBJS)\test_url.obj \
|
$(OBJS)\test_url.obj \
|
||||||
$(OBJS)\test_vectors.obj \
|
$(OBJS)\test_vectors.obj \
|
||||||
@@ -714,6 +715,9 @@ $(OBJS)\test_queue.obj: .\thread\queue.cpp
|
|||||||
$(OBJS)\test_tls.obj: .\thread\tls.cpp
|
$(OBJS)\test_tls.obj: .\thread\tls.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\thread\tls.cpp
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\thread\tls.cpp
|
||||||
|
|
||||||
|
$(OBJS)\test_ftp.obj: .\uris\ftp.cpp
|
||||||
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\uris\ftp.cpp
|
||||||
|
|
||||||
$(OBJS)\test_uris.obj: .\uris\uris.cpp
|
$(OBJS)\test_uris.obj: .\uris\uris.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\uris\uris.cpp
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\uris\uris.cpp
|
||||||
|
|
||||||
|
@@ -331,6 +331,7 @@ TEST_OBJECTS = &
|
|||||||
$(OBJS)\test_misc.obj &
|
$(OBJS)\test_misc.obj &
|
||||||
$(OBJS)\test_queue.obj &
|
$(OBJS)\test_queue.obj &
|
||||||
$(OBJS)\test_tls.obj &
|
$(OBJS)\test_tls.obj &
|
||||||
|
$(OBJS)\test_ftp.obj &
|
||||||
$(OBJS)\test_uris.obj &
|
$(OBJS)\test_uris.obj &
|
||||||
$(OBJS)\test_url.obj &
|
$(OBJS)\test_url.obj &
|
||||||
$(OBJS)\test_vectors.obj &
|
$(OBJS)\test_vectors.obj &
|
||||||
@@ -626,6 +627,9 @@ $(OBJS)\test_queue.obj : .AUTODEPEND .\thread\queue.cpp
|
|||||||
$(OBJS)\test_tls.obj : .AUTODEPEND .\thread\tls.cpp
|
$(OBJS)\test_tls.obj : .AUTODEPEND .\thread\tls.cpp
|
||||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
$(OBJS)\test_ftp.obj : .AUTODEPEND .\uris\ftp.cpp
|
||||||
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
$(OBJS)\test_uris.obj : .AUTODEPEND .\uris\uris.cpp
|
$(OBJS)\test_uris.obj : .AUTODEPEND .\uris\uris.cpp
|
||||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<
|
||||||
|
|
||||||
|
@@ -92,6 +92,7 @@
|
|||||||
thread/misc.cpp
|
thread/misc.cpp
|
||||||
thread/queue.cpp
|
thread/queue.cpp
|
||||||
thread/tls.cpp
|
thread/tls.cpp
|
||||||
|
uris/ftp.cpp
|
||||||
uris/uris.cpp
|
uris/uris.cpp
|
||||||
uris/url.cpp
|
uris/url.cpp
|
||||||
vectors/vectors.cpp
|
vectors/vectors.cpp
|
||||||
|
@@ -345,6 +345,10 @@ SOURCE=.\fswatcher\fswatchertest.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\uris\ftp.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\hashes\hashes.cpp
|
SOURCE=.\hashes\hashes.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -694,6 +694,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\fswatcher\fswatchertest.cpp">
|
RelativePath=".\fswatcher\fswatchertest.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\uris\ftp.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\hashes\hashes.cpp">
|
RelativePath=".\hashes\hashes.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
@@ -999,6 +999,10 @@
|
|||||||
RelativePath=".\fswatcher\fswatchertest.cpp"
|
RelativePath=".\fswatcher\fswatchertest.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\uris\ftp.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\hashes\hashes.cpp"
|
RelativePath=".\hashes\hashes.cpp"
|
||||||
>
|
>
|
||||||
|
@@ -1,16 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<!--
|
|
||||||
|
|
||||||
This project was generated by
|
|
||||||
Bakefile 0.2.8 (http://www.bakefile.org)
|
|
||||||
Do not modify, all changes will be overwritten!
|
|
||||||
|
|
||||||
-->
|
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="test"
|
Name="test"
|
||||||
ProjectGUID="{2F45723C-ED6B-5F60-8BFF-6B3609464A7B}"
|
ProjectGUID="{2F45723C-ED6B-5F60-8BFF-6B3609464A7B}"
|
||||||
|
TargetFrameworkVersion="0"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
@@ -18,7 +12,6 @@
|
|||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
|
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
@@ -51,7 +44,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions="/MP"
|
AdditionalOptions="/MP"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;."
|
AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;F:\cppunit\include;."
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;_UNICODE;_CONSOLE;wxUSE_GUI=0"
|
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;_UNICODE;_CONSOLE;wxUSE_GUI=0"
|
||||||
ExceptionHandling="1"
|
ExceptionHandling="1"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -86,7 +79,7 @@
|
|||||||
OutputFile="vc_mswud\test.exe"
|
OutputFile="vc_mswud\test.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
AdditionalLibraryDirectories=".\..\lib\vc_lib"
|
AdditionalLibraryDirectories=".\..\lib\vc_lib;F:\cppunit\lib"
|
||||||
GenerateManifest="true"
|
GenerateManifest="true"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="vc_mswud\test.pdb"
|
ProgramDatabaseFile="vc_mswud\test.pdb"
|
||||||
@@ -104,8 +97,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswud\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswud\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -185,9 +178,9 @@
|
|||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="vc_mswu\test.pdb"
|
ProgramDatabaseFile="vc_mswu\test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@@ -200,8 +193,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswu\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswu\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -296,8 +289,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswunivud\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswunivud\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -377,9 +370,9 @@
|
|||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="vc_mswunivu\test.pdb"
|
ProgramDatabaseFile="vc_mswunivu\test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@@ -392,8 +385,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswunivu\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswunivu\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -488,8 +481,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswuddll\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswuddll\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -569,9 +562,9 @@
|
|||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="vc_mswudll\test.pdb"
|
ProgramDatabaseFile="vc_mswudll\test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@@ -584,8 +577,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswudll\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswudll\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -680,8 +673,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswunivuddll\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswunivuddll\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -761,9 +754,9 @@
|
|||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="vc_mswunivudll\test.pdb"
|
ProgramDatabaseFile="vc_mswunivudll\test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@@ -776,8 +769,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
OutputFile="vc_mswunivudll\test_vc9_test.bsc"
|
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile="vc_mswunivudll\test_vc9_test.bsc"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
@@ -791,7 +784,6 @@
|
|||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
|
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
@@ -971,6 +963,10 @@
|
|||||||
RelativePath=".\fswatcher\fswatchertest.cpp"
|
RelativePath=".\fswatcher\fswatchertest.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\uris\ftp.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\hashes\hashes.cpp"
|
RelativePath=".\hashes\hashes.cpp"
|
||||||
>
|
>
|
||||||
@@ -1154,7 +1150,5 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|
||||||
|
180
tests/uris/ftp.cpp
Normal file
180
tests/uris/ftp.cpp
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user