Github user galen-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/383#discussion_r99265598 --- Diff: geode-core/src/test/java/org/apache/geode/internal/InternalDataSerializerQuickcheckStringTest.java --- @@ -0,0 +1,63 @@ +/* + * 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.geode.internal; + +import static org.junit.Assert.*; + +import com.pholser.junit.quickcheck.Property; +import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; +import org.apache.geode.DataSerializer; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Tests the serialization and deserialization of randomly generated Strings. + * + * The current implementation (0.7 or 0.8alpha2) of junit-quickcheck-generators only generates valid + * codepoints, and that it doesn't tend to test strings that are particularly long, though the more + * trials you run, the longer they get. + */ +@Category(UnitTest.class) +@RunWith(JUnitQuickcheck.class) +public class InternalDataSerializerQuickcheckStringTest { + @Property(trials = 1000) + public void StringSerializedDeserializesToSameValue(String originalString) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); + + DataSerializer.writeString(originalString, dataOutputStream); + dataOutputStream.flush(); + + byte[] stringBytes = byteArrayOutputStream.toByteArray(); + DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(stringBytes)); + String returnedString = DataSerializer.readString(dataInputStream); + + assertEquals("Deserialized string matches original", originalString, returnedString); --- End diff -- I think that would require rewriting either the test runner or the assertion functions. I don't see the seed when I'm running in IntelliJ (though it doesn't seem to discard output), but I do when I run the test suite (where unprintable input appears as question marks): ``` shrinking: Deserialized string matches original expected:<[foo]> but was:<[?? ]> Shrunken args: [?? ] Original failure message: [Deserialized string matches original expected:<[foo]> but was:<[????????]>] Original args: [????????] Seeds: [5559329435085103409] ``` I can then rerun the test with: ``` public void StringSerializedDeserializesToSameValue(@When(seed=5559329435085103409L) String originalString) throws IOException { ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---