File appDir = new File(getBuildDirectory(), "webapps/examples");
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
tomcat.start(); int port = getPort();
tomcat.getConnector().stop();
Exception e = null; try (ServerSocket s = new ServerSocket(port, 100, InetAddress.getByName("localhost"))) { // This should not throw an Exception
} catch (Exception e1) {
e = e1;
} Assert.assertNull(e);
tomcat.getConnector().start();
}
@Test publicvoid testUnixDomainSocket() throws Exception {
Tomcat tomcat = getTomcatInstance();
Connector c = tomcat.getConnector();
Assume.assumeTrue("NIO Unix domain sockets have to be supported for this test",
c.getProtocolHandlerClassName().contains("NioProtocol")
&& JreCompat.isJre16Available());
File tempPath = File.createTempFile("uds-tomcat-test-", ".sock");
String unixDomainSocketPath = tempPath.getAbsolutePath(); // Need to delete the file to make way for the actual socket Assert.assertTrue(tempPath.delete()); Assert.assertTrue(c.setProperty("unixDomainSocketPath", unixDomainSocketPath));
tomcat.start();
// Connect to the domain socket as a client
SocketAddress sa = JreCompat.getInstance().getUnixDomainSocketAddress(unixDomainSocketPath);
ByteBuffer response = ByteBuffer.allocate(1024); try (SocketChannel socket = JreCompat.getInstance().openUnixDomainSocketChannel()) {
socket.connect(sa);
socket.write(ByteBuffer.wrap("OPTIONS * HTTP/1.0\r\n\r\n".getBytes()));
socket.read(response);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.