Application implements AutoCloseable { public static Application fromServicesXml(String xml, Networking networking) { Path applicationDir = StandaloneContainerRunner.createApplicationPackage(xml); return new Application(applicationDir, networking, true); } Application(Path path, Networking networking, boolean deletePathWhenClosing); @Beta static Application fromBuilder(Builder builder); static Application fromServicesXml(String xml, Networking networking); static Application fromApplicationPackage(Path path, Networking networking); static Application fromApplicationPackage(File file, Networking networking); JDisc getJDisc(String id); @Override void close(); static final String vespaLocalProperty; }
@Test public void minimal_application_can_be_constructed() { try (Application application = Application.fromServicesXml("<container version=\"1.0\"/>", Networking.disable)) { Application unused = application; } }
@Test(expected = ConnectException.class) public void http_interface_is_off_when_networking_is_disabled() throws Exception { int httpPort = getFreePort(); try (Application application = Application.fromServicesXml(servicesXmlWithServer(httpPort), Networking.disable)) { HttpClient client = new org.apache.http.impl.client.DefaultHttpClient(); int statusCode = client.execute(new HttpGet("http: fail("Networking.disable is specified, but the network interface is enabled! Got status code: " + statusCode); Application unused = application; } }
@Test public void http_interface_is_on_when_networking_is_enabled() throws Exception { int httpPort = getFreePort(); try (Application application = Application.fromServicesXml(servicesXmlWithServer(httpPort), Networking.enable)) { HttpClient client = new org.apache.http.impl.client.DefaultHttpClient(); HttpResponse response = client.execute(new HttpGet("http: assertEquals(200, response.getStatusLine().getStatusCode()); BufferedReader r = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String line; StringBuilder sb = new StringBuilder(); while ((line = r.readLine()) != null) { sb.append(line).append("\n"); } assertTrue(sb.toString().contains("Handler")); Application unused = application; } }
@Test public void application_with_access_control_can_be_constructed() { try (Application application = Application.fromServicesXml(servicesXmlWithAccessControl(), Networking.disable)) { Application unused = application; } }