[
https://issues.apache.org/jira/browse/AVRO-2245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16667630#comment-16667630
]
ASF GitHub Bot commented on AVRO-2245:
--------------------------------------
nandorKollar commented on a change in pull request #351: [AVRO-2245] Improve
java tests for compression codecs
URL: https://github.com/apache/avro/pull/351#discussion_r229065081
##########
File path: lang/java/avro/src/test/java/org/apache/avro/file/TestAllCodecs.java
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.avro.file;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Parameterized.class)
+public class TestAllCodecs {
+
+ @Parameterized.Parameters(name = "{index}: codec={0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ { "bzip2", BZip2Codec.class },
+ { "zstandard", ZstandardCodec.class },
+ { "null", NullCodec.class },
+ { "xz", XZCodec.class },
+ { "snappy", SnappyCodec.class },
+ { "deflate", DeflateCodec.class },
+ });
+ }
+
+ @Parameterized.Parameter(0)
+ public String codec;
+
+ @Parameterized.Parameter(1)
+ public Class<? extends Codec> codecClass;
+
+
+ @Test
+ public void testCodec() throws IOException {
+ int inputSize = 500_000;
+
+ byte[] input = generateTestData(inputSize);
+
+ Codec codecInstance = CodecFactory.fromString(codec).createInstance();
+ assertTrue(codecClass.isInstance(codecInstance));
+ assertTrue(codecInstance.getName().equals(codec));
+
+ ByteBuffer inputByteBuffer = ByteBuffer.wrap(input);
Review comment:
Here, the original tests allocated a 2 times bigger buffer than the original
input, which was supposed to test AVRO-1326 is fixed. If i'm not mistaken, with
refactor this test like you did, we lose this verification.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Java codec testing improvements
> -------------------------------
>
> Key: AVRO-2245
> URL: https://issues.apache.org/jira/browse/AVRO-2245
> Project: Avro
> Issue Type: Improvement
> Components: java
> Reporter: Jacob Tolar
> Priority: Minor
>
> In the Avro Java implementation, TestBZip2Codec and TestZstandardCodec are
> both laughably wrong.
> For example, the last lines of TestBZip2Codec:
> {code:java}
> byte[] outputByteArray = decompressedBuffer.array();
> for (int i = 0; i < inputByteSize; i++) {
> inputByteArray[i] = outputByteArray[i];
> }
> {code}
> There should be an assertEquals in there not an assignment statement. (And if
> you put assertEquals there, the test actually fails...).
> I will send a PR that replaces these tests with a correct parametrized test
> for all codecs.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)