Examples of TInput


Examples of org.apache.niolex.commons.test.TInput

            @Override
            protected void process(TInput in, Dispatcher dispatcher) {
                System.out.println("x get input with tag " + (in.getTag() == 0 ? in.hashCode() : in.getTag()));
            }};
        assertEquals("not yet implemented", s.getStageName());
        s.addInput(new TInput(3));
        s.shutdown();
        assertEquals(0, s.getInputSize());
    }
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

  @Test
  public final void testShutdownSend() {
    SleepStage ss = new SleepStage("abc", dispatcher);
    ss.shutdown();
    ss = spy(ss);
    TInput in = mock(TInput.class);
    ss.addInput(in);
    ArgumentCaptor<RejectType> cap = ArgumentCaptor.forClass(RejectType.class);
    verify(ss).reject(cap.capture(), eq("abc"), eq(in));
    assertEquals(RejectType.STAGE_SHUTDOWN, cap.getValue());
    assertEquals(ss.getInputSize(), 0);
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

   *
   * @throws InterruptedException
   */
  @Test
  public final void testProcessError() throws InterruptedException {
      TInput in = mock(TInput.class);
      final One<RejectType> one = One.create(null);
    SleepStage ss = new SleepStage("abc", dispatcher){
        @Override
        public void reject(RejectType type, Object info, Message msg) {
            one.a = type;
        }
    };
    when(in.getTag()).thenReturn(65432);
    ss.addInput(in);
    Thread.sleep(100);
    assertEquals(RejectType.PROCESS_ERROR, one.a);
    assertEquals(ss.getInputSize(), 0);
    ss.shutdown();
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

            @Override
            protected void process(Message in, Dispatcher dispatcher) {
                ThreadUtil.sleep(1);
            }};
    TInput in = mock(TInput.class);
    RejectMessage r = new RejectMessage(RejectType.USER_REJECT, "By Drop Message", in);
    for (int i = 0; i < 20000; ++i) {
      ss.addInput(in);
      ss.addInput(r);
    }
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

                throw new NullPointerException();
            }

      };

      TInput in = mock(TInput.class);
        RejectMessage r = new RejectMessage(RejectType.USER_REJECT, "By Drop Message", in);
        ss.addInput(r);
        ss.addInput(r);
        ss.addInput(in);
        ss.addInput(r);
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

  @Test
  public final void testAddThreadToMax() throws Exception {
    SleepStage ss = new SleepStage("abc", dispatcher);
    Field f = Stage.class.getDeclaredField("lastAdjustTime");
    f.setAccessible(true);
    TInput in = mock(TInput.class);
    // Prepare ready.
    // stage 1.
    for (int i = 0; i < 60; ++i) {
      ss.addInput(in);
    }
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

  @Test
  public final void testAdjustTremble() throws Exception {
    SleepStage ss = new SleepStage("abc", dispatcher, 600);
    Field f = Stage.class.getDeclaredField("lastAdjustTime");
    f.setAccessible(true);
    TInput in = mock(TInput.class);
    ss.processRate = 0.030;
    // Prepare ready.
    // stage 1.
    for (int i = 0; i < 100; ++i) {
      ss.addInput(in);
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

  }

  @Test
  public void testDispatch() throws Exception {
    for (int i = 0; i < computeSize; ++i) {
      disp.dispatch("c1", new TInput(MockUtil.randInt(1000)));
      Thread.sleep(1);
    }

    latch.await(10, TimeUnit.SECONDS);
    disp.shutdown();
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

    adj.startAdjust();
    int it = 10000;
    //
    System.out.println("stage 1. send 10 request and sleep 10.");
    while (it-- > 0) {
      s.addInput(new TInput());
      Thread.sleep(1);
    }
    //
    System.out.println("stage 2. send 60 request and sleep 10.");
    it = 5000;
    while (it-- > 0) {
      for (int i = 0; i < 60; ++i) {
        s.addInput(new TInput());
      }
      Thread.sleep(10);
    }
    it = 20000;
    //
    System.out.println("stage 3. send 20 request and sleep 10.");
    while (it-- > 0) {
      s.addInput(new TInput());
      s.addInput(new TInput());
      Thread.sleep(1);
    }
    //
    it = 10000;
    System.out.println("stage 4. send 10 request and sleep 10.");
    while (it-- > 0) {
      s.addInput(new TInput());
      Thread.sleep(1);
    }
    //
    System.out.println("stage 5. shutdown now.");
    Thread.sleep(100);
View Full Code Here

Examples of org.apache.niolex.commons.test.TInput

  /**
   * Test method for {@link org.apache.niolex.commons.seda.Dispatcher#dispatch(java.lang.String, org.apache.niolex.commons.seda.Message)}.
   */
  @Test
  public final void testDispatchStringT() {
    boolean a = disp.dispatch("C1", new TInput());
    assertTrue(a);
    a = disp.dispatch("C2", new TInput());
    assertFalse(a);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.