Example #1
0
  @Test
  public void shouldReThrowWebServerException() throws IOException, InterruptedException {
    WebDaemon webDaemon = spy(new WebDaemon());
    ReflectionUtils.setField(main, "webDaemon", webDaemon);

    InterruptedException toBeThrown = new InterruptedException("Ouch!");
    doThrow(toBeThrown).when(webDaemon).start(any(ConfigurationForServer.class));

    try {
      main.runMain(new String[] {"-ws", "--port=1234"});
      fail("Should have thrown exception");
    } catch (RuntimeException rte) {
      assertThat((InterruptedException) rte.getCause(), sameInstance(toBeThrown));
    }
  }
Example #2
0
  @Test
  public void shouldRunFileSystem() throws IOException, InterruptedException {
    main.runMain(new String[] {"-fs", "--js-version=1.0", "src", "dest"});

    TypeSafeMatcher<ConfigurationForFS> matcher =
        new TypeSafeMatcher<ConfigurationForFS>() {
          @Override
          protected boolean matchesSafely(ConfigurationForFS item) {
            return item.getCompilerEnvirons().getLanguageVersion() == 100;
          }

          public void describeTo(Description description) {}
        };
    verify(fileSystemInstrumenter, times(1)).run(argThat(matcher));
  }
Example #3
0
  @Test
  public void shouldRunWebServer() throws IOException, InterruptedException {
    main.runMain(new String[] {"-ws", "--port=1234"});

    TypeSafeMatcher<ConfigurationForServer> matcher =
        new TypeSafeMatcher<ConfigurationForServer>() {
          @Override
          protected boolean matchesSafely(ConfigurationForServer item) {
            return item.getPort() == 1234;
          }

          public void describeTo(Description description) {}
        };
    verify(webDaemon, times(1)).start(argThat(matcher));
  }
Example #4
0
 @Test
 public void shouldShowFileSystemHelp() throws IOException, InterruptedException {
   main.runMain(new String[] {"-ws", "-h"});
   verifyZeroInteractions(fileSystemInstrumenter);
 }
Example #5
0
 @Test
 public void shouldShowWebServerHelp() throws IOException, InterruptedException {
   main.runMain(new String[] {"-ws", "-h"});
   verifyZeroInteractions(webDaemon);
 }