本文整理汇总了C++中TestRunner::passIfNoException方法的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner::passIfNoException方法的具体用法?C++ TestRunner::passIfNoException怎么用?C++ TestRunner::passIfNoException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRunner
的用法示例。
在下文中一共展示了TestRunner::passIfNoException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contributorGetTest
static void contributorGetTest(Node& node, TestRunner& tr)
{
tr.group("contributors");
Messenger* messenger = node.getMessenger();
tr.test("id");
{
Url url("/api/3.0/contributors/1");
// get contributor
DynamicObject contributor;
assertNoException(
messenger->getFromBitmunk(&url, contributor));
printf("\nContributor:\n");
dumpDynamicObject(contributor, false);
}
tr.passIfNoException();
tr.test("owner");
{
Url url("/api/3.0/contributors/?owner=900");
// get contributor
DynamicObject contributors;
assertNoException(
messenger->getFromBitmunk(&url, contributors));
printf("\nContributors:\n");
dumpDynamicObject(contributors, false);
}
tr.passIfNoException();
tr.test("media");
{
Url url("/api/3.0/contributors/?media=1");
// get contributor
DynamicObject contributors;
assertNoException(
messenger->getFromBitmunk(&url, contributors));
printf("\nContributors:\n");
dumpDynamicObject(contributors, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例2: runFiberYieldTest
static void runFiberYieldTest(TestRunner& tr)
{
tr.group("Fiber Yield");
tr.test("10 yielding fibers/10 iterations");
{
Kernel k;
k.getEngine()->start();
FiberScheduler fs;
// queue up some fibers prior to starting
for(int i = 0; i < 10; ++i)
{
fs.addFiber(new TestFiber(10));
}
uint64_t startTime = Timer::startTiming();
fs.start(&k, 1);
fs.waitForLastFiberExit(true);
printf("time=%g secs... ", Timer::getSeconds(startTime));
k.getEngine()->stop();
}
tr.passIfNoException();
tr.ungroup();
}
示例3: userAddTest
static void userAddTest(Node& node, TestRunner& tr)
{
tr.group("user add");
Messenger* messenger = node.getMessenger();
tr.test("add (valid)");
{
Url url("/api/3.0/users");
// password update
User user;
user["email"] = "[email protected]";
user["username"] = "testuser1";
user["password"] = "password";
user["confirm"] = "password";
user["tosAgree"] = "agree";
assertNoException(
messenger->postSecureToBitmunk(
&url, &user, NULL, node.getDefaultUserId()));
printf("\nUser added.\n");
}
tr.passIfNoException();
tr.ungroup();
}
示例4: runHttpServerTest
static void runHttpServerTest(TestRunner& tr)
{
tr.test("Http Server");
// create kernel
Kernel k;
// set thread stack size in engine (128k)
k.getEngine()->getThreadPool()->setThreadStackSize(131072);
// optional for testing --
// limit threads to 2: one for accepting, 1 for handling
//k.getEngine()->getThreadPool()->setPoolSize(2);
// start engine
k.getEngine()->start();
// create server
Server server;
InternetAddress address("0.0.0.0", 19100);
// create SSL/generic http connection servicer
HttpConnectionServicer hcs;
// SslContext context;
// SslSocketDataPresenter presenter1(&context);
// NullSocketDataPresenter presenter2;
// SocketDataPresenterList list(false);
// list.add(&presenter1);
// list.add(&presenter2);
server.addConnectionService(&address, &hcs);//, &list);
// create test http request servicer
TestHttpRequestServicer test1("/test");
hcs.addRequestServicer(&test1, false);
uint64_t seconds = 30;
if(server.start(&k))
{
printf("\nServer started on %s and will run for %" PRIu64 " seconds.\n",
address.toString(false).c_str(), seconds);
}
else if(Exception::get() != NULL)
{
printf("\nServer start failed with errors=%s\n",
Exception::get()->getMessage());
}
// sleep
Thread::sleep(seconds * 1000);
server.stop();
printf("Server stopped.\n");
// stop kernel engine
k.getEngine()->stop();
tr.passIfNoException();
}
示例5: pingPerfTest
static void pingPerfTest(Node& node, TestRunner& tr)
{
tr.group("ping perf");
Messenger* messenger = node.getMessenger();
// number of loops for each test
Config cfg = tr.getApp()->getConfig();
//node.getConfigManager()->getConfig(
// tester->getApp()->getMetaConfig()["groups"]["main"]->getString());
int n = cfg->hasMember("loops") ? cfg["loops"]->getInt32() : 50;
tr.test("insecure get");
{
Url url("/api/3.0/system/test/ping");
DynamicObject dummy;
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
messenger->getFromBitmunk(&url, dummy);
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.test("secure get");
{
Url url("/api/3.0/system/test/ping");
DynamicObject dummy;
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
messenger->getSecureFromBitmunk(&url, dummy, node.getDefaultUserId());
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.ungroup();
}
示例6: runHttpClientPostTest
static void runHttpClientPostTest(TestRunner& tr)
{
tr.test("Http Client POST");
// create client
HttpClient client;
// connect
Url url("http://www.bitmunk.com");
if(client.connect(&url))
{
printf("Connected to: %s\n", url.toString().c_str());
InternetAddress address(url.getHost().c_str(), url.getPort());
printf("%s\n", address.toString().c_str());
char someData[] = "Just some post data.";
ByteArrayInputStream baos(someData, strlen(someData));
// do post
DynamicObject headers;
headers["Content-Type"] = "text/plain";
headers["Transfer-Encoding"] = "chunked";
HttpTrailer trailer;
HttpResponse* response = client.post(&url, &headers, &baos, &trailer);
if(response != NULL)
{
printf("Response=\n%s\n",
response->getHeader()->toString().c_str());
if(response->getHeader()->getStatusCode() == 200)
{
// receive content
trailer.clearFields();
File file("/tmp/postresponse.txt");
FileOutputStream fos(file);
if(client.receiveContent(&fos, &trailer))
{
printf("Content downloaded to '%s'\n",
file->getAbsolutePath());
printf("HTTP trailers=\n%s\n", trailer.toString().c_str());
}
assertNoExceptionSet();
}
}
else
{
printf("There was no response!\n");
}
client.disconnect();
}
tr.passIfNoException();
}
示例7: accountGetPerfTest
static void accountGetPerfTest(Node& node, TestRunner& tr)
{
tr.group("accounts perf");
Messenger* messenger = node.getMessenger();
// number of loops
int n = 25;
tr.test("insecure get");
{
Url url("/api/3.0/accounts/?owner=900");
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
User user;
messenger->getFromBitmunk(&url, user);
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.test("secure get");
{
Url url("/api/3.0/accounts/?owner=900");
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
User user;
messenger->getFromBitmunk(&url, user, node.getDefaultUserId());
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.ungroup();
}
示例8: accountGetTest
static void accountGetTest(Node& node, TestRunner& tr)
{
tr.group("accounts");
Messenger* messenger = node.getMessenger();
tr.test("get");
{
Url url("/api/3.0/accounts/?owner=900");
// get all accounts
User user;
messenger->getSecureFromBitmunk(&url, user, node.getDefaultUserId());
printf("\nAccounts:\n");
dumpDynamicObject(user);
}
tr.passIfNoException();
tr.ungroup();
tr.group("account");
tr.test("get");
{
// create url for obtaining users
Url url("/api/3.0/accounts/9000");
// get account
Account account;
assertNoException(
messenger->getSecureFromBitmunk(
&url, account, node.getDefaultUserId()));
printf("\nAccount:\n");
dumpDynamicObject(account, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例9: reviewGetTest
static void reviewGetTest(Node& node, TestRunner& tr)
{
tr.group("reviews");
Messenger* messenger = node.getMessenger();
tr.test("user get");
{
// create url for obtaining user reviews
Url url("/api/3.0/reviews/user/900");
// get account
DynamicObject reviews;
assertNoException(
messenger->getSecureFromBitmunk(
&url, reviews, node.getDefaultUserId()));
printf("\nReviews:\n");
dumpDynamicObject(reviews, false);
}
tr.passIfNoException();
tr.test("media get");
{
// create url for obtaining media reviews
Url url("/api/3.0/reviews/media/1");
// get account
DynamicObject reviews;
assertNoException(
messenger->getSecureFromBitmunk(
&url, reviews, node.getDefaultUserId()));
printf("\nReviews:\n");
dumpDynamicObject(reviews, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例10: while
static void runDynoIterTest1(
TestRunner& tr, const char* name, int dynos, int iter)
{
tr.test(name);
{
uint64_t start_init = System::getCurrentMilliseconds();
DynamicObject d1;
d1->setType(Array);
for(int i = 0; i < dynos; ++i)
{
d1->append(i);
//d1[i] = i;
}
uint64_t start_iter = System::getCurrentMilliseconds();
for(int j = 0; j < iter; ++j)
{
DynamicObjectIterator i = d1.getIterator();
while(i->hasNext())
{
i->next();
}
}
uint64_t iter_dt = System::getCurrentMilliseconds() - start_iter;
uint64_t init_dt = start_iter - start_init;
if(header)
{
printf(
"%9s %9s "
"%8s %9s "
"%8s %10s %9s "
"%9s\n",
"dynos", "iter",
"init (s)", "d/ms",
"iter (s)", "i/s", "(d*i)/ms",
"total (s)");
header = false;
}
printf(
"%9d %9d "
"%8.3f %9.3f "
"%8.3f %10.3f %9.3f "
"%9.3f\n",
dynos, iter,
init_dt/1000.0, dynos/(double)init_dt,
iter_dt/1000.0, iter/(iter_dt/1000.0), (dynos*iter)/(double)iter_dt,
(init_dt + iter_dt)/1000.0);
}
tr.passIfNoException();
}
示例11: runHttpClientGetTest
static void runHttpClientGetTest(TestRunner& tr)
{
tr.test("Http Client GET");
// create client
HttpClient client;
// connect
Url url("http://www.bitmunk.com");
if(client.connect(&url))
{
printf("Connected to: %s\n", url.toString().c_str());
InternetAddress address(url.getHost().c_str(), url.getPort());
printf("%s\n", address.toString().c_str());
// do get
DynamicObject headers;
headers["Test-Header"] = "bacon";
HttpResponse* response = client.get(&url, &headers);
if(response != NULL)
{
printf("Response=\n%s\n", response->getHeader()->toString().c_str());
if(response->getHeader()->getStatusCode() == 200)
{
// receive content
HttpTrailer trailer;
File file("/tmp/index.html");
FileOutputStream fos(file);
if(client.receiveContent(&fos, &trailer))
{
printf("Content downloaded to '%s'\n",
file->getAbsolutePath());
printf("HTTP trailers=\n%s\n", trailer.toString().c_str());
}
assertNoExceptionSet();
}
}
else
{
printf("There was no response!\n");
}
client.disconnect();
}
tr.passIfNoException();
}
示例12: runConfigTest
static void runConfigTest(Node& node, TestRunner& tr)
{
tr.group("config");
tr.test("user configs");
{
/*{
printf("config debug:\n");
Config c = node.getConfigManager()->getDebugInfo();
JsonWriter::writeToStdOut(c, false, false);
assertNoException();
}*/
UserId userId;
bool loggedin = node.login("devuser", "password", &userId);
assertNoExceptionSet();
assert(loggedin);
{
Config c = node.getConfigManager()->getUserConfig(userId, true);
assert(!c.isNull());
if(tr.getVerbosityLevel() > 1)
{
printf("raw user %" PRIu64 " config:\n", userId);
JsonWriter::writeToStdOut(c, false, false);
assertNoExceptionSet();
}
}
{
Config c = node.getConfigManager()->getUserConfig(userId);
assert(!c.isNull());
if(tr.getVerbosityLevel() > 1)
{
printf("user %" PRIu64 " config:\n", userId);
JsonWriter::writeToStdOut(c, false, false);
assertNoExceptionSet();
}
}
node.logout(userId);
assertNoExceptionSet();
}
tr.passIfNoException();
tr.ungroup();
}
示例13: permissionGetTest
static void permissionGetTest(Node& node, TestRunner& tr)
{
tr.group("permissions");
Messenger* messenger = node.getMessenger();
tr.test("group get");
{
// create url for obtaining permission group information
Url url("/api/3.0/permissions/100");
// get permission group
PermissionGroup group;
assertNoException(
messenger->getFromBitmunk(&url, group));
printf("\nGroup:\n");
dumpDynamicObject(group, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例14: acquireLicenseTest
static void acquireLicenseTest(Node& node, TestRunner& tr)
{
tr.group("media license");
Messenger* messenger = node.getMessenger();
tr.test("acquire signed media");
{
// create url for obtaining media license
Url url("/api/3.0/sva/contracts/media/2");
// get signed media
Media media;
assertNoException(
messenger->postSecureToBitmunk(
&url, NULL, &media, node.getDefaultUserId()));
printf("\nSigned Media:\n");
dumpDynamicObject(media, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例15: runPingTest
static void runPingTest(TestRunner& tr)
{
tr.test("Ping");
// create kernel
Kernel k;
k.getEngine()->start();
// create server
Server server;
InternetAddress address("localhost", 19100);
// // create SSL/generic ping connection servicer
// PingConnectionServicer pcs;
//// SslContext context;
//// SslSocketDataPresenter presenter1(&context);
//// NullSocketDataPresenter presenter2;
//// SocketDataPresenterList list(false);
//// list.add(&presenter1);
//// list.add(&presenter2);
// server.addConnectionService(&address, &pcs);//, &list);
// create SSL/generic http connection servicer
HttpConnectionServicer hcs;
// SslContext context;
// SslSocketDataPresenter presenter1(&context);
// NullSocketDataPresenter presenter2;
// SocketDataPresenterList list(false);
// list.add(&presenter1);
// list.add(&presenter2);
server.addConnectionService(&address, &hcs);//, &list);
// create test http request servicer
PingHttpRequestServicer test1("/test");
hcs.addRequestServicer(&test1, false);
if(server.start(&k))
{
printf("Server started.\n");
}
else if(Exception::get() != NULL)
{
printf("Server started with errors=%s\n",
Exception::get()->getMessage());
}
// connect
Url url("http://localhost:19100");
HttpTrailer trailer;
File file("/tmp/index.html");
FileOutputStream fos(file);
HttpClient client;
uint64_t start = System::getCurrentMilliseconds();
client.connect(&url);
client.get(&url, NULL);
client.receiveContent(&fos, &trailer);
uint64_t end = System::getCurrentMilliseconds();
client.disconnect();
// sleep
//Thread::sleep(10000);
server.stop();
printf("Server stopped.\n");
// stop kernel engine
k.getEngine()->stop();
uint64_t millis = end - start;
printf("Connection Time: %" PRIu64 "\n", millis);
// uint64_t millis = test1.end - test1.start;
// double cps = ((double)pcs.serviced) / millis * 1000.0;
// printf("Connections serviced: %d\n", pcs.serviced);
// printf("Time: %" PRIu64 "\n", millis);
// printf("Connections/Second: %f\n", cps);
tr.passIfNoException();
}