def setUp(self):
        if hasattr(self, 'ipb_client'):
            yield HappySMSCTestCase.setUp(self, interceptorpb_client = self.ipb_client)
        else:
            yield HappySMSCTestCase.setUp(self)

        # Connect to RouterPB
        yield self.connect('127.0.0.1', self.pbPort)

        # Provision user, group, default mt route and
        # default mt interceptor
        self.g1 = Group(1)
        yield self.group_add(self.g1)

        self.c1 = SmppClientConnector(id_generator())
        self.mt_interceptor = MTInterceptorScript(self.script)
        self.u1_password = '******'
        self.u1 = User(1, self.g1, 'username', self.u1_password)
        self.u2_password = '******'
        self.u2 = User(1, self.g1, 'username2', self.u2_password)
        yield self.user_add(self.u1)

        yield self.mtroute_add(DefaultRoute(self.c1), 0)
        yield self.mtinterceptor_add(DefaultInterceptor(self.mt_interceptor), 0)

        # Now we'll create the connector
        yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort)
        c1Config = SMPPClientConfig(id=self.c1.cid, port = self.SMSCPort.getHost().port)
        yield self.SMPPClientManagerPBProxy.add(c1Config)

        # And start it !
        yield self.SMPPClientManagerPBProxy.start(self.c1.cid)

        # Get stats singletons
        self.stats_http = HttpAPIStatsCollector().get()
    def setUp(self):
        if hasattr(self, "ipb_client"):
            yield HappySMSCTestCase.setUp(self, interceptorpb_client=self.ipb_client)
        else:
            yield HappySMSCTestCase.setUp(self)

        # Connect to RouterPB
        yield self.connect("127.0.0.1", self.pbPort)

        # Provision user, group, default mt route and
        # default mt interceptor
        self.g1 = Group(1)
        yield self.group_add(self.g1)

        self.c1 = SmppClientConnector(id_generator())
        self.mt_interceptor = MTInterceptorScript(self.script)
        self.u1_password = "******"
        self.u1 = User(1, self.g1, "username", self.u1_password)
        self.u2_password = "******"
        self.u2 = User(1, self.g1, "username2", self.u2_password)
        yield self.user_add(self.u1)

        yield self.mtroute_add(DefaultRoute(self.c1), 0)
        yield self.mtinterceptor_add(DefaultInterceptor(self.mt_interceptor), 0)

        # Now we'll create the connector
        yield self.SMPPClientManagerPBProxy.connect("127.0.0.1", self.CManagerPort)
        c1Config = SMPPClientConfig(id=self.c1.cid, port=self.SMSCPort.getHost().port)
        yield self.SMPPClientManagerPBProxy.add(c1Config)

        # And start it !
        yield self.SMPPClientManagerPBProxy.start(self.c1.cid)

        # Get stats singletons
        self.stats_http = HttpAPIStatsCollector().get()
    def tearDown(self):
        # Stop smppc
        yield self.SMPPClientManagerPBProxy.stop(self.c1.cid)
        # Wait for 'BOUND_TRX' state
        while True:
            ssRet = yield self.SMPPClientManagerPBProxy.session_state(self.c1.cid)
            if ssRet == 'NONE' or ssRet == 'UNBOUND':
                break;
            else:
                yield waitFor(0.2)

        yield HappySMSCTestCase.tearDown(self)
    def tearDown(self):
        # Stop smppc
        yield self.SMPPClientManagerPBProxy.stop(self.c1.cid)
        # Wait for 'BOUND_TRX' state
        while True:
            ssRet = yield self.SMPPClientManagerPBProxy.session_state(self.c1.cid)
            if ssRet == "NONE" or ssRet == "UNBOUND":
                break
            else:
                yield waitFor(0.2)

        yield HappySMSCTestCase.tearDown(self)