This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6ac1006f12564d3f56572b104a9f879d21272386 Author: Vladimir V. Bychkov <[email protected]> AuthorDate: Thu Aug 4 17:47:52 2022 +0200 Assumptions with comment instead of if-return --- .../camel/component/crypto/ECDSASignatureTest.java | 5 ++--- .../camel/component/crypto/SignatureTest.java | 6 ++---- .../camel/component/jetty/HttpsAsyncRouteTest.java | 17 +++++---------- .../JettyRouteWithUnknownSocketPropertiesTest.java | 6 ++---- ...ttyRouteWithUnknownSslSocketPropertiesTest.java | 6 ++---- .../component/jms/tuning/PerformanceRouteTest.java | 5 ++--- .../salesforce/CompositeApiIntegrationTest.java | 6 +++--- .../xpath/XPathLanguageDefaultSettingsTest.java | 5 ++--- .../camel/language/xpath/XPathLanguageTest.java | 25 ++++++---------------- .../component/servlet/HttpClientRouteTest.java | 6 ++---- .../component/xmlsecurity/ECDSASignatureTest.java | 25 ++++++---------------- .../xmlsecurity/EncryptionAlgorithmTest.java | 15 ++++++------- .../processor/SplitterParallelAggregateTest.java | 14 +++++------- .../SplitterWithScannerIoExceptionTest.java | 7 +++--- .../apache/camel/processor/ThrottlerDslTest.java | 5 ++--- .../camel/processor/ThrottlerMethodCallTest.java | 5 ++--- .../org/apache/camel/processor/ThrottlerTest.java | 21 ++++++------------ .../processor/ThrottlerThreadPoolProfileTest.java | 6 +++--- .../management/ManagedPooledExchangeTest.java | 5 ++--- .../ManagedRouteStopWithAbortAfterTimeoutTest.java | 11 +++++----- .../camel/management/ManagedThrottlerTest.java | 15 +++---------- 21 files changed, 74 insertions(+), 142 deletions(-) diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java index 9da9614496c..9015c6a8c72 100644 --- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java +++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/ECDSASignatureTest.java @@ -36,6 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.apache.camel.test.junit5.TestSupport.isJavaVendor; +import static org.junit.jupiter.api.Assumptions.assumeFalse; public class ECDSASignatureTest extends CamelTestSupport { @@ -94,9 +95,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test void testECDSASHA1() throws Exception { - if (ibmJDK || !canRun) { - return; - } + assumeFalse(ibmJDK || !canRun, "Test preconditions failed: ibmJDK=" + ibmJDK + ", canRun=" + canRun); setupMock(); sendBody("direct:ecdsa-sha1", payload); diff --git a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java index 8eaaf1feb50..1d6c2f39841 100644 --- a/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java +++ b/components/camel-crypto/src/test/java/org/apache/camel/component/crypto/SignatureTest.java @@ -47,6 +47,7 @@ import static org.apache.camel.component.crypto.DigitalSignatureConstants.SIGNAT import static org.apache.camel.test.junit5.TestSupport.isJavaVendor; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assumptions.assumeFalse; public class SignatureTest extends CamelTestSupport { @@ -242,10 +243,7 @@ public class SignatureTest extends CamelTestSupport { @Test void testSetProviderInRouteDefinition() throws Exception { - if (isJavaVendor("ibm")) { - return; - } - // can only be run on SUN JDK + assumeFalse(isJavaVendor("ibm"), "can only be run on SUN JDK"); setupMock(); sendBody("direct:provider", payload); assertMockEndpointsSatisfied(); diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java index 50297e7f2f5..9d663b59922 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java @@ -46,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeFalse; @ResourceLock(SSL_SYSPROPS) public class HttpsAsyncRouteTest extends HttpsRouteTest { @@ -94,9 +95,7 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest { @Test public void testEndpoint() throws Exception { // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("windows"), "Test is not intended for windows"); MockEndpoint mockEndpointA = resolveMandatoryEndpoint("mock:a", MockEndpoint.class); mockEndpointA.expectedBodiesReceived(expectedBody); @@ -125,9 +124,7 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest { @Test public void testEndpointWithoutHttps() { // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("windows"), "Test is not intended for windows"); MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class); try { @@ -142,9 +139,7 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest { @Test public void testHelloEndpoint() throws Exception { // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("windows"), "Test is not intended for windows"); ByteArrayOutputStream os = new ByteArrayOutputStream(); URL url = new URL("https://localhost:" + port1 + "/hello"); @@ -166,9 +161,7 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest { @Test public void testHelloEndpointWithoutHttps() throws Exception { // these tests does not run well on Windows - if (isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("windows"), "Test is not intended for windows"); try { new URL("http://localhost:" + port1 + "/hello").openStream(); diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSocketPropertiesTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSocketPropertiesTest.java index 2678731df73..59fedfa1e66 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSocketPropertiesTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSocketPropertiesTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class JettyRouteWithUnknownSocketPropertiesTest extends BaseJettyTest { @@ -36,10 +37,7 @@ public class JettyRouteWithUnknownSocketPropertiesTest extends BaseJettyTest { @Test public void testUnknownProperty() throws Exception { - if (!Server.getVersion().startsWith("8")) { - // SocketConnector props do not work for jetty 9 - return; - } + assumeTrue(Server.getVersion().startsWith("8"), "SocketConnector props do not work for jetty 9"); context.addRoutes(new RouteBuilder() { @Override public void configure() { diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSslSocketPropertiesTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSslSocketPropertiesTest.java index b0435e66aaf..2b44b1897a8 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSslSocketPropertiesTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteWithUnknownSslSocketPropertiesTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class JettyRouteWithUnknownSslSocketPropertiesTest extends BaseJettyTest { @@ -36,10 +37,7 @@ public class JettyRouteWithUnknownSslSocketPropertiesTest extends BaseJettyTest @Test public void testUnknownProperty() throws Exception { - if (!Server.getVersion().startsWith("8")) { - // SocketConnector props do not work for jetty 9 - return; - } + assumeTrue(Server.getVersion().startsWith("8"), "SocketConnector props do not work for jetty 9"); context.addRoutes(new RouteBuilder() { @Override public void configure() { diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java index 6b15a2bc9ef..4cb465d509a 100644 --- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/tuning/PerformanceRouteTest.java @@ -28,6 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; +import static org.junit.jupiter.api.Assumptions.assumeTrue; @Disabled public class PerformanceRouteTest extends CamelTestSupport { @@ -36,9 +37,7 @@ public class PerformanceRouteTest extends CamelTestSupport { @Test public void testPerformance() throws Exception { - if (!canRunOnThisPlatform()) { - return; - } + assumeTrue(canRunOnThisPlatform(), "Test is not intended for this platform"); long start = System.currentTimeMillis(); diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompositeApiIntegrationTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompositeApiIntegrationTest.java index 0623e254922..8fbc215081b 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompositeApiIntegrationTest.java +++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompositeApiIntegrationTest.java @@ -43,6 +43,8 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import static org.junit.jupiter.api.Assumptions.assumeFalse; + @Parameterized public class CompositeApiIntegrationTest extends AbstractSalesforceTestBase { @@ -206,9 +208,7 @@ public class CompositeApiIntegrationTest extends AbstractSalesforceTestBase { @Test public void shouldSupportRelatedObjectRetrieval() { - if (Version.create(version).compareTo(Version.create("36.0")) < 0) { - return; - } + assumeFalse(Version.create(version).compareTo(Version.create("36.0")) < 0, "Version must be less than 36.0"); final SObjectComposite composite = new SObjectComposite("36.0", true); composite.addGetRelated("Account", accountId, "CreatedBy", "GetRelatedAccountReferenceId"); diff --git a/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageDefaultSettingsTest.java b/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageDefaultSettingsTest.java index 95cd2eb7683..6e81adf4a1c 100644 --- a/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageDefaultSettingsTest.java +++ b/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageDefaultSettingsTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.parallel.Resources; import org.springframework.context.support.AbstractXmlApplicationContext; import static org.apache.camel.test.junit5.TestSupport.isJavaVendor; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * Tests that verify the usage of default settings in the XPath language by declaring a bean called xpath in the @@ -71,9 +72,7 @@ public class XPathLanguageDefaultSettingsTest extends CamelSpringTestSupport { @Test public void testSpringDSLXPathLanguageDefaultSettings() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpointResult = getMockEndpoint("mock:testDefaultXPathSettingsResult"); MockEndpoint mockEndpointException = getMockEndpoint("mock:testDefaultXPathSettingsResultException"); diff --git a/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageTest.java b/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageTest.java index 12cb98deea1..7f5bbe9679b 100644 --- a/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageTest.java +++ b/components/camel-saxon/src/test/java/org/apache/camel/language/xpath/XPathLanguageTest.java @@ -31,6 +31,7 @@ import org.springframework.context.support.AbstractXmlApplicationContext; import static org.apache.camel.test.junit5.TestSupport.isJavaVendor; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * @@ -73,9 +74,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Test public void testSpringDSLXPathSaxonFlag() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithFlagResult"); mockEndpoint.expectedMessageCount(1); @@ -90,9 +89,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Test public void testSpringDSLXPathFactory() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithFactoryResult"); mockEndpoint.expectedMessageCount(1); @@ -108,9 +105,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Disabled("See http://www.saxonica.com/documentation/index.html#!xpath-api/jaxp-xpath/factory") @Test public void testSpringDSLXPathObjectModel() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithObjectModelResult"); mockEndpoint.expectedMessageCount(1); @@ -125,9 +120,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Test public void testSpringDSLXPathSaxonFlagPredicate() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithFlagResultPredicate"); mockEndpoint.expectedMessageCount(1); @@ -139,9 +132,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Test public void testSpringDSLXPathFactoryPredicate() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithFactoryResultPredicate"); mockEndpoint.expectedMessageCount(1); @@ -154,9 +145,7 @@ public class XPathLanguageTest extends CamelSpringTestSupport { @Disabled("See http://www.saxonica.com/documentation/index.html#!xpath-api/jaxp-xpath/factory") @Test public void testSpringDSLXPathObjectModelPredicate() throws Exception { - if (!jvmAdequate) { - return; - } + assumeTrue(jvmAdequate, "JVM is not adequate"); MockEndpoint mockEndpoint = getMockEndpoint("mock:testSaxonWithObjectModelResultPredicate"); mockEndpoint.expectedMessageCount(1); diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java index e159e79ea8c..4636a6298c1 100644 --- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java +++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java @@ -31,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class HttpClientRouteTest extends ServletCamelRouterTestSupport { @@ -113,10 +114,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport { @Test public void testCreateSerlvetEndpointProducer() throws Exception { - if (!startCamelContext) { - // don't test it with web.xml configure - return; - } + assumeTrue(startCamelContext, "don't test it with web.xml configure"); try { context.addRoutes(new RouteBuilder() { @Override diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java index 981f95539b1..9611f3ae912 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/ECDSASignatureTest.java @@ -46,6 +46,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.apache.camel.test.junit5.TestSupport.isJavaVendor; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * Test for the ECDSA algorithms @@ -178,9 +179,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSASHA1() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_sha1", payload); assertMockEndpointsSatisfied(); @@ -188,9 +187,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSASHA224() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_sha224", payload); assertMockEndpointsSatisfied(); @@ -198,9 +195,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSASHA256() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_sha256", payload); assertMockEndpointsSatisfied(); @@ -208,9 +203,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSASHA384() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_sha384", payload); assertMockEndpointsSatisfied(); @@ -218,9 +211,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSASHA512() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_sha512", payload); assertMockEndpointsSatisfied(); @@ -228,9 +219,7 @@ public class ECDSASignatureTest extends CamelTestSupport { @Test public void testECDSARIPEMD160() throws Exception { - if (!canTest) { - return; - } + assumeTrue(canTest, "Test preconditions failed: canTest="+canTest); setupMock(); sendBody("direct:ecdsa_ripemd160", payload); assertMockEndpointsSatisfied(); diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/EncryptionAlgorithmTest.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/EncryptionAlgorithmTest.java index 27284526fdc..d4a7e377f75 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/EncryptionAlgorithmTest.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/EncryptionAlgorithmTest.java @@ -32,6 +32,8 @@ import org.apache.xml.security.encryption.XMLCipher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + /** * Test all available encryption algorithms */ @@ -113,9 +115,7 @@ public class EncryptionAlgorithmTest extends CamelTestSupport { @Test public void testAES192() throws Exception { - if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) { - return; - } + assumeTrue(TestHelper.UNRESTRICTED_POLICIES_INSTALLED, "Test preconditions failed: UNRESTRICTED_POLICIES_INSTALLED="+TestHelper.UNRESTRICTED_POLICIES_INSTALLED); // Set up the Key KeyGenerator keygen = KeyGenerator.getInstance("AES"); @@ -141,9 +141,7 @@ public class EncryptionAlgorithmTest extends CamelTestSupport { @Test public void testAES192GCM() throws Exception { - if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) { - return; - } + assumeTrue(TestHelper.UNRESTRICTED_POLICIES_INSTALLED, "Test preconditions failed: UNRESTRICTED_POLICIES_INSTALLED="+TestHelper.UNRESTRICTED_POLICIES_INSTALLED); // Set up the Key KeyGenerator keygen = KeyGenerator.getInstance("AES"); @@ -169,9 +167,7 @@ public class EncryptionAlgorithmTest extends CamelTestSupport { @Test public void testAES256() throws Exception { - if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) { - return; - } + assumeTrue(TestHelper.UNRESTRICTED_POLICIES_INSTALLED, "Test preconditions failed: UNRESTRICTED_POLICIES_INSTALLED="+TestHelper.UNRESTRICTED_POLICIES_INSTALLED); // Set up the Key KeyGenerator keygen = KeyGenerator.getInstance("AES"); @@ -197,6 +193,7 @@ public class EncryptionAlgorithmTest extends CamelTestSupport { @Test public void testAES256GCM() throws Exception { + assumeTrue(TestHelper.UNRESTRICTED_POLICIES_INSTALLED, "Test preconditions failed: UNRESTRICTED_POLICIES_INSTALLED="+TestHelper.UNRESTRICTED_POLICIES_INSTALLED); if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) { return; } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterParallelAggregateTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterParallelAggregateTest.java index eb213a79ac3..c53860f778a 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterParallelAggregateTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterParallelAggregateTest.java @@ -31,6 +31,8 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.util.StopWatch; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + public class SplitterParallelAggregateTest extends ContextTestSupport { // run this test manually as it takes some time to process, but shows that @@ -56,27 +58,21 @@ public class SplitterParallelAggregateTest extends ContextTestSupport { @Test public void test1() throws Exception { - if (!enabled) { - return; - } + assumeTrue(enabled); int numberOfRequests = 1; timeSplitRoutes(numberOfRequests); } @Test public void test2() throws Exception { - if (!enabled) { - return; - } + assumeTrue(enabled); int numberOfRequests = 2; timeSplitRoutes(numberOfRequests); } @Test public void test4() throws Exception { - if (!enabled) { - return; - } + assumeTrue(enabled); int numberOfRequests = 4; timeSplitRoutes(numberOfRequests); } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithScannerIoExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithScannerIoExceptionTest.java index 4c10a147e1d..2b75ad6ca44 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithScannerIoExceptionTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithScannerIoExceptionTest.java @@ -20,13 +20,14 @@ import org.apache.camel.ContextTestSupport; import org.apache.camel.builder.RouteBuilder; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assumptions.assumeFalse; + public class SplitterWithScannerIoExceptionTest extends ContextTestSupport { @Test public void testSplitterStreamingWithError() throws Exception { - if (isPlatform("aix") || isJavaVendor("ibm")) { - return; - } + assumeFalse(isPlatform("aix")); + assumeFalse(isJavaVendor("ibm")); getMockEndpoint("mock:a").expectedMinimumMessageCount(250); getMockEndpoint("mock:b").expectedMessageCount(0); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java index cba3c41a97b..58bbf9e804f 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java @@ -25,6 +25,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ThrottlerDslTest extends ContextTestSupport { private static final int INTERVAL = 500; @@ -37,9 +38,7 @@ public class ThrottlerDslTest extends ContextTestSupport { @Test public void testDsl() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(messageCount); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java index c1033c7b651..5f5bec2f9fa 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java @@ -27,6 +27,7 @@ import org.apache.camel.util.StopWatch; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ThrottlerMethodCallTest extends ContextTestSupport { private static final int INTERVAL = 100; @@ -50,9 +51,7 @@ public class ThrottlerMethodCallTest extends ContextTestSupport { @Test public void testConfigurationWithMethodCallExpression() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(messageCount); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java index b7ff7210bd7..4fb2ef498fd 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java @@ -26,6 +26,7 @@ import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ThrottlerTest extends ContextTestSupport { private static final int INTERVAL = 500; @@ -39,9 +40,7 @@ public class ThrottlerTest extends ContextTestSupport { @Test public void testSendLotsOfMessagesButOnly3GetThroughWithin2Seconds() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(3); @@ -58,9 +57,7 @@ public class ThrottlerTest extends ContextTestSupport { @Test public void testSendLotsOfMessagesWithRejectExecution() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(2); @@ -79,9 +76,7 @@ public class ThrottlerTest extends ContextTestSupport { @Test public void testSendLotsOfMessagesSimultaneouslyButOnly3GetThrough() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); long elapsed = sendMessagesAndAwaitDelivery(MESSAGE_COUNT, "direct:a", MESSAGE_COUNT, resultEndpoint); @@ -90,9 +85,7 @@ public class ThrottlerTest extends ContextTestSupport { @Test public void testConfigurationWithConstantExpression() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); long elapsed = sendMessagesAndAwaitDelivery(MESSAGE_COUNT, "direct:expressionConstant", MESSAGE_COUNT, resultEndpoint); @@ -101,9 +94,7 @@ public class ThrottlerTest extends ContextTestSupport { @Test public void testConfigurationWithHeaderExpression() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(MESSAGE_COUNT); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java index 5a2143f3664..f9eabec6404 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerThreadPoolProfileTest.java @@ -22,6 +22,8 @@ import org.apache.camel.builder.ThreadPoolProfileBuilder; import org.apache.camel.spi.ThreadPoolProfile; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + public class ThrottlerThreadPoolProfileTest extends ContextTestSupport { protected boolean canTest() { @@ -31,9 +33,7 @@ public class ThrottlerThreadPoolProfileTest extends ContextTestSupport { @Test public void testThreadPool() throws Exception { - if (!canTest()) { - return; - } + assumeTrue(canTest()); getMockEndpoint("mock:result").expectedMessageCount(2); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java index 718e8198114..5ad42df0a89 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java @@ -37,6 +37,7 @@ import org.junit.jupiter.api.condition.OS; import static org.apache.camel.management.DefaultManagementObjectNameStrategy.TYPE_SERVICE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assumptions.assumeFalse; @DisabledOnOs(OS.AIX) public class ManagedPooledExchangeTest extends ManagementTestSupport { @@ -59,9 +60,7 @@ public class ManagedPooledExchangeTest extends ManagementTestSupport { @Test public void testSameExchange() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) - if (isPlatform("aix")) { - return; - } + assumeFalse(isPlatform("aix")); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(3); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteStopWithAbortAfterTimeoutTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteStopWithAbortAfterTimeoutTest.java index e4c731ec6b5..d8f4a4573b5 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteStopWithAbortAfterTimeoutTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedRouteStopWithAbortAfterTimeoutTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.api.condition.OS; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; @DisabledOnOs(OS.AIX) public class ManagedRouteStopWithAbortAfterTimeoutTest extends ManagementTestSupport { @@ -40,9 +41,8 @@ public class ManagedRouteStopWithAbortAfterTimeoutTest extends ManagementTestSup @Test public void testStopRouteWithAbortAfterTimeoutTrue() throws Exception { // JMX tests dont work well on AIX or windows CI servers (hangs them) - if (isPlatform("aix") || isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("aix")); + assumeFalse(isPlatform("windows")); MockEndpoint mockEP = getMockEndpoint("mock:result"); mockEP.setExpectedMessageCount(10); @@ -82,9 +82,8 @@ public class ManagedRouteStopWithAbortAfterTimeoutTest extends ManagementTestSup @Test public void testStopRouteWithAbortAfterTimeoutFalse() throws Exception { // JMX tests dont work well on AIX or windows CI servers (hangs them) - if (isPlatform("aix") || isPlatform("windows")) { - return; - } + assumeFalse(isPlatform("aix")); + assumeFalse(isPlatform("windows")); MockEndpoint mockEP = getMockEndpoint("mock:result"); diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java index f9cfa6acc83..93d337f298b 100644 --- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java +++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedThrottlerTest.java @@ -113,10 +113,7 @@ public class ManagedThrottlerTest extends ManagementTestSupport { public void testThrottleVisableViaJmx() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) assumeFalse(isPlatform("aix")); - if (isPlatform("windows")) { - // windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests - return; - } + assumeFalse(isPlatform("windows")); // get the stats for the route MBeanServer mbeanServer = getMBeanServer(); @@ -146,10 +143,7 @@ public class ManagedThrottlerTest extends ManagementTestSupport { public void testThrottleAsyncVisableViaJmx() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) assumeFalse(isPlatform("aix")); - if (isPlatform("windows")) { - // windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests - return; - } + assumeFalse(isPlatform("windows")); // get the stats for the route MBeanServer mbeanServer = getMBeanServer(); @@ -181,10 +175,7 @@ public class ManagedThrottlerTest extends ManagementTestSupport { public void testThrottleAsyncExceptionVisableViaJmx() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) assumeFalse(isPlatform("aix")); - if (isPlatform("windows")) { - // windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests - return; - } + assumeFalse(isPlatform("windows")); // get the stats for the route MBeanServer mbeanServer = getMBeanServer();
