diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java deleted file mode 100644 index 089315d0e9f5c..0000000000000 --- a/core/camel-core/src/test/java/org/apache/camel/impl/TypeConverterRegistryPerformanceTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.camel.impl; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.w3c.dom.Document; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.util.StopWatch; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class TypeConverterRegistryPerformanceTest extends ContextTestSupport { - - private final int inner = 10; - - private CountDownLatch latch; - - @Test - public void testManual() { - // noop - } - - public void disbledtestPerformance() throws Exception { - // force converter to be loaded on startup - Document dom = context.getTypeConverter().convertTo(Document.class, "World"); - assertNotNull(dom); - - StopWatch watch = new StopWatch(); - - int size = 20000; - latch = new CountDownLatch(size); - int pool = 100; - ExecutorService executorService = Executors.newFixedThreadPool(pool); - - for (int i = 0; i < size; i++) { - executorService.submit(new Runnable() { - @Override - public void run() { - for (int j = 0; j < inner; j++) { - Document dom = context.getTypeConverter().convertTo(Document.class, "World"); - assertNotNull(dom); - } - latch.countDown(); - } - }); - } - - assertTrue(latch.await(2, TimeUnit.MINUTES), "Should all work"); - log.info("Took {}", watch.taken()); - - executorService.shutdownNow(); - } - - @Override - public boolean isUseRouteBuilder() { - return false; - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/language/TokenPairIteratorSplitChoicePerformanceManualTest.java b/core/camel-core/src/test/java/org/apache/camel/language/TokenPairIteratorSplitChoicePerformanceManualTest.java deleted file mode 100644 index e43a5a0a64b43..0000000000000 --- a/core/camel-core/src/test/java/org/apache/camel/language/TokenPairIteratorSplitChoicePerformanceManualTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.camel.language; - -import java.io.OutputStream; -import java.nio.file.Files; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.NotifyBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.util.StopWatch; -import org.apache.camel.util.TimeUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * - */ -@Disabled("Test manually") -public class TokenPairIteratorSplitChoicePerformanceManualTest extends ContextTestSupport { - - private final int size = 20 * 1000; - private final AtomicInteger tiny = new AtomicInteger(); - private final AtomicInteger small = new AtomicInteger(); - private final AtomicInteger med = new AtomicInteger(); - private final AtomicInteger large = new AtomicInteger(); - private final StopWatch watch = new StopWatch(); - - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - createDataFile(log, size); - } - - @Test - public void testTokenPairPerformanceRoute() { - NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create(); - - boolean matches = notify.matches(5, TimeUnit.MINUTES); - log.info("Processed file with {} elements in: {}", size, TimeUtils.printDuration(watch.taken(), true)); - - log.info("Processed {} tiny messages", tiny.get()); - log.info("Processed {} small messages", small.get()); - log.info("Processed {} medium messages", med.get()); - log.info("Processed {} large messages", large.get()); - - assertEquals((size / 10) * 4, tiny.get()); - assertEquals((size / 10) * 2, small.get()); - assertEquals((size / 10) * 3, med.get()); - assertEquals(size / 10, large.get()); - - assertTrue(matches, "Should complete route"); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - from(fileUri("?initialDelay=0&delay=10&noop=true")).process(new Processor() { - public void process(Exchange exchange) { - log.info("Starting to process file"); - watch.restart(); - } - }).split().tokenizeXML("order").streaming().choice().when().xpath("/order/amount < 10") - .process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("3"), xml); - - int num = tiny.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} tiny messages", num); - log.debug(xml); - } - } - }).when().xpath("/order/amount < 50").process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("44"), xml); - - int num = small.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} small messages: {}", num, xml); - log.debug(xml); - } - } - }).when().xpath("/order/amount < 100").process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("88"), xml); - - int num = med.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} medium messages", num); - log.debug(xml); - } - } - }).otherwise().process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("123"), xml); - - int num = large.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} large messages", num); - log.debug(xml); - } - } - }).end() // choice - .end(); // split - } - }; - } - - public void createDataFile(Logger log, int size) throws Exception { - log.info("Creating data file ..."); - - try (OutputStream fos = Files.newOutputStream(testFile("data.xml"))) { - fos.write("\n".getBytes()); - - for (int i = 0; i < size; i++) { - fos.write("\n".getBytes()); - fos.write((" " + i + "\n").getBytes()); - int num = i % 10; - if (num <= 3) { - fos.write(" 3\n".getBytes()); - fos.write(" 333\n".getBytes()); - } else if (num <= 5) { - fos.write(" 44\n".getBytes()); - fos.write(" 444\n".getBytes()); - } else if (num <= 8) { - fos.write(" 88\n".getBytes()); - fos.write(" 888\n".getBytes()); - } else { - fos.write(" 123\n".getBytes()); - fos.write(" 123123\n".getBytes()); - } - fos.write(" bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\n" - .getBytes()); - fos.write("\n".getBytes()); - } - - fos.write("".getBytes()); - } - - log.info("Creating data file done."); - } - -} diff --git a/core/camel-core/src/test/java/org/apache/camel/language/XPathSplitChoicePerformanceManualTest.java b/core/camel-core/src/test/java/org/apache/camel/language/XPathSplitChoicePerformanceManualTest.java deleted file mode 100644 index 65045598db586..0000000000000 --- a/core/camel-core/src/test/java/org/apache/camel/language/XPathSplitChoicePerformanceManualTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.camel.language; - -import java.io.OutputStream; -import java.nio.file.Files; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.NotifyBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.util.StopWatch; -import org.apache.camel.util.TimeUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * - */ -@Disabled("Test manually") -public class XPathSplitChoicePerformanceManualTest extends ContextTestSupport { - - private final int size = 20 * 1000; - private final AtomicInteger tiny = new AtomicInteger(); - private final AtomicInteger small = new AtomicInteger(); - private final AtomicInteger med = new AtomicInteger(); - private final AtomicInteger large = new AtomicInteger(); - private final StopWatch watch = new StopWatch(); - - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - createDataFile(log, size); - } - - @Test - public void testXPatPerformanceRoute() { - NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create(); - - boolean matches = notify.matches(60, TimeUnit.SECONDS); - log.info("Processed file with {} elements in: {}", size, TimeUtils.printDuration(watch.taken(), true)); - - log.info("Processed {} tiny messages", tiny.get()); - log.info("Processed {} small messages", small.get()); - log.info("Processed {} medium messages", med.get()); - log.info("Processed {} large messages", large.get()); - - assertEquals((size / 10) * 4, tiny.get()); - assertEquals((size / 10) * 2, small.get()); - assertEquals((size / 10) * 3, med.get()); - assertEquals(size / 10, large.get()); - - assertTrue(matches, "Should complete route"); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - from(fileUri("?initialDelay=0&delay=10&noop=true")).process(new Processor() { - public void process(Exchange exchange) { - log.info("Starting to process file"); - watch.restart(); - } - }).split().xpath("/orders/order").streaming().choice().when().xpath("/order/amount < 10") - .process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("3"), xml); - - int num = tiny.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} tiny messages", num); - log.debug(xml); - } - } - }).when().xpath("/order/amount < 50").process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("44"), xml); - - int num = small.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} small messages", num); - log.debug(xml); - } - } - }).when().xpath("/order/amount < 100").process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("88"), xml); - - int num = med.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} medium messages", num); - log.debug(xml); - } - } - }).otherwise().process(new Processor() { - public void process(Exchange exchange) { - String xml = exchange.getIn().getBody(String.class); - assertTrue(xml.contains("123"), xml); - - int num = large.incrementAndGet(); - if (num % 100 == 0) { - log.info("Processed {} large messages", num); - log.debug(xml); - } - } - }).end() // choice - .end(); // split - } - }; - } - - public void createDataFile(Logger log, int size) throws Exception { - - log.info("Creating data file ..."); - - try (OutputStream fos = Files.newOutputStream(testFile("data.xml"))) { - fos.write("\n".getBytes()); - - for (int i = 0; i < size; i++) { - fos.write("\n".getBytes()); - fos.write((" " + i + "\n").getBytes()); - int num = i % 10; - if (num <= 3) { - fos.write(" 3\n".getBytes()); - fos.write(" 333\n".getBytes()); - } else if (num <= 5) { - fos.write(" 44\n".getBytes()); - fos.write(" 444\n".getBytes()); - } else if (num <= 8) { - fos.write(" 88\n".getBytes()); - fos.write(" 888\n".getBytes()); - } else { - fos.write(" 123\n".getBytes()); - fos.write(" 123123\n".getBytes()); - } - fos.write(" bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla\n" - .getBytes()); - fos.write("\n".getBytes()); - } - - fos.write("".getBytes()); - } - - log.info("Creating data file done."); - } - -}