TEST(OperationContextTest, SessionIdAndTransactionNumber) {
    auto serviceCtx = ServiceContext::make();
    auto client = serviceCtx->makeClient("OperationContextTest");
    auto opCtx = client->makeOperationContext();

    const auto lsid = makeLogicalSessionIdForTest();
    opCtx->setLogicalSessionId(lsid);
    opCtx->setTxnNumber(5);

    ASSERT(opCtx->getTxnNumber());
    ASSERT_EQUALS(5, *opCtx->getTxnNumber());
}
示例#2
0
/*===========================================================================
  External MidiShare functions implementation
  =========================================================================== */		
MSFunctionType(short) MSOpen (MidiName name, TMSGlobalPtr g)
{
	TApplPtr appl, drv;
	TClientsPtr clients = Clients(g);
	short ref = MIDIerrSpace;

	msOpenMutex (kOpenCloseMutex);
    if (clients->nbAppls == 0) {
		drv  = NewAppl (sizeof(TAppl) + sizeof(TDriver));
		if (drv) {
			TDriverInfos infos;
			setName (infos.name, kMidiShareName);
			infos.version = MSGetVersion (g);
		    makeDriver(clients, drv, MidiShareDriverRef, &infos, 0);
			Clients(g)->nbDrivers++;
		}
		MidiShareWakeup(g);
		appl = NewAppl (sizeof(TAppl));
		if (appl) {
		    makeClient(clients, appl, MidiShareRef, kMidiShareName, kClientFolder);
			Clients(g)->nbAppls++;
		}
	}
	if (CheckClientsCount(clients)) {
		appl = NewAppl (sizeof(TAppl));
		if (appl) {
			for (ref = 1; clients->appls[ref]; ref++)
				;
			makeClient(clients, appl, ref, name, kClientFolder);
			Clients(g)->nbAppls++;
			CallAlarm (ref, MIDIOpenAppl, clients);
		}
	}
	msCloseMutex (kOpenCloseMutex);
	return ref;
}
    virtual void run(Message& request, MessageResponder* out) {

        // Deserialize the command line arguments.
        wchar_t* cmd_line;
        request.cast(&cmd_line, 0);
        int argc = 0;
        wchar_t** argv = CommandLineToArgvW(cmd_line, &argc);

        // The only argument is the URL to open.
        if (argc == 1) {
            // TODO: Really important to check that the argument is actually a URL!!!
	        RPCClient* client = makeClient();
            Request* request = client->initiate("openurl", (wcslen(cmd_line) + 1) * sizeof(wchar_t));
            request->send(cmd_line);
            request->finish(false, 60);
            DWORD r = 0;
            out->run(sizeof r, &r);
        } else {
            out->run(0, NULL);
        }
    }
TEST(OperationContextTest, SessionIdAndTransactionNumber) {
    auto serviceCtx = ServiceContext::make();
    auto client = serviceCtx->makeClient("OperationContextTest");
    auto opCtx = client->makeOperationContext();

    const auto lsid = makeLogicalSessionIdForTest();
    opCtx->setLogicalSessionId(lsid);
    opCtx->setTxnNumber(5);

    ASSERT(opCtx->getTxnNumber());
    ASSERT_EQUALS(5, *opCtx->getTxnNumber());
}

DEATH_TEST(OperationContextTest, SettingTransactionNumberWithoutSessionIdShouldCrash, "invariant") {
    auto serviceCtx = ServiceContext::make();
    auto client = serviceCtx->makeClient("OperationContextTest");
    auto opCtx = client->makeOperationContext();

    opCtx->setTxnNumber(5);
}

DEATH_TEST(OperationContextTest, CallingMarkKillWithExtraInfoCrashes, "invariant") {
    auto serviceCtx = ServiceContext::make();
    auto client = serviceCtx->makeClient("OperationContextTest");
    auto opCtx = client->makeOperationContext();

    opCtx->markKilled(ErrorCodes::ForTestingErrorExtraInfo);
}

DEATH_TEST(OperationContextTest, CallingSetDeadlineWithExtraInfoCrashes, "invariant") {
    auto serviceCtx = ServiceContext::make();