Package test.shell.sync

Examples of test.shell.sync.SyncProcess


  public void testCloseHangingProcess() throws Exception {
    final CyclicBarrier syncA = new CyclicBarrier(2);
    final CyclicBarrier syncB = new CyclicBarrier(2);
    final CyclicBarrier syncC = new CyclicBarrier(2);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
          syncB.await();
View Full Code Here


  public void testBreak() throws Exception {
    final CyclicBarrier syncA = new CyclicBarrier(2);
    final CyclicBarrier syncB = new CyclicBarrier(3);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
          syncB.await();
View Full Code Here

  }

  @Test
  public void testRequest() throws Exception {
    final ArrayBlockingQueue<String> requests = new ArrayBlockingQueue<String>(1);
    foo.shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        context.append("world");
        context.end(ShellResponse.ok());
        requests.add(request);
View Full Code Here

  }

  @Test
  public void testServerClose() throws Exception {
    final ArrayBlockingQueue<String> requests = new ArrayBlockingQueue<String>(1);
    foo.shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        context.end(ShellResponse.close());
        requests.add(request);
      }
View Full Code Here

  public void testBufferEvent() throws Exception {
    final CyclicBarrier syncA = new CyclicBarrier(2);
    final CountDownLatch syncB = new CountDownLatch(1);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        syncA.await();
        syncB.await();
        context.append("foo");
        context.end(ShellResponse.ok());
      }
    });
    syncA.await();
    term.publish(TermEvent.readLine("bar"));
    syncB.countDown();
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        context.append("bar");
        context.end(ShellResponse.ok());
      }
    });
View Full Code Here

  public void testCancellation() throws Exception {
    final CyclicBarrier syncA = new CyclicBarrier(2);
    final CyclicBarrier syncB = new CyclicBarrier(getBarrierSize());
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      @Override
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
          syncB.await();
        }
        catch (Exception e) {
          e.printStackTrace();
        }
      }

      public void cancel() {
        try {
          syncB.await();
        }
        catch (Exception e) {
          e.printStackTrace();
        }
      }
    });
    syncA.await();
    term.publish(TermEvent.brk());
    term.publish(TermEvent.readLine("bar"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        context.append("bar");
        context.end(ShellResponse.ok());
      }
    });
View Full Code Here

  }

  public void testProcessClose() throws Exception {
    processor.addListener(term);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        context.end(ShellResponse.close());
      }
    });
    assertJoin(thread);
View Full Code Here

    final CyclicBarrier syncB = new CyclicBarrier(2);
    final CyclicBarrier syncC = new CyclicBarrier(2);
    final AtomicReference<String> line = new AtomicReference<String>();
    processor.addListener(term);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
          syncB.await();
        }
View Full Code Here

    final CyclicBarrier syncB = new CyclicBarrier(2);
    final CyclicBarrier syncC = new CyclicBarrier(2);
    final AtomicReference<String> line = new AtomicReference<String>();
    processor.addListener(term);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
          syncB.await();
        }
View Full Code Here

    final CyclicBarrier syncA = new CyclicBarrier(2);
    final CyclicBarrier syncB = new CyclicBarrier(2);
    final AtomicReference<String> line = new AtomicReference<String>();
    processor.addListener(term);
    term.publish(TermEvent.readLine("foo"));
    shell.addProcess(new SyncProcess() {
      public void run(String request, ShellProcessContext context) throws Exception {
        try {
          syncA.await();
        }
        catch (Exception e) {
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.