Skip to content

Commit 3974a96

Browse files
committed
Split test in 3
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent 5144956 commit 3974a96

File tree

3 files changed

+119
-60
lines changed

3 files changed

+119
-60
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
18+
package org.glassfish.jersey.tests.e2e.server;
19+
20+
import static org.junit.Assert.assertEquals;
21+
22+
import javax.ws.rs.GET;
23+
import javax.ws.rs.Path;
24+
import javax.ws.rs.core.Application;
25+
import javax.ws.rs.core.Response;
26+
27+
import org.glassfish.jersey.server.ResourceConfig;
28+
import org.glassfish.jersey.test.JerseyTest;
29+
import org.junit.Test;
30+
31+
public class Issue4780Resource1Test extends JerseyTest {
32+
33+
// 1 interface and 1 implementation having same @Path
34+
@Test
35+
public void resource1() throws Exception {
36+
Response response = target().path("/resource1").request().get();
37+
response.bufferEntity();
38+
assertEquals(response.readEntity(String.class), 200, response.getStatus());
39+
}
40+
41+
@Override
42+
protected Application configure() {
43+
return new ResourceConfig(Resource1_1.class, IResource1_2.class);
44+
}
45+
46+
@Path("")
47+
public static class Resource1_1 implements IResource1_2 {
48+
@GET
49+
@Path("/resource1")
50+
@Override
51+
public String get() {
52+
return "";
53+
}
54+
}
55+
56+
@Path("")
57+
public static interface IResource1_2 {
58+
@GET
59+
@Path("/resource1")
60+
String get();
61+
}
62+
63+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
18+
package org.glassfish.jersey.tests.e2e.server;
19+
20+
import javax.ws.rs.GET;
21+
import javax.ws.rs.Path;
22+
23+
import org.glassfish.jersey.server.ResourceConfig;
24+
import org.glassfish.jersey.server.model.ModelValidationException;
25+
import org.glassfish.jersey.test.JerseyTest;
26+
import org.junit.Test;
27+
28+
public class Issue4780Resource2Test {
29+
30+
// 2 interfaces having same @Path
31+
@Test(expected = ModelValidationException.class)
32+
public void resource2() throws Exception {
33+
JerseyTest test = new JerseyTest(new ResourceConfig(IResource2_1.class, IResource2_2.class)) {};
34+
try {
35+
test.setUp();
36+
} finally {
37+
test.tearDown();
38+
}
39+
}
40+
41+
@Path("")
42+
public static interface IResource2_1 {
43+
@GET
44+
@Path("/resource2")
45+
String get();
46+
}
47+
48+
@Path("")
49+
public static interface IResource2_2 {
50+
@GET
51+
@Path("/resource2")
52+
String get();
53+
}
54+
55+
}

tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4780Test.java renamed to tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4780Resource3Test.java

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,15 @@
1717

1818
package org.glassfish.jersey.tests.e2e.server;
1919

20-
import static org.junit.Assert.assertEquals;
21-
2220
import javax.ws.rs.GET;
2321
import javax.ws.rs.Path;
24-
import javax.ws.rs.core.Response;
2522

2623
import org.glassfish.jersey.server.ResourceConfig;
2724
import org.glassfish.jersey.server.model.ModelValidationException;
2825
import org.glassfish.jersey.test.JerseyTest;
2926
import org.junit.Test;
3027

31-
public class Issue4780Test {
32-
33-
// 1 interface and 1 implementation having same @Path
34-
@Test
35-
public void resource1() throws Exception {
36-
JerseyTest test = new JerseyTest(new ResourceConfig(Resource1_1.class, IResource1_2.class)) {};
37-
try {
38-
test.setUp();
39-
Response response = test.target().path("/resource1").request().get();
40-
response.bufferEntity();
41-
assertEquals(response.readEntity(String.class), 200, response.getStatus());
42-
} finally {
43-
test.tearDown();
44-
}
45-
}
46-
47-
// 2 interfaces having same @Path
48-
@Test(expected = ModelValidationException.class)
49-
public void resource2() throws Exception {
50-
JerseyTest test = new JerseyTest(new ResourceConfig(IResource2_1.class, IResource2_2.class)) {};
51-
try {
52-
test.setUp();
53-
} finally {
54-
test.tearDown();
55-
}
56-
}
28+
public class Issue4780Resource3Test {
5729

5830
// 2 classes having same @Path
5931
@Test(expected = ModelValidationException.class)
@@ -66,37 +38,6 @@ public void resource3() throws Exception {
6638
}
6739
}
6840

69-
@Path("")
70-
public static class Resource1_1 implements IResource1_2 {
71-
@GET
72-
@Path("/resource1")
73-
@Override
74-
public String get() {
75-
return "";
76-
}
77-
}
78-
79-
@Path("")
80-
public static interface IResource1_2 {
81-
@GET
82-
@Path("/resource1")
83-
String get();
84-
}
85-
86-
@Path("")
87-
public static interface IResource2_1 {
88-
@GET
89-
@Path("/resource2")
90-
String get();
91-
}
92-
93-
@Path("")
94-
public static interface IResource2_2 {
95-
@GET
96-
@Path("/resource2")
97-
String get();
98-
}
99-
10041
@Path("")
10142
public static class Resource3_1 {
10243
@GET

0 commit comments

Comments
 (0)