Esempio n. 1
0
  @Test
  public void shouldNotFailIfStartupTakesLessTimeThanTimeout() throws IOException {
    Configurator configurator = buildProperties();
    configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 100);
    server =
        new CommunityNeoServer(configurator) {
          @Override
          protected Iterable<ServerModule> createServerModules() {
            return Arrays.asList();
          }
        };

    // When
    try {
      server.start();
    } catch (ServerStartupException e) {
      fail("Should not have been interupted.");
    }

    // Then
    InterruptThreadTimer timer =
        server.getDependencyResolver().resolveDependency(InterruptThreadTimer.class);

    assertThat(timer.getState(), is(InterruptThreadTimer.State.IDLE));
  }
Esempio n. 2
0
  @Test
  public void serverShouldSupportSsl() throws Exception {
    // When
    server.start();

    // Then
    assertThat(server.getHttpsEnabled(), is(true));
    assertThat(GET(httpsUri).status(), is(200));
  }
Esempio n. 3
0
  @Before
  public void startServer() throws NoSuchAlgorithmException, KeyManagementException, IOException {
    server =
        server()
            .withHttpsEnabled()
            .usingDatabaseDir(folder.cleanDirectory(name.getMethodName()).getAbsolutePath())
            .build();
    httpsUri = server.httpsUri().toASCIIString();

    // Because we are generating a non-CA-signed certificate, we need to turn off verification in
    // the client.
    // This is ironic, since there is no proper verification on the CA side in the first place, but
    // I digress.

    TrustManager[] trustAllCerts =
        new TrustManager[] {
          new X509TrustManager() {
            public void checkClientTrusted(X509Certificate[] arg0, String arg1)
                throws CertificateException {}

            public void checkServerTrusted(X509Certificate[] arg0, String arg1)
                throws CertificateException {}

            public X509Certificate[] getAcceptedIssuers() {
              return null;
            }
          }
        };

    // Install the all-trusting trust manager
    SSLContext sc = SSLContext.getInstance("TLS");
    sc.init(null, trustAllCerts, new SecureRandom());
    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
  }
Esempio n. 4
0
 @After
 public void stopServer() {
   if (server != null) {
     server.stop();
     server = null;
   }
 }
Esempio n. 5
0
  @Test
  public void webadminShouldBeRetrievableViaSsl() throws Exception {
    // When
    server.start();

    // Then
    assertThat(GET(httpsUri + "webadmin/").status(), is(200));
  }
Esempio n. 6
0
  @Test
  public void shouldNotTimeOutIfTimeoutDisabled() throws IOException {
    Configurator configurator = buildProperties();
    configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 0);
    server = createSlowServer(configurator);

    // When
    server.start();

    // Then
    // No exceptions should have been thrown
  }
Esempio n. 7
0
  @Test
  public void txEndpointShouldReplyWithHttpsWhenItReturnsURLs() throws Exception {
    // Given
    server.start();

    // When
    HTTP.Response response =
        POST(httpsUri + "db/data/transaction", quotedJson("{'statements':[]}"));

    // Then
    assertThat(response.location(), startsWith(httpsUri));
    assertThat(response.get("commit").asText(), startsWith(httpsUri));
  }
Esempio n. 8
0
  @Test
  public void shouldTimeoutIfStartupTakesLongerThanTimeout() throws IOException {
    Configurator configurator = buildProperties();
    configurator.configuration().setProperty(Configurator.STARTUP_TIMEOUT, 1);
    server = createSlowServer(configurator);

    try {
      server.start();
      fail("Should have been interrupted.");
    } catch (ServerStartupException e) {
      // ok!
    }
  }
Esempio n. 9
0
 @After
 public void stopTheServer() {
   server.stop();
 }