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.commons.utils.CollectionUtils.*;
20  import static org.apache.juneau.junit.bct.BctAssertions.*;
21  
22  import java.util.*;
23  
24  import org.apache.juneau.commons.utils.*;
25  import org.junit.jupiter.params.*;
26  import org.junit.jupiter.params.provider.*;
27  
28  /**
29   * Tests designed to serialize and parse objects to make sure we end up
30   * with the same objects for all serializers and parsers.
31   */
32  class BeanProperties_RoundTripTest extends RoundTripTest_Base {
33  
34  	//------------------------------------------------------------------------------------------------------------------
35  	// Combo arrays/lists
36  	//------------------------------------------------------------------------------------------------------------------
37  
38  	public static class A01 {
39  		public List<Long>[] f1;
40  	}
41  
42  	@ParameterizedTest
43  	@MethodSource("testers")
44  	void a01_arrayOfListOfLongs(RoundTrip_Tester t) throws Exception {
45  		var o = new A01();
46  		o.f1 = new List[1];
47  		o.f1[0] = l(123L);
48  		o = t.roundTrip(o);
49  		assertBean(o, "f1{0{0}}", "{{123}}");
50  	}
51  
52  	public static class A02 {
53  		public List<Long[]> f1;
54  	}
55  
56  	@ParameterizedTest
57  	@MethodSource("testers")
58  	void a02_listOfArrayOfLongs(RoundTrip_Tester t) throws Exception {
59  		var o = new A02();
60  		o.f1 = CollectionUtils.<Long[]>l(a(123L));
61  		o = t.roundTrip(o);
62  		assertBean(o, "f1{0{0}}", "{{123}}");
63  	}
64  
65  	public static class A03 {
66  		public List<Long>[][] f1;
67  	}
68  
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] = a(l(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 = CollectionUtils.<Long[][]>l(a2(a(123L)));
88  		o = t.roundTrip(o);
89  		assertBean(o, "f1{0{0{0}}}", "{{{123}}}");
90  	}
91  }