Exemple #1
0
int
Client::run(int, char*[])
{
    Test::MyObjectPrxPtr proxy =
        ICE_UNCHECKED_CAST(Test::MyObjectPrx,
                           communicator()->stringToProxy("test:" + getTestEndpoint(communicator(), 0)));

    char oe = char(0xBD); // A single character in ISO Latin 9
    string msg = string("tu me fends le c") + oe + "ur!";
    cout << "testing string converter";
    if(useLocale)
    {
        cout << " (using locale)";
    }
    if(useIconv)
    {
        cout << " (using iconv)";
    }
    cout << "... " << flush;
    wstring wmsg = proxy->widen(msg);
    test(proxy->narrow(wmsg) == msg);
    test(wmsg.size() == msg.size());
    cout << "ok" << endl;
    proxy->shutdown();
    return EXIT_SUCCESS;
}
Exemple #2
0
int
ClientApp::run(int, char*[])
{

#ifndef _WIN32
//
// Check SIGPIPE is now SIG_IGN
//
    struct sigaction action;
    sigaction(SIGPIPE, 0, &action);
    test(action.sa_handler == SIG_IGN);
#endif

    //
    // Create OA and servants
    //
    Ice::ObjectAdapterPtr oa = communicator()->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");

    Ice::ObjectPtr servant = ICE_MAKE_SHARED(MyObjectI);
    InterceptorIPtr interceptor = ICE_MAKE_SHARED(InterceptorI, servant);
    AMDInterceptorIPtr amdInterceptor = ICE_MAKE_SHARED(AMDInterceptorI, servant);

    Test::MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(Test::MyObjectPrx, oa->addWithUUID(interceptor));
    Test::MyObjectPrxPtr prxForAMD = ICE_UNCHECKED_CAST(Test::MyObjectPrx, oa->addWithUUID(amdInterceptor));

    cout << "Collocation optimization on" << endl;
    int rs = run(prx, interceptor);
    if(rs != 0)
    {
        return rs;
    }

    cout << "Now with AMD" << endl;
    rs = runAmd(prxForAMD, amdInterceptor);
    if(rs != 0)
    {
        return rs;
    }

    oa->activate(); // Only necessary for non-collocation optimized tests

    cout << "Collocation optimization off" << endl;
    interceptor->clear();
    prx = ICE_UNCHECKED_CAST(Test::MyObjectPrx, prx->ice_collocationOptimized(false));
    rs = run(prx, interceptor);
    if(rs != 0)
    {
        return rs;
    }

    cout << "Now with AMD" << endl;
    amdInterceptor->clear();
    prxForAMD = ICE_UNCHECKED_CAST(Test::MyObjectPrx, prxForAMD->ice_collocationOptimized(false));
    rs = runAmd(prxForAMD, amdInterceptor);

    return rs;
}
Exemple #3
0
int
main(int argc, char* argv[])
{
#ifdef ICE_STATIC_LIBS
    Ice::registerIceSSL();
#endif

    Ice::InitializationData initData;
    initData.properties = Ice::createProperties(argc, argv);

    string narrowEncoding;
    string wideEncoding;

#ifdef _WIN32
    useIconv = false;
#else
    //
    // Switch to French locale
    // (we just used the codeset for as default internal code for
    // stringConverter below)
    //
    useLocale = (setlocale(LC_ALL, "fr_FR.ISO8859-15") != 0 || setlocale(LC_ALL, "fr_FR.iso885915@euro") != 0);
#endif

    if(useIconv)
    {

#if defined(__hpux)
        narrowEncoding = "iso815";
        wideEncoding = "ucs4";

#elif defined(_AIX)

        // Always big-endian
        narrowEncoding = "ISO8859-15";

        if(sizeof(wchar_t) == 4)
        {
            wideEncoding = "UTF-32";
        }
        else
        {
            wideEncoding = "UTF-16";
        }
#else

        narrowEncoding = "ISO8859-15";

        if(sizeof(wchar_t) == 4)
        {
#  ifdef ICE_BIG_ENDIAN
            wideEncoding = "UTF-32BE";
#  else
            wideEncoding = "UTF-32LE";
#  endif
        }
        else
        {
#  ifdef ICE_BIG_ENDIAN
            wideEncoding = "UTF-16BE";
#  else
            wideEncoding = "UTF-16LE";
#  endif
        }
#endif
    }

    {
#ifdef _WIN32
        //
        // 28605 == ISO 8859-15 codepage
        //
        setProcessStringConverter(Ice::createWindowsStringConverter(28605));
#else
        if(useLocale)
        {
            setProcessStringConverter(Ice::createIconvStringConverter<char>(""));
        }
        else
        {
            setProcessStringConverter(Ice::createIconvStringConverter<char>(narrowEncoding));
        }

        setProcessWstringConverter(Ice::createIconvStringConverter<wchar_t>(wideEncoding));

#endif

        Ice::CommunicatorPtr communicator = Ice::initialize(initData);
        Test::MyObjectPrxPtr proxy =
            ICE_UNCHECKED_CAST(Test::MyObjectPrx,
                               communicator->stringToProxy("test:" + getTestEndpoint(communicator, 0)));

        char oe = char(0xBD); // A single character in ISO Latin 9
        string msg = string("tu me fends le c") + oe + "ur!";
        cout << "testing string converter";
        if(useLocale)
        {
            cout << " (using locale)";
        }
        if(useIconv)
        {
            cout << " (using iconv)";
        }
        cout << "... " << flush;
        wstring wmsg = proxy->widen(msg);
        test(proxy->narrow(wmsg) == msg);
        test(wmsg.size() == msg.size());
        communicator->destroy();
        cout << "ok" << endl;
    }

    Ice::setProcessStringConverter(ICE_NULLPTR);
    Ice::setProcessWstringConverter(Ice::createUnicodeWstringConverter());


    string propValue = "Ice:createStringConverter";
    if(useIconv && !useLocale)
    {
        propValue +=  " iconv=" + narrowEncoding + "," + wideEncoding;
    }
    propValue += " windows=28605";

    initData.properties->setProperty("Ice.Plugin.IceStringConverter", propValue);

    Ice::CommunicatorPtr communicator = Ice::initialize(initData);
    Test::MyObjectPrxPtr proxy =
        ICE_UNCHECKED_CAST(Test::MyObjectPrx,
                           communicator->stringToProxy("test:" + getTestEndpoint(communicator, 0)));

    char oe = char(0xBD); // A single character in ISO Latin 9
    string msg = string("tu me fends le c") + oe + "ur!";
    cout << "testing string converter plug-in";
    if(useLocale)
    {
        cout << " (using locale)";
    }
    if(useIconv)
    {
        cout << " (using iconv)";
    }
    cout << "... " << flush;
    wstring wmsg = proxy->widen(msg);
    test(proxy->narrow(wmsg) == msg);
    test(wmsg.size() == msg.size());
    cout << "ok" << endl;

    proxy->shutdown();
    communicator->destroy();

    return EXIT_SUCCESS;
}
Exemple #4
0
int
ClientApp::runAmd(const Test::MyObjectPrxPtr& prx, const AMDInterceptorIPtr& interceptor)
{
    cout << "testing simple interceptor... " << flush;
    test(interceptor->getLastOperation().empty());
    test(prx->amdAdd(33, 12) == 45);
    test(interceptor->getLastOperation() == "amdAdd");
    test(!interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing retry... " << flush;
    test(prx->amdAddWithRetry(33, 12) == 45);
    test(interceptor->getLastOperation() == "amdAddWithRetry");
    test(!interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing user exception... " << flush;
    try
    {
        prx->amdBadAdd(33, 12);
        test(false);
    }
    catch(const Test::InvalidInputException&)
    {
        // expected
    }
    test(interceptor->getLastOperation() == "amdBadAdd");
    test(!interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing ONE... " << flush;
    interceptor->clear();
    try
    {
        prx->amdNotExistAdd(33, 12);
        test(false);
    }
    catch(const Ice::ObjectNotExistException&)
    {
        // expected
    }
    test(interceptor->getLastOperation() == "amdNotExistAdd");
    test(!interceptor->getLastStatus());

    test(dynamic_cast<Ice::ObjectNotExistException*>(interceptor->getException()) != 0);

    cout << "ok" << endl;
    cout << "testing system exception... " << flush;
    interceptor->clear();
    try
    {
        prx->amdBadSystemAdd(33, 12);
        test(false);
    }
    catch(const Ice::UnknownException&)
    {
        test(!prx->ice_isCollocationOptimized());
    }
    catch(const MySystemException&)
    {
        test(prx->ice_isCollocationOptimized());
    }
    test(interceptor->getLastOperation() == "amdBadSystemAdd");
    test(!interceptor->getLastStatus());
    test(dynamic_cast<MySystemException*>(interceptor->getException()) != 0);
    cout << "ok" << endl;
    return EXIT_SUCCESS;
}
Exemple #5
0
int
ClientApp::run(const Test::MyObjectPrxPtr& prx, const InterceptorIPtr& interceptor)
{
    cout << "testing simple interceptor... " << flush;
    test(interceptor->getLastOperation().empty());
    prx->ice_ping();
    test(interceptor->getLastOperation() == "ice_ping");
    test(interceptor->getLastStatus());
    string typeId = prx->ice_id();
    test(interceptor->getLastOperation() == "ice_id");
    test(interceptor->getLastStatus());
    test(prx->ice_isA(typeId));
    test(interceptor->getLastOperation() == "ice_isA");
    test(interceptor->getLastStatus());
    test(prx->add(33, 12) == 45);
    test(interceptor->getLastOperation() == "add");
    test(interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing retry... " << flush;
    test(prx->addWithRetry(33, 12) == 45);
    test(interceptor->getLastOperation() == "addWithRetry");
    test(interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing user exception... " << flush;
    try
    {
        prx->badAdd(33, 12);
        test(false);
    }
    catch(const Test::InvalidInputException&)
    {
        // expected
    }
    test(interceptor->getLastOperation() == "badAdd");
    test(interceptor->getLastStatus());
    cout << "ok" << endl;
    cout << "testing ONE... " << flush;

    interceptor->clear();
    try
    {
        prx->notExistAdd(33, 12);
        test(false);
    }
    catch(const Ice::ObjectNotExistException&)
    {
        // expected
    }
    test(interceptor->getLastOperation() == "notExistAdd");
    cout << "ok" << endl;
    cout << "testing system exception... " << flush;
    interceptor->clear();
    try
    {
        prx->badSystemAdd(33, 12);
        test(false);
    }
    catch(const Ice::UnknownException&)
    {
        test(!prx->ice_isCollocationOptimized());
    }
    catch(const MySystemException&)
    {
        test(prx->ice_isCollocationOptimized());
    }
    catch(...)
    {
        test(false);
    }
    test(interceptor->getLastOperation() == "badSystemAdd");
    cout << "ok" << endl;

    cout << "testing simple AMD... " << flush;
    test(prx->amdAdd(33, 12) == 45);
    test(interceptor->getLastOperation() == "amdAdd");
    test(!interceptor->getLastStatus());
    cout << "ok" << endl;

    return EXIT_SUCCESS;
}