11/*
2- * Copyright (c) 2019, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2019, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2525 * @test
2626 * @bug 8246774
2727 * @summary Checks that the appropriate default value is given to the canonical ctr
28- * @run testng AbsentStreamValuesTest
28+ * @run junit AbsentStreamValuesTest
2929 */
3030
3131import java .io .ByteArrayInputStream ;
3434import java .io .IOException ;
3535import java .io .ObjectInputStream ;
3636import java .io .Serializable ;
37- import org .testng .annotations .DataProvider ;
38- import org .testng .annotations .Test ;
3937import static java .io .ObjectStreamConstants .*;
4038import static java .lang .System .out ;
41- import static org .testng .Assert .*;
39+
40+ import static org .junit .jupiter .api .Assertions .*;
41+ import org .junit .jupiter .api .Test ;
42+ import org .junit .jupiter .api .TestInstance ;
43+ import org .junit .jupiter .params .ParameterizedTest ;
44+ import org .junit .jupiter .params .provider .MethodSource ;
4245
4346/**
4447 * Basic test to check that default primitive / reference values are presented
4548 * to the record's canonical constructor, for fields not in the stream.
4649 */
50+ @ TestInstance (TestInstance .Lifecycle .PER_CLASS )
4751public class AbsentStreamValuesTest {
4852
4953 record R01 (boolean x ) implements Serializable { }
@@ -61,7 +65,6 @@ record R12(Object[] x) implements Serializable { }
6165 record R13 (R12 x ) implements Serializable { }
6266 record R14 (R13 [] x ) implements Serializable { }
6367
64- @ DataProvider (name = "recordTypeAndExpectedValue" )
6568 public Object [][] recordTypeAndExpectedValue () {
6669 return new Object [][] {
6770 new Object [] { R01 .class , false },
@@ -81,7 +84,8 @@ public Object[][] recordTypeAndExpectedValue() {
8184 };
8285 }
8386
84- @ Test (dataProvider = "recordTypeAndExpectedValue" )
87+ @ ParameterizedTest
88+ @ MethodSource ("recordTypeAndExpectedValue" )
8589 public void testWithDifferentTypes (Class <?> clazz , Object expectedXValue )
8690 throws Exception
8791 {
@@ -92,7 +96,7 @@ public void testWithDifferentTypes(Class<?> clazz, Object expectedXValue)
9296 Object obj = deserialize (bytes );
9397 out .println ("deserialized: " + obj );
9498 Object actualXValue = clazz .getDeclaredMethod ("x" ).invoke (obj );
95- assertEquals (actualXValue , expectedXValue );
99+ assertEquals (expectedXValue , actualXValue );
96100 }
97101
98102 // --- all together
@@ -107,18 +111,18 @@ public void testWithAllTogether() throws Exception {
107111
108112 R15 obj = (R15 )deserialize (bytes );
109113 out .println ("deserialized: " + obj );
110- assertEquals (obj .a , false );
111- assertEquals (obj .b , 0 );
112- assertEquals (obj .c , 0 );
113- assertEquals (obj . d , '\u0000' );
114- assertEquals (obj .e , 0 );
115- assertEquals (obj .f , 0l );
116- assertEquals (obj .g , 0f );
117- assertEquals (obj .h , 0d );
118- assertEquals (obj .i , null );
119- assertEquals (obj .j , null );
120- assertEquals (obj .k , null );
121- assertEquals (obj .l , null );
114+ assertEquals (false , obj .a );
115+ assertEquals (0 , obj .b );
116+ assertEquals (0 , obj .c );
117+ assertEquals ('\u0000' , obj . d );
118+ assertEquals (0 , obj .e );
119+ assertEquals (0l , obj .f );
120+ assertEquals (0f , obj .g );
121+ assertEquals (0d , obj .h );
122+ assertEquals (null , obj .i );
123+ assertEquals (null , obj .j );
124+ assertEquals (null , obj .k );
125+ assertEquals (null , obj .l );
122126 }
123127
124128 // --- generic type
@@ -132,8 +136,8 @@ public void testGenericType() throws Exception {
132136
133137 R16 obj = (R16 )deserialize (bytes );
134138 out .println ("deserialized: " + obj );
135- assertEquals (obj .t , null );
136- assertEquals (obj .u , null );
139+ assertEquals (null , obj .t );
140+ assertEquals (null , obj .u );
137141 }
138142
139143 // --- infra
0 commit comments