This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit c5cb4467ba3f1cab4cbd28d3890e51a87ae167c2 Author: Guillaume Nodet <[email protected]> AuthorDate: Mon Jul 27 12:18:23 2020 +0200 [CAMEL-11807] Upgrade camel-undertow-spring-security to junit5 --- components/camel-undertow-spring-security/pom.xml | 2 +- .../spring/security/AbstractSpringSecurityBearerTokenTest.java | 6 +++--- .../apache/camel/component/spring/security/NoTokenTest.java | 9 ++++++--- .../spring/security/SpringSecurityBearerTokenTest.java | 10 +++++++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/components/camel-undertow-spring-security/pom.xml b/components/camel-undertow-spring-security/pom.xml index a0728d4..b4c6e5b 100644 --- a/components/camel-undertow-spring-security/pom.xml +++ b/components/camel-undertow-spring-security/pom.xml @@ -61,7 +61,7 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/AbstractSpringSecurityBearerTokenTest.java b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/AbstractSpringSecurityBearerTokenTest.java index 2d5b68a..4fc1df2 100644 --- a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/AbstractSpringSecurityBearerTokenTest.java +++ b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/AbstractSpringSecurityBearerTokenTest.java @@ -33,8 +33,8 @@ import org.apache.camel.component.spring.security.keycloak.KeycloakRealmRoleConv import org.apache.camel.component.spring.security.keycloak.KeycloakUsernameSubClaimAdapter; import org.apache.camel.component.undertow.UndertowComponent; import org.apache.camel.test.AvailablePortFinder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.BeforeClass; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.BeforeAll; import org.springframework.security.oauth2.jwt.Jwt; public abstract class AbstractSpringSecurityBearerTokenTest extends CamelTestSupport { @@ -47,7 +47,7 @@ public abstract class AbstractSpringSecurityBearerTokenTest extends CamelTestSup return mockFilter; } - @BeforeClass + @BeforeAll public static void initPort() throws Exception { port = AvailablePortFinder.getNextAvailable(); } diff --git a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/NoTokenTest.java b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/NoTokenTest.java index 208f75d..1b77dbf 100644 --- a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/NoTokenTest.java +++ b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/NoTokenTest.java @@ -20,8 +20,11 @@ import io.undertow.util.StatusCodes; import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.http.base.HttpOperationFailedException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class NoTokenTest extends AbstractSpringSecurityBearerTokenTest { @@ -35,7 +38,7 @@ public class NoTokenTest extends AbstractSpringSecurityBearerTokenTest { template.requestBody("undertow:http://localhost:{{port}}/myapp", "empty body", String.class); - Assert.fail("Access has to be denied"); + fail("Access has to be denied"); } catch (CamelExecutionException e) { HttpOperationFailedException he = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause()); assertEquals(StatusCodes.FORBIDDEN, he.getStatusCode()); diff --git a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/SpringSecurityBearerTokenTest.java b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/SpringSecurityBearerTokenTest.java index 6080d84..2e2a19d 100644 --- a/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/SpringSecurityBearerTokenTest.java +++ b/components/camel-undertow-spring-security/src/test/java/org/apache/camel/component/spring/security/SpringSecurityBearerTokenTest.java @@ -20,8 +20,12 @@ import io.undertow.util.StatusCodes; import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.http.base.HttpOperationFailedException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; public class SpringSecurityBearerTokenTest extends AbstractSpringSecurityBearerTokenTest { @@ -46,7 +50,7 @@ public class SpringSecurityBearerTokenTest extends AbstractSpringSecurityBearerT template.requestBody("undertow:http://localhost:{{port}}/myapp", "empty body", String.class); - Assert.fail("Access is denied"); + fail("Access is denied"); } catch (CamelExecutionException e) { HttpOperationFailedException he = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause()); assertEquals(StatusCodes.FORBIDDEN, he.getStatusCode());
