jtulach@1039
|
1 |
/**
|
jtulach@1039
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
jtulach@1039
|
3 |
*
|
jtulach@1039
|
4 |
* Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
|
jtulach@1039
|
5 |
*
|
jtulach@1039
|
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
jtulach@1039
|
7 |
* Other names may be trademarks of their respective owners.
|
jtulach@1039
|
8 |
*
|
jtulach@1039
|
9 |
* The contents of this file are subject to the terms of either the GNU
|
jtulach@1039
|
10 |
* General Public License Version 2 only ("GPL") or the Common
|
jtulach@1039
|
11 |
* Development and Distribution License("CDDL") (collectively, the
|
jtulach@1039
|
12 |
* "License"). You may not use this file except in compliance with the
|
jtulach@1039
|
13 |
* License. You can obtain a copy of the License at
|
jtulach@1039
|
14 |
* http://www.netbeans.org/cddl-gplv2.html
|
jtulach@1039
|
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
jtulach@1039
|
16 |
* specific language governing permissions and limitations under the
|
jtulach@1039
|
17 |
* License. When distributing the software, include this License Header
|
jtulach@1039
|
18 |
* Notice in each file and include the License file at
|
jtulach@1039
|
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
jtulach@1039
|
20 |
* particular file as subject to the "Classpath" exception as provided
|
jtulach@1039
|
21 |
* by Oracle in the GPL Version 2 section of the License file that
|
jtulach@1039
|
22 |
* accompanied this code. If applicable, add the following below the
|
jtulach@1039
|
23 |
* License Header, with the fields enclosed by brackets [] replaced by
|
jtulach@1039
|
24 |
* your own identifying information:
|
jtulach@1039
|
25 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
jtulach@1039
|
26 |
*
|
jtulach@1039
|
27 |
* Contributor(s):
|
jtulach@1039
|
28 |
*
|
jtulach@1039
|
29 |
* The Original Software is NetBeans. The Initial Developer of the Original
|
jtulach@1039
|
30 |
* Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
|
jtulach@1039
|
31 |
*
|
jtulach@1039
|
32 |
* If you wish your version of this file to be governed by only the CDDL
|
jtulach@1039
|
33 |
* or only the GPL Version 2, indicate your decision by adding
|
jtulach@1039
|
34 |
* "[Contributor] elects to include this software in this distribution
|
jtulach@1039
|
35 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
jtulach@1039
|
36 |
* single choice of license, a recipient has the option to distribute
|
jtulach@1039
|
37 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
jtulach@1039
|
38 |
* to extend the choice of license to its licensees as provided above.
|
jtulach@1039
|
39 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
jtulach@1039
|
40 |
* Version 2 license, then the option applies only if the new code is
|
jtulach@1039
|
41 |
* made subject to such option by the copyright holder.
|
jtulach@1039
|
42 |
*/
|
jtulach@1039
|
43 |
package org.netbeans.html.json.impl;
|
jtulach@1039
|
44 |
|
jtulach@1039
|
45 |
import net.java.html.json.Model;
|
jtulach@1039
|
46 |
import net.java.html.json.Property;
|
jtulach@1039
|
47 |
import static org.testng.Assert.assertEquals;
|
jtulach@1039
|
48 |
import static org.testng.Assert.assertNotNull;
|
jtulach@1039
|
49 |
import static org.testng.Assert.assertNull;
|
jtulach@1039
|
50 |
import static org.testng.Assert.assertSame;
|
jtulach@1039
|
51 |
import org.testng.annotations.Test;
|
jtulach@1039
|
52 |
|
jtulach@1039
|
53 |
@Model(className = "Infinity", properties = {
|
jtulach@1039
|
54 |
@Property(name = "next", type = Infinity.class)
|
jtulach@1039
|
55 |
})
|
jtulach@1039
|
56 |
public class InfinityTest {
|
jtulach@1039
|
57 |
@Test
|
jtulach@1039
|
58 |
public void atLeastThousandStepsDeep() {
|
jtulach@1039
|
59 |
Infinity infinity = new Infinity();
|
jtulach@1039
|
60 |
int cnt = 0;
|
jtulach@1039
|
61 |
while (++cnt < 1000) {
|
jtulach@1039
|
62 |
infinity = infinity.getNext();
|
jtulach@1039
|
63 |
}
|
jtulach@1039
|
64 |
assertNotNull(infinity);
|
jtulach@1039
|
65 |
assertEquals(cnt, 1000);
|
jtulach@1039
|
66 |
}
|
jtulach@1039
|
67 |
|
jtulach@1039
|
68 |
@Test
|
jtulach@1039
|
69 |
public void afterInitializationRemainsTheSame() {
|
jtulach@1039
|
70 |
Infinity infinity = new Infinity();
|
jtulach@1039
|
71 |
Infinity first = infinity.getNext();
|
jtulach@1039
|
72 |
Infinity second = infinity.getNext();
|
jtulach@1039
|
73 |
assertSame(first, second);
|
jtulach@1039
|
74 |
}
|
jtulach@1039
|
75 |
|
jtulach@1039
|
76 |
@Test
|
jtulach@1039
|
77 |
public void nullRemains() {
|
jtulach@1039
|
78 |
Infinity infinity = new Infinity();
|
jtulach@1039
|
79 |
infinity.setNext(null);
|
jtulach@1039
|
80 |
assertNull(infinity.getNext(), "Remains null");
|
jtulach@1039
|
81 |
assertNull(infinity.getNext(), "Again");
|
jtulach@1039
|
82 |
}
|
jtulach@1039
|
83 |
|
jtulach@1039
|
84 |
@Test
|
jtulach@1039
|
85 |
public void ownValueRemains() {
|
jtulach@1039
|
86 |
Infinity infinity = new Infinity();
|
jtulach@1039
|
87 |
Infinity n = new Infinity();
|
jtulach@1039
|
88 |
infinity.setNext(n);
|
jtulach@1039
|
89 |
assertEquals(infinity.getNext(), n, "Remains n");
|
jtulach@1039
|
90 |
assertEquals(infinity.getNext(), n, "Again n");
|
jtulach@1039
|
91 |
}
|
jtulach@1039
|
92 |
}
|