tillrohrmann commented on a change in pull request #14936: URL: https://github.com/apache/flink/pull/14936#discussion_r578464596
########## File path: flink-core/src/test/java/org/apache/flink/util/SerializedValueTest.java ########## @@ -47,26 +50,47 @@ public void testSimpleValue() { assertNotNull(v.toString()); assertNotNull(copy.toString()); + assertNotEquals(0, v.getByteArray().length); + assertArrayEquals(v.getByteArray(), copy.getByteArray()); + + byte[] bytes = v.getByteArray(); + SerializedValue<String> saved = + SerializedValue.fromBytes(Arrays.copyOf(bytes, bytes.length)); + assertEquals(v, saved); + assertArrayEquals(v.getByteArray(), saved.getByteArray()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } @Test Review comment: Might be a bit shorter: ```suggestion @Test(expected = NullPointerException.class) ``` ########## File path: flink-core/src/test/java/org/apache/flink/util/SerializedValueTest.java ########## @@ -47,26 +50,47 @@ public void testSimpleValue() { assertNotNull(v.toString()); assertNotNull(copy.toString()); + assertNotEquals(0, v.getByteArray().length); + assertArrayEquals(v.getByteArray(), copy.getByteArray()); + + byte[] bytes = v.getByteArray(); + SerializedValue<String> saved = + SerializedValue.fromBytes(Arrays.copyOf(bytes, bytes.length)); + assertEquals(v, saved); + assertArrayEquals(v.getByteArray(), saved.getByteArray()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } @Test - public void testNullValue() { + public void testNullValue() throws Exception { try { - SerializedValue<Object> v = new SerializedValue<>(null); - SerializedValue<Object> copy = CommonTestUtils.createCopySerializable(v); + new SerializedValue<>(null); + fail("expect NullPointerException"); + } catch (NullPointerException e) { + // ignore + } + } - assertNull(copy.deserializeValue(getClass().getClassLoader())); + @Test + public void testFromNullBytes() { + try { + SerializedValue.fromBytes(null); + fail("expect NullPointerException"); + } catch (NullPointerException e) { + // ignore + } + } - assertEquals(v, copy); - assertEquals(v.hashCode(), copy.hashCode()); - assertEquals(v.toString(), copy.toString()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); + @Test Review comment: Same here with `@Test(exepcted = ...)`. ########## File path: flink-core/src/test/java/org/apache/flink/util/SerializedValueTest.java ########## @@ -47,26 +50,47 @@ public void testSimpleValue() { assertNotNull(v.toString()); assertNotNull(copy.toString()); + assertNotEquals(0, v.getByteArray().length); + assertArrayEquals(v.getByteArray(), copy.getByteArray()); + + byte[] bytes = v.getByteArray(); + SerializedValue<String> saved = + SerializedValue.fromBytes(Arrays.copyOf(bytes, bytes.length)); + assertEquals(v, saved); + assertArrayEquals(v.getByteArray(), saved.getByteArray()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } @Test - public void testNullValue() { + public void testNullValue() throws Exception { try { - SerializedValue<Object> v = new SerializedValue<>(null); - SerializedValue<Object> copy = CommonTestUtils.createCopySerializable(v); + new SerializedValue<>(null); + fail("expect NullPointerException"); + } catch (NullPointerException e) { + // ignore + } + } - assertNull(copy.deserializeValue(getClass().getClassLoader())); + @Test Review comment: Same here with `@Test(expected = ...)`. ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/AkkaRpcSerializedValueTest.java ########## @@ -0,0 +1,123 @@ +/* + * 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.flink.runtime.rpc.akka; + +import org.apache.flink.util.InstantiationUtil; + +import org.junit.Test; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.Instant; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + +public class AkkaRpcSerializedValueTest { Review comment: ```suggestion public class AkkaRpcSerializedValueTest extends TestLogger { ``` This makes sure that the test names are printed. This is quite helpful for CI where multiple tests are executed one after another and the names help to split the log messages from the different test cases. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org