Пример #1
0
  @Test
  public void shouldStopKoalaNode() {
    // act
    cloudPlatform.stop();

    // assert
    verify(koalaNode).stop();
  }
Пример #2
0
  @Test
  public void shouldStartKoalaNode() {
    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(koalaNode).start();
  }
Пример #3
0
  @Before
  public void setUp() throws Exception {
    koalaNode = mock(KoalaNode.class);
    commandLine = mock(CommandLine.class);

    cloudPlatform = new CloudPlatform();
    cloudPlatform.setKoalaNode(koalaNode);
  }
Пример #4
0
  @Test
  public void shouldRethrowThrowable() {
    // setup
    RuntimeException ex = mock(RuntimeException.class);
    doThrow(ex).when(koalaNode).start();

    // act
    try {
      cloudPlatform.start(commandLine);
      fail();
    } catch (RuntimeException t) {
      assertEquals(ex, t.getCause());
    }
  }
Пример #5
0
  @Test
  public void shouldSetPreferredBootstrapIfSetOnCommandLine() {
    // setup
    String prefferedBootstrap = "abc";

    when(commandLine.hasOption("b")).thenReturn(true);
    when(commandLine.getOptionValue("b")).thenReturn(prefferedBootstrap);

    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(commandLine).getOptionValue("b");
    verify(koalaNode).setPreferredBootstraps(prefferedBootstrap);
  }
Пример #6
0
  @Test
  public void shouldSetPortIfSetOnCommandLine() {
    // setup
    String port = "50";

    when(commandLine.hasOption("p")).thenReturn(true);
    when(commandLine.getOptionValue("p")).thenReturn(port);

    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(commandLine).getOptionValue("p");
    verify(koalaNode).setPort(50);
  }
Пример #7
0
  @Test
  public void shouldLoadAddressPathIfSetOnCommandLine() {
    // setup
    String addressPattern = "addressPattern";

    when(commandLine.hasOption("a")).thenReturn(true);
    when(commandLine.getOptionValue("a")).thenReturn(addressPattern);

    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(commandLine).getOptionValue("a");
    verify(koalaNode).setAddressPattern(addressPattern);
  }
Пример #8
0
  @Test
  public void shouldSetNodeIdFileWhenInSingleRunModeAndPortAndAddressAreNull() {
    // setup
    ArgumentCaptor<String> nodeIdFile = ArgumentCaptor.forClass(String.class);
    when(commandLine.hasOption("a")).thenReturn(false);
    when(commandLine.getOptionValue("a")).thenReturn(null);
    when(commandLine.hasOption("p")).thenReturn(false);
    when(commandLine.getOptionValue("p")).thenReturn(null);
    when(commandLine.hasOption("s")).thenReturn(true);

    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(koalaNode).setNodeIdFile(nodeIdFile.capture());
    assertTrue(nodeIdFile.getValue().contains("nodeId"));
  }
Пример #9
0
  @Test
  public void shouldSetNodeIdFileWhenInSingleRunMode() {
    // setup
    ArgumentCaptor<String> nodeIdFile = ArgumentCaptor.forClass(String.class);
    String port = "50";
    String addressPattern = "addressPattern";

    when(commandLine.hasOption("a")).thenReturn(true);
    when(commandLine.getOptionValue("a")).thenReturn(addressPattern);
    when(commandLine.hasOption("p")).thenReturn(true);
    when(commandLine.getOptionValue("p")).thenReturn(port);
    when(commandLine.hasOption("s")).thenReturn(true);

    // act
    cloudPlatform.start(commandLine);

    // assert
    verify(koalaNode).setNodeIdFile(nodeIdFile.capture());
    assertTrue(nodeIdFile.getValue().contains(port));
    assertTrue(nodeIdFile.getValue().contains(addressPattern));
  }