Updated jnr-unixsocket dependencies to 0.22 in *.mod.

Fixed Unix Socket distribution test.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-04-06 15:39:20 +02:00
parent aa7e9ee060
commit bd0f5ba313
2 changed files with 27 additions and 21 deletions

View File

@ -19,7 +19,7 @@ server
etc/jetty-unixsocket.xml
[files]
maven://com.github.jnr/jnr-unixsocket/0.20|lib/jnr/jnr-unixsocket-0.20.jar
maven://com.github.jnr/jnr-unixsocket/0.22|lib/jnr/jnr-unixsocket-0.22.jar
maven://com.github.jnr/jnr-ffi/2.1.9|lib/jnr/jnr-ffi-2.1.9.jar
maven://com.github.jnr/jffi/1.2.17|lib/jnr/jffi-1.2.17.jar
maven://com.github.jnr/jffi/1.2.16/jar/native|lib/jnr/jffi-1.2.16-native.jar
@ -30,8 +30,8 @@ maven://org.ow2.asm/asm-tree/7.0|lib/jnr/asm-tree-7.0.jar
maven://org.ow2.asm/asm-util/7.0|lib/jnr/asm-util-7.0.jar
maven://com.github.jnr/jnr-x86asm/1.0.2|lib/jnr/jnr-x86asm-1.0.2.jar
maven://com.github.jnr/jnr-constants/0.9.11|lib/jnr/jnr-constants-0.9.11.jar
maven://com.github.jnr/jnr-enxio/0.18|lib/jnr/jnr-enxio-0.18.jar
maven://com.github.jnr/jnr-posix/3.0.46|lib/jnr/jnr-posix-3.0.46.jar
maven://com.github.jnr/jnr-enxio/0.20|lib/jnr/jnr-enxio-0.20.jar
maven://com.github.jnr/jnr-posix/3.0.47|lib/jnr/jnr-posix-3.0.47.jar
[lib]
lib/jetty-unixsocket-${jetty.version}.jar

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
import org.eclipse.jetty.util.StringUtil;
import org.junit.jupiter.api.Test;
@ -41,6 +41,7 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class DistributionTests extends AbstractDistributionTest
{
@ -211,29 +212,33 @@ public class DistributionTests extends AbstractDistributionTest
}
@Test
public void unixSocket() throws Exception
public void testUnixSocket() throws Exception
{
Path sockFile;
Path tmpSockFile;
String unixSocketTmp = System.getProperty("unix.socket.tmp");
if( StringUtil.isNotBlank(unixSocketTmp))
if (StringUtil.isNotBlank(unixSocketTmp))
tmpSockFile = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock");
else
tmpSockFile = Files.createTempFile("unix", ".sock");
if (tmpSockFile.toAbsolutePath().toString().length() > UnixSocketConnector.MAX_UNIX_SOCKET_PATH_LENGTH)
{
sockFile = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock");
} else {
sockFile = Files.createTempFile("unix", ".sock");
Path tmp = Paths.get("/tmp");
assumeTrue(Files.exists(tmp) && Files.isDirectory(tmp));
tmpSockFile = Files.createTempFile(tmp, "unix", ".sock");
}
Path sockFile = tmpSockFile;
assertTrue(Files.deleteIfExists(sockFile), "temp sock file cannot be deleted");
String jettyVersion = System.getProperty("jettyVersion");
DistributionTester distribution = DistributionTester.Builder.newInstance()
.jettyVersion(jettyVersion)
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();
.jettyVersion(jettyVersion)
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();
String[] args1 = {
"--create-startd",
"--add-to-start=unixsocket-http,deploy,jsp",
"--approve-all-licenses"
"--create-startd",
"--add-to-start=unixsocket-http,deploy,jsp",
"--approve-all-licenses"
};
try (DistributionTester.Run run1 = distribution.start(args1))
{
@ -243,19 +248,20 @@ public class DistributionTests extends AbstractDistributionTest
File war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + jettyVersion);
distribution.installWarFile(war, "test");
try (DistributionTester.Run run2 = distribution.start("jetty.unixsocket="+sockFile.toString()))
try (DistributionTester.Run run2 = distribution.start("jetty.unixsocket.path=" + sockFile.toString()))
{
assertTrue(run2.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS));
startHttpClient(() -> new HttpClient( new HttpClientTransportOverUnixSockets(sockFile.toString()), null));
startHttpClient(() -> new HttpClient(new HttpClientTransportOverUnixSockets(sockFile.toString()), null));
ContentResponse response = client.GET("http://localhost/test/index.jsp");
assertEquals(HttpStatus.OK_200, response.getStatus());
assertThat(response.getContentAsString(), containsString("Hello"));
assertThat(response.getContentAsString(), not(containsString("<%")));
}
} finally {
}
finally
{
Files.deleteIfExists(sockFile);
}
}
}