apupier commented on code in PR #29080:
URL: https://github.com/apache/camel/pull/29080#discussion_r4453628856


##########
components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreStreamBodyTest.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * 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.component.statestore;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.stream.InputStreamCache;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class StateStoreStreamBodyTest extends CamelTestSupport {
+
+    // not valid UTF-8, so it would not survive a conversion to text
+    private static final byte[] BINARY = { 0, 1, 2, (byte) 0xC3, (byte) 0x28, 
(byte) 0xFF, (byte) 0xFE };
+
+    @Test
+    void testPutStreamCacheStoresItsBytes() {
+        // the route caches the stream, so the producer gets a stream cache
+        template.requestBodyAndHeaders("direct:put", new 
ByteArrayInputStream(BINARY),
+                Map.of(StateStoreConstants.KEY, "key1"));
+
+        assertStoredBytes("key1", BINARY);
+    }
+
+    @Test
+    void testPutInputStreamStoresItsBytes() {
+        // without stream caching the producer gets the InputStream itself
+        template.requestBodyAndHeaders("direct:putNoStreamCaching", new 
ByteArrayInputStream(BINARY),
+                Map.of(StateStoreConstants.KEY, "key1"));
+
+        assertStoredBytes("key1", BINARY);

Review Comment:
   could we use different keys between tests to avoid having potential bad 
interaction if tests are played in parallel in heavy load?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to