Package test.shell.sync

Examples of test.shell.sync.SyncProcess


    driver.assertCRLF().assertFlush().assertChar('%').assertChar(' ').assertFlush().assertEmpty();
  }

  public void testHandleKeyInProcess() {
    final ArrayBlockingQueue<Integer> keys = new ArrayBlockingQueue<Integer>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      protected KeyHandler createKeyHandler() {
        return new KeyHandler() {
          @Override
          public void handle(KeyType type, int[] sequence) {
View Full Code Here


    assertEquals((int)'b', (int)keys.poll());
    assertFalse(console.getKeyBuffer().iterator().hasNext());
  }

  public void testHandleKeyExceptionInProcess() {
    shell.addProcess(new SyncProcess() {
      @Override
      protected KeyHandler createKeyHandler() {
        return new KeyHandler() {
          @Override
          public void handle(KeyType type, int[] sequence) {
View Full Code Here

    driver.assertChar('a').assertFlush();
    driver.assertChar('\\').assertFlush();
    driver.assertCRLF().assertChars("> ").assertFlush();
    driver.assertChar('b').assertFlush().assertEmpty();
    final ArrayList<String> requests = new ArrayList<String>();
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        requests.add(request);
      }
    });
View Full Code Here

    driver.assertCRLF().assertChars("> ").assertFlush();
    driver.assertChar('c').assertFlush();
    driver.assertChar('"').assertFlush();
    driver.assertChar('d').assertFlush().assertEmpty();
    final ArrayList<String> requests = new ArrayList<String>();
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        requests.add(request);
      }
    });
View Full Code Here

    driver.assertChars("d ").assertFlush().assertEmpty();
  }

  public void testInterruptMultiline() throws Exception {
    final ArrayBlockingQueue<String> keys = new ArrayBlockingQueue<String>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        keys.add(request);
      }
    });
View Full Code Here

    console.init();
    console.on(KeyStrokes.UP);
    driver.assertEmpty();
    console.on(KeyStrokes.DOWN);
    driver.assertEmpty();
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        context.end(ShellResponse.ok());
      }
    });
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertCRLF().assertFlush().assertEmpty();
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        context.end(ShellResponse.ok());
      }
    });
    console.on(KeyStrokes.b);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('b').assertFlush().assertCRLF().assertFlush().assertCRLF().assertFlush().assertEmpty();
    console.on(KeyStrokes.c);
    driver.assertChar('c').assertFlush().assertEmpty();
    console.on(KeyStrokes.UP);
    driver.assertDel().assertChar('b').assertFlush().assertEmpty();
    console.on(KeyStrokes.UNDERSCORE);
    driver.assertChar('_').assertFlush().assertEmpty();
    console.on(KeyStrokes.UP);
    driver.assertDel().assertDel().assertChar('a').assertFlush().assertEmpty();
    console.on(KeyStrokes.UP);
    driver.assertEmpty();
    console.on(KeyStrokes.DOWN);
    driver.assertDel().assertChar('b').assertChar('_').assertFlush().assertEmpty();
    console.on(KeyStrokes.DOWN);
    driver.assertDel().assertDel().assertChar('c').assertFlush().assertEmpty();
    console.on(KeyStrokes.DOWN);
    driver.assertEmpty();
    console.on(KeyStrokes.UP);
    driver.assertDel().assertChar('b').assertChar('_').assertFlush().assertEmpty();
    console.on(KeyStrokes.ONE);
    driver.assertChar('1').assertFlush().assertEmpty();
    final ArrayList<String> requests = new ArrayList<String>();
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        requests.add(request);
        context.end(ShellResponse.ok());
      }
View Full Code Here

    driver.assertDel().assertDel().assertChar('a').assertFlush().assertEmpty();
  }

  public void testReadLine1() throws Exception {
    final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        contexts.add(context);
      }
    });
View Full Code Here

   * Same than {@link #testReadLine1()} but we provide input before the thread read lines effectively
   * which leads to a simpler test since we need only one thread
   */
  public void testReadLine2() throws Exception {
    final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        contexts.add(context);
      }
    });
View Full Code Here

   * - we cannot call readline twice at the same time and
   * - if the reading thread is interrupted then it throws InterruptedIOException
   */
  public void testReadLine3() throws Exception {
    final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        contexts.add(context);
      }
    });
View Full Code Here

  /**
   * Make sure that a reading thread is interrupted when the process ends
   */
  public void testReadLine4() throws Exception {
    final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        contexts.add(context);
      }
    });
View Full Code Here

TOP

Related Classes of test.shell.sync.SyncProcess

Copyright © 2018 www.massapicom. 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.