essobedo commented on code in PR #9266:
URL: https://github.com/apache/camel/pull/9266#discussion_r1091507790


##########
core/camel-core/src/test/java/org/apache/camel/component/bean/BeanChoseMethodWithMatchingTypeAndSkipSettersTest.java:
##########
@@ -37,8 +37,7 @@ protected Registry createRegistry() throws Exception {
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
-        CamelContext context = super.createCamelContext();
-        return context;
+        return super.createCamelContext();

Review Comment:
   This method does not need to be overridden at all



##########
core/camel-core/src/test/java/org/apache/camel/component/file/cluster/FileLockClusteredRoutePolicyFactoryTest.java:
##########
@@ -39,7 +38,7 @@
 
 public final class FileLockClusteredRoutePolicyFactoryTest {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(FileLockClusteredRoutePolicyFactoryTest.class);
-    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).collect(Collectors.toList());
+    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).toList();

Review Comment:
   Basically `List.of("0", "1", "2)`, right?



##########
core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDiscardWhenFullTest.java:
##########
@@ -36,10 +39,8 @@ public void testDiscardWhenFull() throws Exception {
         // start route
         context.getRouteController().startRoute("foo");
 
-        // wait until  at least 1 message has been consumed
-        while (mock.getReceivedCounter() < 1) {
-            Thread.sleep(100);
-        }
+        // wait until at least 1 message has been consumed
+        Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> 
mock.getReceivedCounter() >= 1);

Review Comment:
   ditto



##########
core/camel-core/src/test/java/org/apache/camel/impl/RefDataFormatTest.java:
##########
@@ -84,8 +84,7 @@ public void marshal(Exchange exchange, Object graph, 
OutputStream stream) throws
         @Override
         public Object unmarshal(Exchange exchange, InputStream stream) throws 
Exception {
             byte[] bytes = 
exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, 
stream);
-            String body = reverseBytes(bytes);
-            return body;
+            return reverseBytes(bytes);

Review Comment:
   ```suggestion
               return 
reverseBytes(exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class,
 stream));
   ```



##########
core/camel-core/src/test/java/org/apache/camel/language/XPathAnotherRouteConcurrentTest.java:
##########
@@ -62,7 +62,7 @@ private String createXmlBody(int index, String name) {
         sb.append("<persons>\n");
         for (int i = 0; i < 100; i++) {
             sb.append("<person>");
-            sb.append("<id>" + index + "-" + i + "</id>");
+            
sb.append("<id>").append(index).append("-").append(i).append("</id>");

Review Comment:
   ```suggestion
               
sb.append("<id>").append(index).append('-').append(i).append("</id>");
   ```



##########
core/camel-core/src/test/java/org/apache/camel/processor/SplitCustomExpressionTest.java:
##########
@@ -59,9 +60,7 @@ public <T> T evaluate(Exchange exchange, Class<T> type) {
             // just split the body by comma
             String[] parts = body.split(",");
             List<String> list = new ArrayList<>();
-            for (String part : parts) {
-                list.add(part);
-            }
+            list.addAll(Arrays.asList(parts));

Review Comment:
   Or simply `List<String> list = List.of(parts);`



##########
core/camel-core/src/test/java/org/apache/camel/processor/SplitRefCustomExpressionTest.java:
##########
@@ -67,9 +68,7 @@ public <T> T evaluate(Exchange exchange, Class<T> type) {
             // just split the body by comma
             String[] parts = body.split(",");
             List<String> list = new ArrayList<>();
-            for (String part : parts) {
-                list.add(part);
-            }
+            list.addAll(Arrays.asList(parts));

Review Comment:
   ditto



##########
core/camel-core/src/test/java/org/apache/camel/processor/transformer/TransformerRouteTest.java:
##########
@@ -276,12 +276,12 @@ public void marshal(Exchange exchange, Object graph, 
OutputStream stream) throws
                 public Object unmarshal(Exchange exchange, InputStream stream) 
throws Exception {
                     BufferedReader reader = new BufferedReader(new 
InputStreamReader(stream));
                     String line = "";
-                    String input = "";
+                    StringBuilder input = new StringBuilder();
                     while ((line = reader.readLine()) != null) {
-                        input += line;
+                        input.append(line);
                     }
                     reader.close();

Review Comment:
   let's use a try-with-resource statement instead



##########
core/camel-core/src/test/java/org/apache/camel/component/file/cluster/FileLockClusteredRoutePolicyTest.java:
##########
@@ -39,7 +38,7 @@
 
 public final class FileLockClusteredRoutePolicyTest {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(FileLockClusteredRoutePolicyTest.class);
-    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).collect(Collectors.toList());
+    private static final List<String> CLIENTS = IntStream.range(0, 
3).mapToObj(Integer::toString).toList();

Review Comment:
   ditto



##########
core/camel-core/src/test/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategyTest.java:
##########
@@ -65,7 +69,7 @@ public void testMultithreadedLocking() throws Exception {
             assertEquals("Line " + i, lines[i]);
         }
 
-        waitUntilCompleted();
+        assertTrue(latch.await(10, TimeUnit.SECONDS), "Did not process the 
messages within 10 seconds");

Review Comment:
   Why not use Awaitility instead?



##########
core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultDiscardWhenFullTest.java:
##########
@@ -37,10 +40,8 @@ public void testDiscardWhenFull() throws Exception {
         // start route
         context.getRouteController().startRoute("foo");
 
-        // wait until  at least 1 message has been consumed
-        while (mock.getReceivedCounter() < 1) {
-            Thread.sleep(100);
-        }
+        // wait until at least 1 message has been consumed
+        Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> 
mock.getReceivedCounter() >= 1);

Review Comment:
   More or less the same thing as setting `expectedMinimumCount` on the mock 
endpoint.



##########
core/camel-core/src/test/java/org/apache/camel/processor/LogProcessorWithProvidedLoggerTest.java:
##########
@@ -43,8 +43,8 @@ public void setUp() throws Exception {
         sw = new StringWriter();
 
         ConsumingAppender.newAppender("org.apache.camel.customlogger", 
"customlogger", Level.TRACE,
-                event -> sw.append(event.getLoggerName() + " " + 
event.getLevel().toString() + " "
-                                   + 
event.getMessage().getFormattedMessage()));
+                event -> sw.append(event.getLoggerName()).append(" 
").append(event.getLevel().toString()).append(" ")

Review Comment:
   ```suggestion
                   event -> sw.append(event.getLoggerName()).append(' 
').append(event.getLevel()).append(' ')
   ```



##########
core/camel-core/src/test/java/org/apache/camel/processor/SplitterPojoTest.java:
##########
@@ -105,9 +106,7 @@ public List<String> splitBody(String body) {
             // you have the full power how you like to split your messages
             List<String> answer = new ArrayList<>();
             String[] parts = body.split(",");
-            for (String part : parts) {
-                answer.add(part);
-            }
+            answer.addAll(Arrays.asList(parts));

Review Comment:
   ditto



##########
core/camel-core/src/test/java/org/apache/camel/processor/async/MyAsyncComponent.java:
##########
@@ -36,11 +36,11 @@ private String prepareReply(String value) {
         // to make URIs valid we make the conventions of using ':' for ' ' and
         // capitalize words
         String[] words = value.split(":");
-        String result = "";
+        StringBuilder result = new StringBuilder();
         for (String word : words) {
-            result += result.isEmpty() ? "" : " ";
-            result += word.substring(0, 1).toUpperCase(Locale.ENGLISH) + 
word.substring(1);
+            result.append((result.length() == 0) ? "" : " ");

Review Comment:
   `isEmpty` should be used instead of `length() == 0`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to