示例#1
0
def testHttps():
    srv = TestSecureServer()
    srv.setDaemon(True)
    srv.start()
    
    sleep(1) # wait until server starts
    while not srv.online:
        sleep(1)
    
    proxy = HessianProxy("https://localhost:" + `TEST_PORT`)
    assert proxy.echo("hello") == "hello"
示例#2
0
def callTestPublic(url):
    try:
        proxy = HessianProxy(url)

        proxy.nullCall()
        # In the next moment nothing continued to happen.

        assert "Hello, world" == proxy.hello()
        print '.',

        o = {1: "one", 2: "two"}
        assert o == proxy.echo(o)
        print '.',

        o = (-1, -2)
        assert list(o) == proxy.echo(o)
        print '.',

        o = ["S-word", "happen-s"]
        assert o == proxy.echo(o)
        print '.',

        a, b = 1902, 34
        assert (a - b) == proxy.subtract(a, b)
        print '.',

        # What about UTF-8?
        padonkRussianMessage = u"Превед!"
        assert padonkRussianMessage == proxy.echo(padonkRussianMessage)
        print '.',

    except Exception as e:
        st = traceback.format_exc()
        if not warnConnectionRefused(e, url):
            print st
            raise e  # re-thow
示例#3
0
def callTestLocal(url):
    srv = TestServer()
    srv.setDaemon(True)
    srv.start()
    # Due to some reason server does not accept connections right after it's started.
    sleep(0.5)

    proxy = HessianProxy(url)

    msg = proxy.nothing()
    assert None == msg

    msg = proxy.hello()
    assert SECRET_MESSAGE == msg

    try:
        proxy.askBitchy()
        assert False  # should not get here
    except Exception as e:
        assert "Go away!" == e.testMessage

    # What about UTF-8?
    padonkMessage = u"Пррревед обонентеги!"
    assert padonkMessage == proxy.echo(padonkMessage)

    callBlobTest(proxy)
    redirectTest(proxy)

    if True:
        from time import time
        print "Some performance measurements..."
        count = 1000
        start = time()
        for _ in range(count):
            proxy.hello()
        fin = time()
        print "One call takes", 1000.0 * (fin - start) / count, "mSec."

    srv.stop()
示例#4
0
def callTestPublic(url):
    try:
        proxy = HessianProxy(url)
        
        proxy.nullCall()
        # In the next moment nothing continued to happen.
        
        assert "Hello, world" == proxy.hello()
        print '.',
        
        o = {1:"one", 2:"two"}
        assert o == proxy.echo(o)
        print '.',
        
        o = (-1, -2)
        assert list(o) == proxy.echo(o)
        print '.',
        
        o = ["S-word", "happen-s"]
        assert o == proxy.echo(o)
        print '.',
        
        a, b = 1902, 34
        assert (a - b) == proxy.subtract(a, b)
        print '.',
        
        # What about UTF-8?
        padonkRussianMessage = u"Превед!"
        assert padonkRussianMessage == proxy.echo(padonkRussianMessage)
        print '.',
                                                                                  
    except Exception as e:
        st = traceback.format_exc()
        if not warnConnectionRefused(e, url):
            print st
            raise e # re-thow
示例#5
0
def callTestLocal(url):
    srv = TestServer()
    srv.setDaemon(True)
    srv.start()
    # Due to some reason server does not accept connections right after it's started.
    sleep(0.5) 
    
    proxy = HessianProxy(url)
        
    msg = proxy.nothing()
    assert None == msg
      
    msg = proxy.hello()
    assert SECRET_MESSAGE == msg
    
    try:
        proxy.askBitchy()
        assert False # should not get here
    except Exception as e:
        assert "Go away!" == e.testMessage 
    
    # What about UTF-8?
    padonkMessage = u"Пррревед обонентеги!"
    assert padonkMessage == proxy.echo(padonkMessage)
    
    callBlobTest(proxy)
    redirectTest(proxy)
    
    if True:
        from time import time 
        print "Some performance measurements..."
        count = 1000
        start = time()
        for _ in range(count):
            proxy.hello()
        fin = time()
        print "One call takes", 1000.0 * (fin - start) / count, "mSec."        

    srv.stop()
示例#6
0
def call_api(method, params={}, args=[]):
    url = _API_PATH + urllib.urlencode(params)
    hp = HessianProxy(url)
    ret = hp(method, args)
    return ret