File tree 3 files changed +36
-20
lines changed
spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test
3 files changed +36
-20
lines changed Original file line number Diff line number Diff line change 27
27
28
28
import static org .junit .Assert .assertEquals ;
29
29
import static org .junit .Assert .assertTrue ;
30
+ import static org .jboss .as .quickstarts .resteasyspring .test .TestUtils .getServerHost ;
30
31
31
32
/**
32
33
* The very basic runtime integration testing.
33
34
* @author liweinan
34
35
*/
35
36
public class BasicRuntimeIT {
36
37
37
- private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy/main" ;
38
-
39
38
@ Test
40
39
public void testHTTPEndpointIsAvailable () throws IOException , InterruptedException , URISyntaxException {
41
- String serverHost = System .getenv ("SERVER_HOST" );
42
- if (serverHost == null ) {
43
- serverHost = System .getProperty ("server.host" );
44
- }
45
- if (serverHost == null ) {
46
- serverHost = DEFAULT_SERVER_HOST ;
47
- }
48
40
final HttpRequest request = HttpRequest .newBuilder ()
49
- .uri (new URI (serverHost +"/" ))
41
+ .uri (new URI (getServerHost () +"/" ))
50
42
.GET ()
51
43
.build ();
52
44
final HttpClient client = HttpClient .newBuilder ()
Original file line number Diff line number Diff line change 33
33
import org .junit .Assert ;
34
34
import org .junit .BeforeClass ;
35
35
import org .junit .Test ;
36
+ import static org .jboss .as .quickstarts .resteasyspring .test .TestUtils .getServerHost ;
36
37
37
38
/**
38
39
* Basic unit tests for resteasy spring integration
@@ -42,18 +43,9 @@ public class ResteasySpringIT {
42
43
43
44
static URL url ;
44
45
45
- private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy/main" ;
46
-
47
46
@ BeforeClass
48
47
public static void setupUrl () throws MalformedURLException {
49
- String serverHost = System .getenv ("SERVER_HOST" );
50
- if (serverHost == null ) {
51
- serverHost = System .getProperty ("server.host" );
52
- }
53
- if (serverHost == null ) {
54
- serverHost = DEFAULT_SERVER_HOST ;
55
- }
56
- url = URI .create (serverHost ).toURL ();
48
+ url = URI .create (getServerHost ()).toURL ();
57
49
}
58
50
59
51
@ Test
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 JBoss by Red Hat.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package org .jboss .as .quickstarts .resteasyspring .test ;
17
+
18
+ public class TestUtils {
19
+ static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy" ;
20
+ static final String MAINPAGE_PATH = "/main" ;
21
+
22
+ static String getServerHost () {
23
+ String serverHost = System .getenv ("SERVER_HOST" );
24
+ if (serverHost == null ) {
25
+ serverHost = System .getProperty ("server.host" );
26
+ }
27
+ if (serverHost == null ) {
28
+ serverHost = DEFAULT_SERVER_HOST ;
29
+ }
30
+ return serverHost + MAINPAGE_PATH ;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments