Skip to content

Commit d5d27d5

Browse files
committed
Duplicate tests for Jakarta
1 parent 0ad3542 commit d5d27d5

File tree

6 files changed

+615
-9
lines changed

6 files changed

+615
-9
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
import java.io.InputStream;
2+
import java.io.IOException;
3+
import java.lang.annotation.Annotation;
4+
import java.lang.reflect.Type;
5+
import jakarta.ws.rs.GET;
6+
import jakarta.ws.rs.POST;
7+
import jakarta.ws.rs.DELETE;
8+
import jakarta.ws.rs.PUT;
9+
import jakarta.ws.rs.OPTIONS;
10+
import jakarta.ws.rs.HEAD;
11+
import jakarta.ws.rs.Path;
12+
import jakarta.ws.rs.BeanParam;
13+
import jakarta.ws.rs.CookieParam;
14+
import jakarta.ws.rs.FormParam;
15+
import jakarta.ws.rs.HeaderParam;
16+
import jakarta.ws.rs.MatrixParam;
17+
import jakarta.ws.rs.PathParam;
18+
import jakarta.ws.rs.Produces;
19+
import jakarta.ws.rs.QueryParam;
20+
import jakarta.ws.rs.client.Client;
21+
import jakarta.ws.rs.core.Context;
22+
import jakarta.ws.rs.core.MediaType;
23+
import jakarta.ws.rs.core.MultivaluedMap;
24+
import jakarta.ws.rs.core.Response;
25+
import jakarta.ws.rs.ext.MessageBodyReader;
26+
27+
@Path("")
28+
public class JakartaRs1 { // $RootResourceClass
29+
public JakartaRs1() { // $InjectableConstructor
30+
}
31+
32+
@GET
33+
int Get() { // $ResourceMethod $ResourceMethodOnResourceClass
34+
return 0; // $XssSink
35+
}
36+
37+
@POST
38+
void Post() { // $ResourceMethod $ResourceMethodOnResourceClass
39+
}
40+
41+
@Produces("text/plain") // $ProducesAnnotation=text/plain
42+
@DELETE
43+
double Delete() { // $ResourceMethod=text/plain $ResourceMethodOnResourceClass
44+
return 0.0; // $XssSink
45+
}
46+
47+
@Produces(MediaType.TEXT_HTML) // $ProducesAnnotation=text/html
48+
@PUT
49+
void Put() { // $ResourceMethod=text/html $ResourceMethodOnResourceClass
50+
}
51+
52+
@OPTIONS
53+
void Options() { // $ResourceMethod $ResourceMethodOnResourceClass
54+
}
55+
56+
@HEAD
57+
void Head() { // $ResourceMethod $ResourceMethodOnResourceClass
58+
}
59+
60+
@Path("")
61+
NonRootResourceClassJakarta subResourceLocator() { // $SubResourceLocator
62+
return null;
63+
}
64+
65+
public class NonRootResourceClassJakarta { // $NonRootResourceClass
66+
@GET
67+
int Get() { // $ResourceMethod $ResourceMethodOnResourceClass
68+
return 0; // $XssSink
69+
}
70+
71+
@Produces("text/html") // $ProducesAnnotation=text/html
72+
@POST
73+
boolean Post() { // $ResourceMethod=text/html $ResourceMethodOnResourceClass
74+
return false;
75+
}
76+
77+
@Produces(MediaType.TEXT_PLAIN) // $ProducesAnnotation=text/plain
78+
@DELETE
79+
double Delete() { // $ResourceMethod=text/plain $ResourceMethodOnResourceClass
80+
return 0.0; // $XssSink
81+
}
82+
83+
@Path("")
84+
AnotherNonRootResourceClassJakarta subResourceLocator1() { // $SubResourceLocator
85+
return null;
86+
}
87+
88+
@GET
89+
@Path("")
90+
NotAResourceClass1Jakarta NotASubResourceLocator1() { // $ResourceMethod $ResourceMethodOnResourceClass
91+
return null; // $XssSink
92+
}
93+
94+
@GET
95+
NotAResourceClass2Jakarta NotASubResourceLocator2() { // $ResourceMethod $ResourceMethodOnResourceClass
96+
return null; // $XssSink
97+
}
98+
99+
NotAResourceClass2Jakarta NotASubResourceLocator3() {
100+
return null;
101+
}
102+
}
103+
}
104+
105+
class AnotherNonRootResourceClassJakarta { // $NonRootResourceClass
106+
public AnotherNonRootResourceClassJakarta() {
107+
}
108+
109+
public AnotherNonRootResourceClassJakarta(@BeanParam int beanParam, @CookieParam("") int cookieParam, @FormParam("") int formParam, // $InjectionAnnotation
110+
@HeaderParam("") int headerParam, @MatrixParam("") int matrixParam, @PathParam("") int pathParam, @QueryParam("") int queryParam, // $InjectionAnnotation
111+
@Context int context) { // $InjectionAnnotation
112+
}
113+
114+
@Path("")
115+
public void resourceMethodWithBeanParamParameter(@BeanParam FooJakarta FooJakarta) { // $SubResourceLocator $InjectionAnnotation
116+
}
117+
}
118+
119+
class FooJakarta {
120+
FooJakarta() { // $BeanParamConstructor
121+
}
122+
123+
public FooJakarta(@BeanParam int beanParam, @CookieParam("") int cookieParam, @FormParam("") int formParam, // $InjectionAnnotation $BeanParamConstructor
124+
@HeaderParam("") int headerParam, @MatrixParam("") int matrixParam, @PathParam("") int pathParam, @QueryParam("") int queryParam, // $InjectionAnnotation
125+
@Context int context) { // $InjectionAnnotation
126+
}
127+
128+
public FooJakarta(@BeanParam int beanParam, @CookieParam("") int cookieParam, @FormParam("") int formParam, // $InjectionAnnotation
129+
@HeaderParam("") int headerParam, @MatrixParam("") int matrixParam, @PathParam("") int pathParam, @QueryParam("") int queryParam, // $InjectionAnnotation
130+
@Context int context, int paramWithoutAnnotation) { // $InjectionAnnotation
131+
}
132+
}
133+
134+
class NotAResourceClass1Jakarta {
135+
}
136+
137+
class NotAResourceClass2Jakarta {
138+
}
139+
140+
class ExtendsJakartaRs1 extends JakartaRs1 {
141+
@Override
142+
int Get() { // $ResourceMethod
143+
return 1;
144+
}
145+
146+
@Override
147+
@QueryParam("") // $InjectionAnnotation
148+
void Post() {
149+
}
150+
151+
@Override
152+
double Delete() { // $ResourceMethod=text/plain
153+
return 1.0;
154+
}
155+
156+
@Override
157+
void Put() { // $ResourceMethod=text/html
158+
}
159+
160+
@Produces("application/json") // $ProducesAnnotation=application/json
161+
@Override
162+
void Options() {
163+
}
164+
165+
@Produces(MediaType.TEXT_XML) // $ProducesAnnotation=text/xml
166+
@Override
167+
void Head() {
168+
}
169+
170+
}
171+
172+
@Produces(MediaType.TEXT_XML) // $ProducesAnnotation=text/xml
173+
class ExtendsJakartaRs1WithProducesAnnotation extends JakartaRs1 {
174+
@Override
175+
int Get() { // $ResourceMethod=text/xml
176+
return 2;
177+
}
178+
179+
@Override
180+
@QueryParam("") // $InjectionAnnotation
181+
void Post() {
182+
}
183+
184+
@Override
185+
double Delete() { // $ResourceMethod=text/plain
186+
return 2.0;
187+
}
188+
189+
@Override
190+
void Put() { // $ResourceMethod=text/html
191+
}
192+
193+
@Override
194+
void Options() { // $ResourceMethod=text/xml
195+
}
196+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import java.io.InputStream;
2+
import java.io.IOException;
3+
import java.lang.annotation.Annotation;
4+
import java.lang.reflect.Type;
5+
import jakarta.ws.rs.GET;
6+
import jakarta.ws.rs.POST;
7+
import jakarta.ws.rs.DELETE;
8+
import jakarta.ws.rs.PUT;
9+
import jakarta.ws.rs.OPTIONS;
10+
import jakarta.ws.rs.HEAD;
11+
import jakarta.ws.rs.Path;
12+
import jakarta.ws.rs.BeanParam;
13+
import jakarta.ws.rs.Consumes;
14+
import jakarta.ws.rs.CookieParam;
15+
import jakarta.ws.rs.FormParam;
16+
import jakarta.ws.rs.HeaderParam;
17+
import jakarta.ws.rs.MatrixParam;
18+
import jakarta.ws.rs.PathParam;
19+
import jakarta.ws.rs.QueryParam;
20+
import jakarta.ws.rs.client.Client;
21+
import jakarta.ws.rs.core.Context;
22+
import jakarta.ws.rs.core.MediaType;
23+
import jakarta.ws.rs.core.MultivaluedMap;
24+
import jakarta.ws.rs.core.Response;
25+
import jakarta.ws.rs.ext.MessageBodyReader;
26+
27+
@Path("")
28+
class JakartaRs2 { // $RootResourceClass
29+
JakartaRs2() {
30+
}
31+
32+
public JakartaRs2(@BeanParam int beanParam, @CookieParam("") int cookieParam, @FormParam("") int formParam, // $InjectionAnnotation $InjectableConstructor
33+
@HeaderParam("") int headerParam, @MatrixParam("") int matrixParam, @PathParam("") int pathParam, @QueryParam("") int queryParam, // $InjectionAnnotation
34+
@Context int context) { // $InjectionAnnotation
35+
}
36+
37+
public JakartaRs2(@BeanParam int beanParam, @CookieParam("") int cookieParam, @FormParam("") int formParam, // $InjectionAnnotation
38+
@HeaderParam("") int headerParam, @MatrixParam("") int matrixParam, @PathParam("") int pathParam, @QueryParam("") int queryParam, // $InjectionAnnotation
39+
@Context int context, int paramWithoutAnnotation) { // $InjectionAnnotation
40+
}
41+
42+
@BeanParam // $InjectionAnnotation
43+
int beanField; // $InjectableField
44+
@CookieParam("") // $InjectionAnnotation
45+
int cookieField; // $InjectableField
46+
@FormParam("") // $InjectionAnnotation
47+
int formField; // $InjectableField
48+
@HeaderParam("") // $InjectionAnnotation
49+
int headerField; // $InjectableField
50+
@MatrixParam("") // $InjectionAnnotation
51+
int matrixField; // $InjectableField
52+
@PathParam("") // $InjectionAnnotation
53+
int pathField; // $InjectableField
54+
@QueryParam("") // $InjectionAnnotation
55+
int queryField; // $InjectableField
56+
@Context // $InjectionAnnotation
57+
int context; // $InjectableField
58+
int fieldWithoutAnnotation;
59+
}
60+
61+
class CustomUnmarshallerJakarta implements MessageBodyReader {
62+
63+
@Override
64+
public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
65+
return true;
66+
}
67+
68+
69+
@Override
70+
public Object readFrom(Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, InputStream inputStream) {
71+
return null;
72+
}
73+
}
74+
75+
class MiscellaneousJakarta {
76+
@Consumes("") // $ConsumesAnnotation
77+
public static void miscellaneousJakarta() throws IOException {
78+
Response.ResponseBuilder responseBuilder = Response.accepted(); // $ResponseBuilderDeclaration
79+
Response response = responseBuilder.build(); // $ResponseDeclaration
80+
Client client; // $ClientDeclaration
81+
MessageBodyReader<String> messageBodyReader = null; // $MessageBodyReaderDeclaration
82+
messageBodyReader.readFrom(null, null, null, null, null, null); // $MessageBodyReaderReadFromCall $MessageBodyReaderReadCall
83+
CustomUnmarshallerJakarta CustomUnmarshallerJakarta = null;
84+
CustomUnmarshallerJakarta.readFrom(null, null, null, null, null, null); // $MessageBodyReaderReadCall
85+
}
86+
}

0 commit comments

Comments
 (0)