-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support RESTeasy 4.0 version in unit tests
* Split jaxrs-2.0 into jaxrs-2.0-common and jaxrs-2.0-testing (similar to e.g. play) * Support newest RESTEasy version in unit tests
- Loading branch information
mateuszrzeszutek
committed
Sep 1, 2020
1 parent
ecef123
commit 496c5ae
Showing
28 changed files
with
410 additions
and
181 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/jaxrs-2.0-common.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apply from: "$rootDir/gradle/instrumentation.gradle" | ||
|
||
muzzle { | ||
fail { | ||
group = "javax.ws.rs" | ||
module = "jsr311-api" | ||
versions = "[,]" | ||
} | ||
pass { | ||
group = "javax.ws.rs" | ||
module = "javax.ws.rs-api" | ||
versions = "[,]" | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...jaxrs-2.0/jaxrs-2.0-jersey-2.0/src/test/groovy/JerseyAnnotationInstrumentationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
class JerseyAnnotationInstrumentationTest extends JaxRsAnnotationsInstrumentationTest { | ||
} |
44 changes: 44 additions & 0 deletions
44
instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/src/test/groovy/JerseyFilterTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import static Resource.Test1 | ||
import static Resource.Test2 | ||
import static Resource.Test3 | ||
|
||
import io.dropwizard.testing.junit.ResourceTestRule | ||
import javax.ws.rs.client.Entity | ||
import javax.ws.rs.core.Response | ||
import org.junit.ClassRule | ||
import spock.lang.Shared | ||
|
||
class JerseyFilterTest extends JaxRsFilterTest { | ||
@Shared | ||
@ClassRule | ||
ResourceTestRule resources = ResourceTestRule.builder() | ||
.addResource(new Test1()) | ||
.addResource(new Test2()) | ||
.addResource(new Test3()) | ||
.addProvider(simpleRequestFilter) | ||
.addProvider(prematchRequestFilter) | ||
.build() | ||
|
||
@Override | ||
def makeRequest(String url) { | ||
Response response = resources.client().target(url).request().post(Entity.text("")) | ||
|
||
return [response.readEntity(String), response.statusInfo.statusCode] | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...entation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/src/test/groovy/JerseyHttpServerTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import io.dropwizard.jetty.NonblockingServletHolder | ||
import org.eclipse.jetty.server.Server | ||
import org.eclipse.jetty.servlet.ServletContextHandler | ||
import org.glassfish.jersey.server.ResourceConfig | ||
import org.glassfish.jersey.servlet.ServletContainer | ||
|
||
class JerseyHttpServerTest extends JaxRsHttpServerTest<Server> { | ||
|
||
@Override | ||
Server startServer(int port) { | ||
def servlet = new ServletContainer(ResourceConfig.forApplicationClass(JaxRsTestApplication)) | ||
|
||
def handler = new ServletContextHandler(ServletContextHandler.SESSIONS) | ||
handler.setContextPath("/") | ||
handler.addServlet(new NonblockingServletHolder(servlet), "/*") | ||
|
||
def server = new Server(port) | ||
server.setHandler(handler) | ||
server.start() | ||
|
||
return server | ||
} | ||
|
||
@Override | ||
void stopServer(Server httpServer) { | ||
httpServer.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...s-2.0/jaxrs-2.0-resteasy-3.0/src/test/groovy/ResteasyAnnotationInstrumentationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
class ResteasyAnnotationInstrumentationTest extends JaxRsAnnotationsInstrumentationTest { | ||
} |
54 changes: 54 additions & 0 deletions
54
...entation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/src/test/groovy/ResteasyFilterTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import static Resource.Test1 | ||
import static Resource.Test2 | ||
import static Resource.Test3 | ||
|
||
import javax.ws.rs.core.MediaType | ||
import org.jboss.resteasy.mock.MockDispatcherFactory | ||
import org.jboss.resteasy.mock.MockHttpRequest | ||
import org.jboss.resteasy.mock.MockHttpResponse | ||
import spock.lang.Shared | ||
|
||
class ResteasyFilterTest extends JaxRsFilterTest { | ||
@Shared | ||
def dispatcher | ||
|
||
def setupSpec() { | ||
dispatcher = MockDispatcherFactory.createDispatcher() | ||
def registry = dispatcher.getRegistry() | ||
registry.addSingletonResource(new Test1()) | ||
registry.addSingletonResource(new Test2()) | ||
registry.addSingletonResource(new Test3()) | ||
|
||
dispatcher.getProviderFactory().register(simpleRequestFilter) | ||
dispatcher.getProviderFactory().register(prematchRequestFilter) | ||
} | ||
|
||
@Override | ||
def makeRequest(String url) { | ||
MockHttpRequest request = MockHttpRequest.post(url) | ||
request.contentType(MediaType.TEXT_PLAIN_TYPE) | ||
request.content(new byte[0]) | ||
|
||
MockHttpResponse response = new MockHttpResponse() | ||
dispatcher.invoke(request, response) | ||
|
||
return [response.contentAsString, response.status] | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...tion/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.0/src/test/groovy/ResteasyHttpServerTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import io.undertow.Undertow | ||
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer | ||
|
||
class ResteasyHttpServerTest extends JaxRsHttpServerTest<UndertowJaxrsServer> { | ||
|
||
@Override | ||
UndertowJaxrsServer startServer(int port) { | ||
def server = new UndertowJaxrsServer() | ||
server.deploy(JaxRsTestApplication) | ||
server.start(Undertow.builder() | ||
.addHttpListener(port, "localhost")) | ||
return server | ||
} | ||
|
||
@Override | ||
void stopServer(UndertowJaxrsServer server) { | ||
server.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...s-2.0/jaxrs-2.0-resteasy-3.1/src/test/groovy/ResteasyAnnotationInstrumentationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
class ResteasyAnnotationInstrumentationTest extends JaxRsAnnotationsInstrumentationTest { | ||
} |
54 changes: 54 additions & 0 deletions
54
...entation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/src/test/groovy/ResteasyFilterTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import static Resource.Test1 | ||
import static Resource.Test2 | ||
import static Resource.Test3 | ||
|
||
import javax.ws.rs.core.MediaType | ||
import org.jboss.resteasy.mock.MockDispatcherFactory | ||
import org.jboss.resteasy.mock.MockHttpRequest | ||
import org.jboss.resteasy.mock.MockHttpResponse | ||
import spock.lang.Shared | ||
|
||
class ResteasyFilterTest extends JaxRsFilterTest { | ||
@Shared | ||
def dispatcher | ||
|
||
def setupSpec() { | ||
dispatcher = MockDispatcherFactory.createDispatcher() | ||
def registry = dispatcher.getRegistry() | ||
registry.addSingletonResource(new Test1()) | ||
registry.addSingletonResource(new Test2()) | ||
registry.addSingletonResource(new Test3()) | ||
|
||
dispatcher.getProviderFactory().register(simpleRequestFilter) | ||
dispatcher.getProviderFactory().register(prematchRequestFilter) | ||
} | ||
|
||
@Override | ||
def makeRequest(String url) { | ||
MockHttpRequest request = MockHttpRequest.post(url) | ||
request.contentType(MediaType.TEXT_PLAIN_TYPE) | ||
request.content(new byte[0]) | ||
|
||
MockHttpResponse response = new MockHttpResponse() | ||
dispatcher.invoke(request, response) | ||
|
||
return [response.contentAsString, response.status] | ||
} | ||
|
||
} |
Oops, something went wrong.