File tree 2 files changed +22
-21
lines changed
instrumentation/tapestry-5.4/javaagent/src/test/java
testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http
2 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -31,33 +31,26 @@ class TapestryTest extends AbstractHttpServerUsingTest<Server> {
31
31
HttpServerInstrumentationExtension .forAgent ();
32
32
33
33
@ Override
34
- protected Server setupServer () {
34
+ protected Server setupServer () throws Exception {
35
35
WebAppContext webAppContext = new WebAppContext ();
36
36
webAppContext .setContextPath (getContextPath ());
37
37
Server jettyServer = new Server (port );
38
38
39
39
// set up test application
40
- try {
41
- webAppContext .setBaseResource (Resource .newResource ("src/test/webapp" ));
42
- for (Connector connector : jettyServer .getConnectors ()) {
43
- connector .setHost ("localhost" );
44
- }
45
-
46
- jettyServer .setHandler (webAppContext );
47
- jettyServer .start ();
48
- } catch (Exception e ) {
49
- throw new RuntimeException (e );
40
+ webAppContext .setBaseResource (Resource .newResource ("src/test/webapp" ));
41
+ for (Connector connector : jettyServer .getConnectors ()) {
42
+ connector .setHost ("localhost" );
50
43
}
44
+
45
+ jettyServer .setHandler (webAppContext );
46
+ jettyServer .start ();
47
+
51
48
return jettyServer ;
52
49
}
53
50
54
51
@ Override
55
- protected void stopServer (Server server ) {
56
- try {
57
- server .stop ();
58
- } catch (Exception e ) {
59
- throw new RuntimeException (e );
60
- }
52
+ protected void stopServer (Server server ) throws Exception {
53
+ server .stop ();
61
54
}
62
55
63
56
@ Override
Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ public abstract class AbstractHttpServerUsingTest<SERVER> {
27
27
public int port ;
28
28
public URI address ;
29
29
30
- protected abstract SERVER setupServer ();
30
+ protected abstract SERVER setupServer () throws Exception ;
31
31
32
- protected abstract void stopServer (SERVER server );
32
+ protected abstract void stopServer (SERVER server ) throws Exception ;
33
33
34
34
protected final InstrumentationTestRunner testing () {
35
35
return testing ;
@@ -40,7 +40,11 @@ protected void startServer() {
40
40
address = buildAddress ();
41
41
}
42
42
43
- server = setupServer ();
43
+ try {
44
+ server = setupServer ();
45
+ } catch (Exception exception ) {
46
+ throw new IllegalStateException ("Failed to start server" , exception );
47
+ }
44
48
if (server != null ) {
45
49
logger .info (
46
50
getClass ().getName ()
@@ -57,7 +61,11 @@ protected void cleanupServer() {
57
61
logger .info (getClass ().getName () + " can't stop null server" );
58
62
return ;
59
63
}
60
- stopServer (server );
64
+ try {
65
+ stopServer (server );
66
+ } catch (Exception exception ) {
67
+ throw new IllegalStateException ("Failed to stop server" , exception );
68
+ }
61
69
server = null ;
62
70
logger .info (getClass ().getName () + " http server stopped at: http://localhost:" + port + "/" );
63
71
}
You can’t perform that action at this time.
0 commit comments