Exemple #1
0
    def setUp(self):
        contract = barrister.Contract(parse(idl))
        self.user_svc = UserServiceImpl()
        self.server = barrister.Server(contract)
        self.server.add_handler("UserService", self.user_svc)

        transport = barrister.InProcTransport(self.server)
        self.client = barrister.Client(transport)
Exemple #2
0
#!/usr/bin/env python

import sys
import barrister
import codecs
import logging
try:
    import json
except:
    import simplejson as json

logging.basicConfig()
logging.getLogger("barrister").setLevel(logging.DEBUG)

trans = barrister.HttpTransport("http://localhost:9233/")
client = barrister.Client(trans, validate_request=False)
batch = None

f = open(sys.argv[1])
out = codecs.open(sys.argv[2], "w", "utf-8")


def get_and_log_result(iface, func, params, result, error):
    status = "ok"
    resp = result

    if error != None:
        status = "rpcerr"
        resp = error.code
        print "RPCERR: %s" % error.msg
Exemple #3
0
#!/usr/bin/env python

import barrister
import sys
import copy
import time

trans = barrister.HttpTransport("http://localhost:7667/content")
client = barrister.Client(trans)

#
# Test 1 - Try adding a page with incorrect types.  Note that server.py
#          has no type validation code.  Type enforcement is done
#          automatically by Barrister based on the IDL

invalid_add_page = [
    # use an int for authorId
    [1, "title", "body", "sports"],
    # pass a null title
    ["author-1", None, "body", "sports"],
    # pass a float for body
    ["author-1", "title", 32.3, "sports"],
    # pass a bool for category
    ["author-1", "title", "body", True],
    # pass an invalid enum value
    ["author-1", "title", "body", "op-ed"]
]

for page_data in invalid_add_page:
    try:
        client.ContentService.addPage(*page_data)
 def __init__(self, address):
     trans = barrister.HttpTransport(address)
     self.client = barrister.Client(trans)