Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
parent
d726fe5c03
commit
682ac94373
|
@ -179,6 +179,13 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-home</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
|
|
@ -29,11 +29,11 @@ import org.junit.Test;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
public class TestGetContent
|
||||
{
|
||||
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
int port = getPort();
|
|
@ -29,10 +29,11 @@ import org.junit.Test;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
public class TestGetContent
|
||||
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.its.jetty_run_war_mojo_it;
|
||||
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -30,12 +29,14 @@ import org.junit.Test;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
public class TestGetContent
|
||||
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
int port = getPort();
|
||||
Assert.assertTrue(port > 0);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
@ -57,6 +58,7 @@ public class TestHelloServlet
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -86,8 +88,7 @@ public class TestHelloServlet
|
|||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.its.jetty_run_mojo_it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = getPort();
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
int attempts = 20;
|
||||
int port = -1;
|
||||
String s = System.getProperty("jetty.port.file");
|
||||
Assert.assertNotNull(s);
|
||||
File f = new File(s);
|
||||
while (true)
|
||||
{
|
||||
if (f.exists())
|
||||
{
|
||||
try (FileReader r = new FileReader(f);
|
||||
LineNumberReader lnr = new LineNumberReader(r);
|
||||
)
|
||||
{
|
||||
s = lnr.readLine();
|
||||
Assert.assertNotNull(s);
|
||||
port = Integer.parseInt(s.trim());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--attempts < 0)
|
||||
break;
|
||||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
|
@ -16,8 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.its.jetty_run_war_exploded_mojo_it;
|
||||
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -30,12 +29,14 @@ import org.junit.Test;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
public class TestGetContent
|
||||
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
int port = getPort();
|
||||
Assert.assertTrue(port > 0);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
@ -57,6 +58,7 @@ public class TestHelloServlet
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -86,8 +88,7 @@ public class TestHelloServlet
|
|||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestGetContent
|
||||
|
||||
{
|
||||
@Test
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
int port = getPort();
|
||||
Assert.assertTrue(port > 0);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
int attempts = 20;
|
||||
int port = -1;
|
||||
String s = System.getProperty("jetty.port.file");
|
||||
Assert.assertNotNull(s);
|
||||
File f = new File(s);
|
||||
while (true)
|
||||
{
|
||||
if (f.exists())
|
||||
{
|
||||
try (FileReader r = new FileReader(f);
|
||||
LineNumberReader lnr = new LineNumberReader(r);
|
||||
)
|
||||
{
|
||||
s = lnr.readLine();
|
||||
Assert.assertNotNull(s);
|
||||
port = Integer.parseInt(s.trim());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--attempts < 0)
|
||||
break;
|
||||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestGetContent
|
||||
|
||||
{
|
||||
@Test
|
||||
public void get_ping_response()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
int port = getPort();
|
||||
Assert.assertTrue(port > 0);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
int attempts = 20;
|
||||
int port = -1;
|
||||
String s = System.getProperty("jetty.port.file");
|
||||
Assert.assertNotNull(s);
|
||||
File f = new File(s);
|
||||
while (true)
|
||||
{
|
||||
if (f.exists())
|
||||
{
|
||||
try (FileReader r = new FileReader(f);
|
||||
LineNumberReader lnr = new LineNumberReader(r);
|
||||
)
|
||||
{
|
||||
s = lnr.readLine();
|
||||
Assert.assertNotNull(s);
|
||||
port = Integer.parseInt(s.trim());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--attempts < 0)
|
||||
break;
|
||||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.its.jetty_start_mojo_it;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = getPort();
|
||||
Assert.assertTrue(port > 0);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
public int getPort()
|
||||
throws Exception
|
||||
{
|
||||
int attempts = 20;
|
||||
int port = -1;
|
||||
String s = System.getProperty("jetty.port.file");
|
||||
Assert.assertNotNull(s);
|
||||
File f = new File(s);
|
||||
while (true)
|
||||
{
|
||||
if (f.exists())
|
||||
{
|
||||
try (FileReader r = new FileReader(f);
|
||||
LineNumberReader lnr = new LineNumberReader(r);
|
||||
)
|
||||
{
|
||||
s = lnr.readLine();
|
||||
Assert.assertNotNull(s);
|
||||
port = Integer.parseInt(s.trim());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (--attempts < 0)
|
||||
break;
|
||||
else
|
||||
Thread.currentThread().sleep(100);
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue