Examples of SleepingAnswer


Examples of net.sf.katta.testutil.mockito.SleepingAnswer

  }

  @Test
  public void testGracefulStartup_Shutdown() throws Exception {
    NodeOperation nodeOperation = mock(NodeOperation.class);
    when(_queue.peek()).thenReturn(nodeOperation).thenAnswer(new SleepingAnswer());

    _node.start();

    assertNotNull(_node.getName());
    assertNotNull(_node.getRpcServer());
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

  }

  @Test
  public void testDisconnectReconnect() throws Exception {
    NodeOperation nodeOperation = mock(NodeOperation.class);
    when(_queue.peek()).thenReturn(nodeOperation).thenAnswer(new SleepingAnswer());
    _node.start();
    Thread.sleep(200);
    verify(nodeOperation, times(1)).execute((NodeContext) notNull());

    _node.disconnect();
    NodeOperation nodeOperation2 = mock(NodeOperation.class);
    reset(_queue);
    when(_queue.peek()).thenReturn(nodeOperation2).thenAnswer(new SleepingAnswer());

    _node.reconnect();
    Thread.sleep(200);
    verify(nodeOperation, times(1)).execute((NodeContext) notNull());
    verify(nodeOperation2, times(1)).execute((NodeContext) notNull());
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

    _node.shutdown();
  }

  @Test
  public void testShutdown_doesNotCloseZkClient() throws Exception {
    when(_queue.peek()).thenAnswer(new SleepingAnswer());
    _node.start();
    _node.shutdown();
    verify(_protocol, never()).disconnect();
  }
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

  }

  @Test
  public void testRedployInstalledShards() throws Exception {
    NodeOperation nodeOperation = mock(NodeOperation.class);
    when(_queue.peek()).thenReturn(nodeOperation).thenAnswer(new SleepingAnswer());

    // start and add shard
    _node.start();
    verify(_contentServer, times(0)).addShard(anyString(), any(File.class));
    String shardName = "shard1";
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

    }
  }

  private MasterQueue mockBlockingOperationQueue() throws InterruptedException {
    MasterQueue queue = mock(MasterQueue.class);
    when(queue.peek()).thenAnswer(new SleepingAnswer());
    return queue;
  }
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

    _processor.run();
  }

  @Test(timeout = 10000)
  public void testDontStopOnOOM() throws Exception {
    when(_queue.peek()).thenThrow(new OutOfMemoryError("test exception")).thenAnswer(new SleepingAnswer());
    Thread thread = new Thread() {
      public void run() {
        _processor.run();
      };
    };
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

            return indexSearcher;
          }
          shardsWithTiemoutCount.incrementAndGet();
        }
        IndexSearcher indexSearcherSpy = spy(indexSearcher);
        doAnswer(new ChainedAnswer(new SleepingAnswer(serverTimeout * 2), new CallsRealMethods())).when(
                indexSearcherSpy).search(any(Weight.class), any(Filter.class), any(Collector.class));
        return indexSearcherSpy;
      }
    });
    server = new LuceneServer("server", mockSeacherFactory, 0.01f);
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

          new DefaultDistributionPolicy(), _queue);

  @Test(timeout = 10000)
  public void testSafeMode() throws Exception {
    final MasterOperation operation = mockOperation(ExecutionInstruction.EXECUTE);
    when(_queue.peek()).thenReturn(operation).thenAnswer(new SleepingAnswer());
    when(_protocol.getLiveNodes()).thenReturn(EMPTY_LIST);

    long safeModeMaxTime = 200;
    OperatorThread operatorThread = new OperatorThread(_context, safeModeMaxTime);
    operatorThread.start();
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

    operatorThread.interrupt();
  }

  @Test(timeout = 10000)
  public void testGracefulShutdownWhileInSafeMode() throws Exception {
    when(_queue.peek()).thenAnswer(new SleepingAnswer());

    long safeModeMaxTime = 2000;
    OperatorThread operatorThread = new OperatorThread(_context, safeModeMaxTime);
    operatorThread.start();
View Full Code Here

Examples of net.sf.katta.testutil.mockito.SleepingAnswer

    operatorThread.join();
  }

  @Test(timeout = 10000)
  public void testGracefulShutdownWhileWaitingForOperations() throws Exception {
    when(_queue.peek()).thenAnswer(new SleepingAnswer());
    when(_protocol.getLiveNodes()).thenReturn(Arrays.asList("node1"));
    long safeModeMaxTime = 200;
    OperatorThread operatorThread = new OperatorThread(_context, safeModeMaxTime);
    operatorThread.start();
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.