diff options
Diffstat (limited to 'cppe')
-rwxr-xr-x | cppe/include/IceE/LocalException.h | 6 | ||||
-rwxr-xr-x | cppe/src/IceE/Connection.cpp | 4 | ||||
-rwxr-xr-x | cppe/src/IceE/LocalException.cpp | 57 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.cpp | 78 | ||||
-rwxr-xr-x | cppe/test/Common/TestCommon.cpp | 151 |
5 files changed, 168 insertions, 128 deletions
diff --git a/cppe/include/IceE/LocalException.h b/cppe/include/IceE/LocalException.h index e4bb4140fef..7971f89a82e 100755 --- a/cppe/include/IceE/LocalException.h +++ b/cppe/include/IceE/LocalException.h @@ -598,16 +598,18 @@ public: virtual void ice_throw() const;
};
-class ICEE_API CompressionNotSupportedException : public ::Ice::ProtocolException
+class ICEE_API FeatureNotSupportedException : public ::Ice::LocalException
{
public:
- CompressionNotSupportedException(const char*, int);
+ FeatureNotSupportedException(const char*, int);
virtual const ::std::string ice_name() const;
virtual ::std::string toString() const;
virtual ::Ice::Exception* ice_clone() const;
virtual void ice_throw() const;
+
+ ::std::string unsupportedFeature;
};
class ICEE_API MarshalException : public ::Ice::ProtocolException
diff --git a/cppe/src/IceE/Connection.cpp b/cppe/src/IceE/Connection.cpp index ad4b5e89bd3..dd1e9cbd7b4 100755 --- a/cppe/src/IceE/Connection.cpp +++ b/cppe/src/IceE/Connection.cpp @@ -1251,7 +1251,9 @@ Ice::Connection::parseMessage(BasicStream& stream, Int& requestId stream.read(compress); if(compress == 2) { - throw CompressionNotSupportedException(__FILE__, __LINE__); + FeatureNotSupportedException ex(__FILE__, __LINE__); + ex.unsupportedFeature = "compression"; + throw ex; } stream.i = stream.b.begin() + headerSize; diff --git a/cppe/src/IceE/LocalException.cpp b/cppe/src/IceE/LocalException.cpp index 00531301eb2..98415674bc6 100755 --- a/cppe/src/IceE/LocalException.cpp +++ b/cppe/src/IceE/LocalException.cpp @@ -1538,31 +1538,31 @@ Ice::IllegalMessageSizeException::ice_throw() const throw *this;
}
-Ice::CompressionNotSupportedException::CompressionNotSupportedException(const char* __file, int __line) :
+Ice::FeatureNotSupportedException::FeatureNotSupportedException(const char* __file, int __line) :
#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug
- ProtocolException(__file, __line)
+ LocalException(__file, __line)
#else
- ::Ice::ProtocolException(__file, __line)
+ ::Ice::LocalException(__file, __line)
#endif
{
}
-static const char* __Ice__CompressionNotSupportedException_name = "Ice::CompressionNotSupportedException";
+static const char* __Ice__FeatureNotSupportedException_name = "Ice::FeatureNotSupportedException";
const ::std::string
-Ice::CompressionNotSupportedException::ice_name() const
+Ice::FeatureNotSupportedException::ice_name() const
{
- return __Ice__CompressionNotSupportedException_name;
+ return __Ice__FeatureNotSupportedException_name;
}
::Ice::Exception*
-Ice::CompressionNotSupportedException::ice_clone() const
+Ice::FeatureNotSupportedException::ice_clone() const
{
- return new CompressionNotSupportedException(*this);
+ return new FeatureNotSupportedException(*this);
}
void
-Ice::CompressionNotSupportedException::ice_throw() const
+Ice::FeatureNotSupportedException::ice_throw() const
{
throw *this;
}
@@ -1850,7 +1850,8 @@ Ice::CommunicatorDestroyedException::toString() const out += ":\ncommunicator object destroyed";
return out;
}
-
+ +
#ifdef never
#endif
@@ -1974,16 +1975,26 @@ Ice::SocketException::toString() const string
Ice::FileException::toString() const
-{
- string out = Exception::toString();
- out += ":\nfile exception: ";
- out += errorToString(error);
- if(!path.empty())
- {
- out += "\npath: ";
- out += path;
- }
- return out;
+{ +
+ string out = Exception::toString(); +
+ out += ":\nfile exception: "; +
+ out += errorToString(error); +
+ if(!path.empty()) +
+ { +
+ out += "\npath: "; +
+ out += path; +
+ } +
+ return out; +
}
string
@@ -2165,10 +2176,12 @@ Ice::IllegalMessageSizeException::toString() const }
string
-Ice::CompressionNotSupportedException::toString() const
+Ice::FeatureNotSupportedException::toString() const
{
string out = Exception::toString();
- out += ":\nprotocol error: compressed messages not supported";
+ out += ":\nfeature `";
+ out += unsupportedFeature;
+ out += "' is not supported.";
return out;
}
diff --git a/cppe/src/IceE/Reference.cpp b/cppe/src/IceE/Reference.cpp index 5250e2fb502..678914b9d37 100644 --- a/cppe/src/IceE/Reference.cpp +++ b/cppe/src/IceE/Reference.cpp @@ -495,8 +495,32 @@ IceInternal::FixedReference::getConnection() const #endif ) { - NoEndpointException ex(__FILE__, __LINE__); - ex.proxy = toString(); + if(_fixedConnections.empty()) + { + NoEndpointException ex(__FILE__, __LINE__); + ex.proxy = toString(); + throw ex; + } + + FeatureNotSupportedException ex(__FILE__, __LINE__); + if(getSecure()) + { + ex.unsupportedFeature = "ssl"; + } + else if(getMode() == ModeDatagram) + { + ex.unsupportedFeature = "datagram"; + } + else if(getMode() == ModeBatchDatagram) + { + ex.unsupportedFeature = "batch datagram"; + } +#ifndef ICEE_HAS_BATCH + else if(getMode() == ModeBatchOneway) + { + ex.unsupportedFeature = "batch"; + } +#endif throw ex; } @@ -826,15 +850,6 @@ IceInternal::DirectReference::toString() const ConnectionPtr IceInternal::DirectReference::getConnection() const { -#ifndef ICEE_HAS_BATCH - if(getMode() == ModeBatchOneway) - { - NoEndpointException ex(__FILE__, __LINE__); - ex.proxy = toString(); - throw ex; - } -#endif - #ifdef ICEE_HAS_ROUTER vector<EndpointPtr> endpts = Parent::getRoutedEndpoints(); if(endpts.empty()) @@ -1066,15 +1081,6 @@ IceInternal::IndirectReference::toString() const ConnectionPtr IceInternal::IndirectReference::getConnection() const { -#ifndef ICEE_HAS_BATCH - if(getMode() == ModeBatchOneway) - { - NoEndpointException ex(__FILE__, __LINE__); - ex.proxy = toString(); - throw ex; - } -#endif - ConnectionPtr connection; while(true) @@ -1220,12 +1226,36 @@ IceInternal::filterEndpoints(const vector<EndpointPtr>& allEndpoints, Reference: vector<EndpointPtr> endpoints; // - // If a secure endpoint, datagram or batch datagram endpoint is - // requested since IceE lacks this support we return no endpoints. + // If a secure endpoint, batch (if batch is not supported), + // datagram or batch datagram endpoint is requested since IceE + // lacks this support we throw an unsupported feature. // - if(sec || m == Reference::ModeDatagram || m == Reference::ModeBatchDatagram) + if(sec || m == Reference::ModeDatagram || m == Reference::ModeBatchDatagram +#ifndef ICEE_HAS_BATCH + || m == Reference::ModeBatchOneway +#endif + ) { - return endpoints; + FeatureNotSupportedException ex(__FILE__, __LINE__); + if(sec) + { + ex.unsupportedFeature = "ssl"; + } + else if(m == Reference::ModeDatagram) + { + ex.unsupportedFeature = "datagram"; + } + else if(m == Reference::ModeBatchDatagram) + { + ex.unsupportedFeature = "batch datagram"; + } +#ifndef ICEE_HAS_BATCH + else if(m == Reference::ModeBatchOneway) + { + ex.unsupportedFeature = "batch"; + } +#endif + throw ex; } endpoints = allEndpoints; diff --git a/cppe/test/Common/TestCommon.cpp b/cppe/test/Common/TestCommon.cpp index 2d1809dc91f..343a71207d5 100755 --- a/cppe/test/Common/TestCommon.cpp +++ b/cppe/test/Common/TestCommon.cpp @@ -7,24 +7,23 @@ // // ********************************************************************** -#include <TestCommon.h>
-#include <TestApplication.h>
-#include <IceE/StaticMutex.h>
+#include <TestCommon.h> +#include <TestApplication.h> + +#include <IceE/StaticMutex.h> #include <IceE/Thread.h> -#ifndef _WIN32 -# include <IceE/Time.h> -#endif +#include <IceE/Time.h> #include <stdarg.h> -using namespace Ice;
using namespace std; +using namespace Ice; class LoggerI : public Logger { public: -
- virtual void
+ + virtual void print(const string& message) { tprintf("%s\n", message.c_str()); @@ -32,16 +31,18 @@ public: virtual void trace(const string& category, const string& message) - {
+ { string s = "[ ";
-#ifdef _WIN32 - char buf[1024];
- sprintf(buf, "%ld", GetTickCount()); - s += buf;
+#ifdef _WIN32
+ {
+ char buf[1024];
+ sprintf(buf, "%ld", GetTickCount());
+ s += buf;
+ }
#else - s += IceUtil::Time::now().toMilliSeconds(); + s += IceUtil::Time::now().toMilliSeconds();
#endif - s += ' ';
+ s += ' '; if(!category.empty()) { @@ -71,7 +72,7 @@ public: } }; -static IceUtil::StaticMutex terminatedMutex = ICEE_STATIC_MUTEX_INITIALIZER;
+static IceUtil::StaticMutex terminatedMutex = ICEE_STATIC_MUTEX_INITIALIZER; static bool appTerminated= false; #ifdef _WIN32_WCE @@ -84,7 +85,7 @@ class TestSuiteFailed { public: }; -
+ static FILE* _tprintfp = 0; static HWND hEdit; static HWND mainWnd; @@ -92,20 +93,20 @@ static IceUtil::ThreadControl mainThread; void tprintf(const char* fmt, ...) -{
+{ va_list va; va_start(va, fmt); char buf[1024]; _vsnprintf(buf, sizeof(buf)-1, fmt, va); buf[sizeof(buf)-1] = '\0'; - va_end(va);
-
- if(_tprintfp)
- {
- fwrite(buf, strlen(buf), 1, _tprintfp);
- fflush(_tprintfp);
- return;
- }
+ va_end(va); + + if(_tprintfp) + { + fwrite(buf, strlen(buf), 1, _tprintfp); + fflush(_tprintfp); + return; + } char* start = buf; const char* end = start + strlen(start); @@ -125,11 +126,11 @@ tprintf(const char* fmt, ...) } *curr = '\0'; static TCHAR nlStr[] = L"\r\n"; -
- //
- // If the thread is not the main thread we have to post a message
- // to the main thread to do the EM_REPLACESEL. Calling SendMessage
- // from a thread other than main is not permitted.
+ + // + // If the thread is not the main thread we have to post a message + // to the main thread to do the EM_REPLACESEL. Calling SendMessage + // from a thread other than main is not permitted. // if(IceUtil::ThreadControl() != mainThread) { @@ -187,14 +188,11 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_CREATE: { - //HFONT hfDefault; - RECT rcClient; GetClientRect(hWnd, &rcClient); hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", - WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE, + WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, - /*0,0,100,100,*/ hWnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL); assert(hEdit != NULL); } @@ -202,12 +200,8 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SIZE: { - HWND hEdit; RECT rcClient; - GetClientRect(hWnd, &rcClient); - - hEdit = GetDlgItem(hWnd, IDC_MAIN_EDIT); SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER); } break; @@ -217,7 +211,7 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) DestroyWindow(hWnd); break; } -
+ case WM_QUIT: case WM_DESTROY: { @@ -243,7 +237,7 @@ TestApplication::main(HINSTANCE hInstance) wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, 0/*IDI_APPLICATION*/); + wc.hIcon = LoadIcon(NULL, 0); wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; @@ -251,42 +245,40 @@ TestApplication::main(HINSTANCE hInstance) if(!RegisterClass(&wc)) { - MessageBox(NULL, L"Window Registration Failed!", L"Error!", - MB_ICONEXCLAMATION | MB_OK); + MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } -
- wchar_t wName[1024] = L"Test";
- if(_name.size() > 0)
- {
- int len = _name.size();
- if(len > 1023)
- {
- len = 1023;
- }
- mbstowcs(wName, _name.c_str(), len);
- wName[len] = L'\0';
- } -
- RECT rect;
- GetClientRect(GetDesktopWindow(), &rect);
- int width = rect.right - rect.left;
- if(width > 320)
- {
- width = 320;
- }
- int height = rect.bottom - rect.top;
- if(height > 200)
- {
- height = 200;
- }
+ + wchar_t wName[1024] = L"Test"; + if(_name.size() > 0) + { + int len = _name.size(); + if(len > 1023) + { + len = 1023; + } + mbstowcs(wName, _name.c_str(), len); + wName[len] = L'\0'; + } + + RECT rect; + GetClientRect(GetDesktopWindow(), &rect); + int width = rect.right - rect.left; + if(width > 320) + { + width = 320; + } + int height = rect.bottom - rect.top; + if(height > 200) + { + height = 200; + } mainWnd = CreateWindow(windowClassName, wName, WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); if(mainWnd == NULL) { - MessageBox(NULL, L"Window Creation Failed!", L"Error!", - MB_ICONEXCLAMATION | MB_OK); + MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } @@ -299,6 +291,7 @@ TestApplication::main(HINSTANCE hInstance) extern int __argc; extern char **__argv; status = run(__argc, __argv); + tprintf("\ntest complete\n"); } catch(const TestSuiteFailed&) { @@ -314,7 +307,7 @@ TestApplication::main(HINSTANCE hInstance) tprintf("std::exception: %s\n", ex.what()); status = EXIT_FAILURE; } - catch(const std::string& msg) + catch(const string& msg) { tprintf("std::string: %s\n", msg.c_str()); status = EXIT_FAILURE; @@ -385,9 +378,9 @@ TestApplication::loadConfig(const PropertiesPtr& properties) } } #else -
-static IceUtil::StaticMutex tprintMutex = ICEE_STATIC_MUTEX_INITIALIZER;
-
+ +static IceUtil::StaticMutex tprintMutex = ICEE_STATIC_MUTEX_INITIALIZER; + void tprintf(const char* fmt, ...) { @@ -420,7 +413,7 @@ TestApplication::main(int ac, char* av[]) tprintf("std::exception: %s\n", ex.what()); status = EXIT_FAILURE; } - catch(const std::string& msg) + catch(const string& msg) { tprintf("std::string: %s\n", msg.c_str()); status = EXIT_FAILURE; @@ -482,12 +475,12 @@ void TestApplication::setCommunicator(const CommunicatorPtr& communicator) { _communicator = communicator; -#ifdef _WIN32_WCE
+#ifdef _WIN32_WCE if(communicator->getProperties()->getPropertyWithDefault("LogToFile", "0") != "0") { - _tprintfp = fopen(("log-" + _name + ".txt").c_str(), "w");
+ _tprintfp = fopen(("log-" + _name + ".txt").c_str(), "w"); } -#endif
+#endif _communicator->setLogger(new LoggerI); } |