Пример #1
0
 /**
  * Runs the stress test.
  *
  * @param clients number of clients
  * @throws Exception exception
  */
 private void run(final int clients) throws Exception {
   // run server instance
   server = createServer();
   // run clients
   final Client[] cl = new Client[clients];
   for (int i = 0; i < clients; ++i) cl[i] = new Client();
   for (final Client c : cl) c.start();
   for (final Client c : cl) c.join();
   // stop server
   stopServer(server);
 }
Пример #2
0
  /**
   * Runs the stress test.
   *
   * @param clients number of clients
   * @param runs number of runs per client
   * @throws Exception exception
   */
  private static void run(final int clients, final int runs) throws Exception {
    // Create test database
    Command cmd = new CreateDB(NAME, INPUT);
    cmd.execute(context);

    // Start clients
    final Client[] cl = new Client[clients];
    for (int i = 0; i < clients; ++i) cl[i] = new Client(runs);
    for (final Client c : cl) c.start();
    for (final Client c : cl) c.join();
    // Drop database
    cmd = new DropDB(NAME);
    cmd.execute(context);
  }
Пример #3
0
 /**
  * Runs the stress test.
  *
  * @param clients number of clients
  * @param runs number of runs per client
  * @throws Exception exception
  */
 private void run(final int clients, final int runs) throws Exception {
   // run server instance
   server = createServer();
   // create test database
   try (final ClientSession cs = createClient()) {
     cs.execute("create db test <test/>");
     // run clients
     final Client[] cl = new Client[clients];
     for (int i = 0; i < clients; ++i) cl[i] = new Client(runs, i % 2 == 0);
     for (final Client c : cl) c.start();
     for (final Client c : cl) c.join();
     // drop database and stop server
     cs.execute("drop db test");
   }
   stopServer(server);
 }
  @Test
  public void testExampleJson() throws Exception {
    String json = FileUtil.readFileFromClasspath("json-examples/client-updated-example.json");
    JsonMessage jsonMessage = new JsonMessage(json);
    ServiceResult serviceResult = new ServiceResult();
    serviceResult.setRawData(jsonMessage);

    ServiceResult transformedServiceResult =
        (ServiceResult) transformer.doTransform(serviceResult, "UTF-8");
    ClientUpdated clientUpdated =
        (ClientUpdated) transformedServiceResult.getIntegrationMessage().getDomainObject();

    MetaData metaData = clientUpdated.getMetaData();

    collector.checkThat(metaData.getMessageType(), is("UpdateClient"));
    collector.checkThat(
        metaData.getMessageId().getGuid(), is("54d7887f-481a-62f6-5b41-3f33f46ec478"));
    collector.checkThat(
        metaData.getCreationTime().getTimestamp(), is("2012-07-07T12:52:20.000+02:00"));
    collector.checkThat(metaData.getVersion(), is("1.0"));
    collector.checkThat(metaData.getSourceSystem(), is("CRM"));

    Client client = clientUpdated.getClient();

    collector.checkThat(client.getClientId(), is("Cl42824050"));
    collector.checkThat(client.getBusinessFormCode(), is(""));
    collector.checkThat(client.getCompanyRegistrationNumber(), is("556284-2319"));
    collector.checkThat(client.getInvoiceLanguage().getLanguageCode(), is("SV"));
    collector.checkThat(client.getRegisteredCompanyName(), is("Kentor IT AB"));
    collector.checkThat(client.getVatNumber(), is("SE556284231901"));
    collector.checkThat(client.getClientType(), is(ClientType.ADVERTISER));

    List<Bank> bankAccounts = client.getBankAccounts();
    collector.checkThat(bankAccounts.size(), is(1));
    Bank bank = bankAccounts.get(0);

    collector.checkThat(bank.getAccountOwner(), is("Account Owner Example"));
    collector.checkThat(bank.getBankAccount(), is("4242424242"));
    collector.checkThat(bank.getBankCode(), is("SWEDSESS"));
    collector.checkThat(bank.getClientId(), is("Cl42824050"));
    collector.checkThat(bank.getMarketId().getOrganizationId(), is(51));

    List<ClientMessageRule> invoiceMessageRules = client.getInvoiceMessageRules();
    collector.checkThat(invoiceMessageRules.size(), is(1));
    ClientMessageRule clientMessageRule = invoiceMessageRules.get(0);

    collector.checkThat(clientMessageRule.getClientId(), is("Cl42824050"));
    collector.checkThat(
        clientMessageRule.getInvoiceMessageRuleId().getGuid(),
        is("face8421-11f1-4684-1769-3478152e5597"));
    collector.checkThat(
        clientMessageRule.getMessageText(),
        is("This is a text to be printed on all invoices for this client"));
    collector.checkThat(
        clientMessageRule.getValidFrom().toString(), is("2012-06-25T00:00:00.000+01:00"));
    collector.checkThat(
        clientMessageRule.getValidTo().toString(), is("2012-08-30T00:00:00.000+01:00"));

    List<Market> marketIds = client.getMarketIds();
    collector.checkThat(marketIds.size(), is(1));
    collector.checkThat(marketIds.get(0).getOrganizationId(), is(51));

    Address registeredAddress = client.getRegisteredAddress();

    collector.checkThat(registeredAddress.getCity(), is("Stockholm"));
    collector.checkThat(registeredAddress.getCountryCode().getValue(), is("SE"));
    collector.checkThat(registeredAddress.getLine1(), is("Vasagatan 38"));
    collector.checkThat(registeredAddress.getLine2(), is("hejsan"));
    collector.checkThat(registeredAddress.getPostalCode(), is("11120"));
    collector.checkThat(registeredAddress.getAddressType().getValue(), is(3));
    collector.checkThat(registeredAddress.getCounty(), nullValue());
  }