예제 #1
0
  // Test the change plan when trying to change a student plan
  @Test
  public void transferpairtest() {
    Backend b = new Backend();
    String[] args = new String[1];
    args[0] = "MasterBankAccounts.txt";

    tlist.clear();

    Transaction t = new Transaction();
    t.setCode("10");
    t.setMisc("A");
    t.setName("");

    Transaction t2 = new Transaction();
    t2.setCode("02");
    t2.setNum("00005");

    Transaction t3 = new Transaction();
    t3.setCode("00");

    tlist.add(t);
    tlist.add(t2);
    tlist.add(t3);

    b.load(args);
    b.setTransactions(tlist);
    b.handletransactions();
    assertEquals("Transfer transactions must come in pairs\n", outContent.toString());
  }
예제 #2
0
  @Test
  public void fromIterable() {
    ArrayList<String> items = new ArrayList<>();
    items.add("one");
    items.add("two");
    items.add("three");

    assertEquals((Long) 3L, Observable.fromIterable(items).count().toBlocking().single());
    assertEquals("two", Observable.fromIterable(items).skip(1).take(1).toBlocking().single());
    assertEquals("three", Observable.fromIterable(items).takeLast(1).toBlocking().single());
  }
예제 #3
0
  @Before
  public void init() {
    alist.add(a1);
    alist.add(a2);
    alist.add(a3);
    alist.add(a4);
    alist.add(a5);
    alist.add(a6);
    alist.add(a7);
    alist.add(a8);
    alist.add(a9);

    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));
  }
예제 #4
0
 /** helper method to insert elements in an iterator into a list. */
 private ArrayList<Position> convertIteration2List(Iterator<Position> iter) {
   neighborhood = new ArrayList<Position>();
   while (iter.hasNext()) {
     p = iter.next();
     neighborhood.add(p);
   }
   return neighborhood;
 }
예제 #5
0
 protected static ArrayList<ServerName> getServerNameList() throws IOException {
   if (TestBase.serverNameList == null) {
     Set<ServerName> serverNameSet = new TreeSet<>(admin.getClusterStatus().getServers());
     ArrayList<ServerName> serverNameList = new ArrayList<>();
     for (ServerName serverName : serverNameSet) {
       serverNameList.add(serverName);
     }
     TestBase.serverNameList = serverNameList;
   }
   return TestBase.serverNameList;
 }
예제 #6
0
 /**
  * Test.
  *
  * @throws Throwable throwable
  */
 @Test
 public void test() throws Throwable {
   // generate reference result
   result = query(QUERY);
   // generate results to be compared
   final ArrayList<Query> queries = new ArrayList<>();
   for (int i = 0; i < 10; i++) queries.add(new Query());
   for (final Query q : queries) q.start();
   for (final Query q : queries) q.join();
   if (error != null) throw error;
 }
  public void runTest(
      final String url,
      final int urlGroupSize,
      final ExceptionHandler exceptionHandler,
      int threadCount) {
    ok = true;
    long beginTime = System.currentTimeMillis();
    ArrayList<Thread> list = new ArrayList<Thread>();
    for (int t = 1; t <= threadCount; t++) {
      Thread tt =
          new Thread(url + "_runTest_" + t) {
            @Override
            public void run() {
              boolean useGroup = urlGroupSize > 1;
              for (int i = 1; i <= urlGroupSize; i++) {
                if (!ok) return;

                String resp = null;
                Throwable t = null;
                try {
                  if (useGroup) {
                    resp = httpClientUtils.get(url + i);
                  } else {
                    resp = httpClientUtils.get(url);
                  }
                } catch (Throwable e) {
                  Throwable ee = ExceptionUtils.getRootCause(e);
                  if (ee == null) {
                    ee = e;
                  }
                  Logger.error(this, "", ee);
                  t = ee;
                } finally {
                  if (ok) {
                    ok = exceptionHandler.handle(t);
                  }
                }
                Logger.info(this, "resp[" + i + "]=========[" + resp + "]=========");
              }
            }
          };
      list.add(tt);
      tt.start();
    }
    for (Thread tt : list) {
      try {
        tt.join();
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    Assert.assertTrue(ok);
    Logger.info(this, "take time milliseconds: " + (System.currentTimeMillis() - beginTime));
  }
예제 #8
0
  @Test
  public void testOfTypeWithPolymorphism() {
    ArrayList<Integer> l1 = new ArrayList<>();
    l1.add(1);
    LinkedList<Integer> l2 = new LinkedList<>();
    l2.add(2);

    @SuppressWarnings("rawtypes")
    Observable<List> observable = Observable.<Object>just(l1, l2, "123").ofType(List.class);

    Subscriber<Object> observer = TestHelper.mockSubscriber();

    observable.subscribe(observer);

    verify(observer, times(1)).onNext(l1);
    verify(observer, times(1)).onNext(l2);
    verify(observer, never()).onNext("123");
    verify(observer, never()).onError(org.mockito.Matchers.any(Throwable.class));
    verify(observer, times(1)).onComplete();
  }