Package org.crsh.shell

Examples of org.crsh.shell.ShellProcessContext


    console.on(KeyStrokes.of("foo"));
    console.on(KeyStrokes.ENTER);
    console.on(KeyStrokes.of("a"));
    console.on(KeyStrokes.INTERRUPT);
    latch.await();
    ShellProcessContext context = contexts.poll(1, TimeUnit.SECONDS);
    context.end(ShellResponse.ok());
    assertEquals("a", getCurrentLine());
    assertEquals(1, getCurrentCursor());
  }
View Full Code Here


    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    console.on(KeyStrokes.b);
    console.on(KeyStrokes.ENTER);
    assertEquals("a", requests.poll());
    ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        contexts.add(context);
      }
    });
    context.end(ShellResponse.ok());
    context = contexts.poll();
    assertNotNull(context);
    context.end(ShellResponse.ok());
  }
View Full Code Here

    });
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    context.end(ShellResponse.ok());
    driver.assertCRLF().assertFlush().assertChar('%').assertChar(' ').assertFlush().assertEmpty();
  }
View Full Code Here

    console.init();
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    final ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    final ArrayBlockingQueue<String> lines = new ArrayBlockingQueue<String>(1);
    Thread t = new Thread() {
      @Override
      public void run() {
        try {
          String s = context.readLine("m", true);
          lines.add(s);
        }
        catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

    console.init();
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    final ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    console.on(KeyStrokes.b);
    console.on(KeyStrokes.ENTER);
    driver.assertEmpty();
    String line = context.readLine("m", true);
    driver.assertChar('m').assertFlush().assertChar('b').assertFlush().assertCRLF().assertFlush().assertEmpty();
    assertEquals("b", line);
  }
View Full Code Here

    console.init();
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    final ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1);
    Thread t = new Thread() {
      @Override
      public void run() {
        try {
          context.readLine("", true);
        }
        catch (InterruptedException e) {
          interrupteds.add(true);
        }
        catch (Exception e) {
          interrupteds.add(false);
        }
      }
    };
    t.start();
    while (t.getState() != Thread.State.WAITING) {
      // Wait until the other thread is waiting
    }
    try {
      context.readLine("", true);
      fail();
    }
    catch (IllegalStateException expected) {
    }
    t.interrupt();
View Full Code Here

    console.init();
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    final ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1);
    Thread t = new Thread() {
      @Override
      public void run() {
        try {
          context.readLine("", true);
        }
        catch (InterruptedException e) {
          interrupteds.add(true);
        }
        catch (Exception e) {
          interrupteds.add(false);
        }
      }
    };
    t.start();
    while (t.getState() != Thread.State.WAITING) {
      // Wait until the other thread is waiting
    }
    context.end(ShellResponse.ok());
    boolean interrupted = interrupteds.poll(3, TimeUnit.SECONDS);
    assertTrue(interrupted);
  }
View Full Code Here

    console.init();
    console.on(KeyStrokes.a);
    console.on(KeyStrokes.ENTER);
    driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty();
    driver.assertEmpty();
    final ShellProcessContext context = contexts.poll();
    assertNotNull(context);
    final ArrayBlockingQueue<Boolean> interrupteds = new ArrayBlockingQueue<Boolean>(1);
    Thread t = new Thread() {
      @Override
      public void run() {
        try {
          context.readLine("", true);
        }
        catch (InterruptedException e) {
          interrupteds.add(true);
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.crsh.shell.ShellProcessContext

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.