View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.a.rttests;
18  
19  import static org.apache.juneau.TestUtils.*;
20  import java.util.*;
21  
22  import org.apache.juneau.common.utils.*;
23  import org.junit.jupiter.params.*;
24  import org.junit.jupiter.params.provider.*;
25  
26  /**
27   * Tests designed to serialize and parse objects to make sure we end up
28   * with the same objects for all serializers and parsers.
29   */
30  class BeanProperties_RoundTripTest extends RoundTripTest_Base {
31  
32  	//------------------------------------------------------------------------------------------------------------------
33  	// Combo arrays/lists
34  	//------------------------------------------------------------------------------------------------------------------
35  
36  	public static class A01 {
37  		public List<Long>[] f1;
38  	}
39  
40  	@SuppressWarnings("unchecked")
41  	@ParameterizedTest
42  	@MethodSource("testers")
43  	void a01_arrayOfListOfLongs(RoundTrip_Tester t) throws Exception {
44  		var o = new A01();
45  		o.f1 = new List[1];
46  		o.f1[0] = alist(123L);
47  		o = t.roundTrip(o);
48  		assertBean(o, "f1{0{0}}", "{{123}}");
49  	}
50  
51  	public static class A02 {
52  		public List<Long[]> f1;
53  	}
54  
55  	@ParameterizedTest
56  	@MethodSource("testers")
57  	void a02_listOfArrayOfLongs(RoundTrip_Tester t) throws Exception {
58  		var o = new A02();
59  		o.f1 = Utils.<Long[]>alist(new Long[]{123L});
60  		o = t.roundTrip(o);
61  		assertBean(o, "f1{0{0}}", "{{123}}");
62  	}
63  
64  	public static class A03 {
65  		public List<Long>[][] f1;
66  	}
67  
68  	@SuppressWarnings("unchecked")
69  	@ParameterizedTest
70  	@MethodSource("testers")
71  	void a03_2dArrayOfListOfLongs(RoundTrip_Tester t) throws Exception {
72  		var o = new A03();
73  		o.f1 = new List[1][1];
74  		o.f1[0] = new List[]{alist(123L)};
75  		o = t.roundTrip(o);
76  		assertBean(o, "f1{0{0{0}}}", "{{{123}}}");
77  	}
78  
79  	public static class A04 {
80  		public List<Long[][]> f1;
81  	}
82  
83  	@ParameterizedTest
84  	@MethodSource("testers")
85  	void a04_listOf2dArrayOfLongs(RoundTrip_Tester t) throws Exception {
86  		var o = new A04();
87  		o.f1 = Utils.<Long[][]>alist(new Long[][]{new Long[]{123L}});
88  		o = t.roundTrip(o);
89  		assertBean(o, "f1{0{0{0}}}", "{{{123}}}");
90  	}
91  }