Skip to content

Commit 9624a1a

Browse files
author
Nicolai Parlog
committed
Fixed tests, so their value comparison does not rely on interning.
1 parent c036b38 commit 9624a1a

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

test/org/codefx/libfx/nesting/property/AbstractNestedPropertyBuilderTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.codefx.libfx.nesting.property;
22

3+
import static org.junit.Assert.assertEquals;
34
import static org.junit.Assert.assertNotSame;
4-
import static org.junit.Assert.assertSame;
55
import javafx.beans.property.Property;
66

7-
import org.codefx.libfx.nesting.property.AbstractNestedPropertyBuilder;
8-
import org.codefx.libfx.nesting.property.NestedProperty;
97
import org.junit.Before;
108
import org.junit.Test;
119

@@ -49,7 +47,7 @@ public void testSetBean() {
4947
builder.setBean(bean);
5048
P nestedProperty = builder.build();
5149

52-
assertSame(bean, nestedProperty.getBean());
50+
assertEquals(bean, nestedProperty.getBean());
5351
}
5452

5553
/**
@@ -72,7 +70,7 @@ public void testSetName() {
7270
builder.setName(name);
7371
P nestedProperty = builder.build();
7472

75-
assertSame(name, nestedProperty.getName());
73+
assertEquals(name, nestedProperty.getName());
7674
}
7775

7876
/**

test/org/codefx/libfx/nesting/property/AbstractNestedPropertyTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
import static org.codefx.libfx.nesting.testhelper.NestingAccess.getNestingValue;
55
import static org.codefx.libfx.nesting.testhelper.NestingAccess.setNestingObservable;
66
import static org.codefx.libfx.nesting.testhelper.NestingAccess.setNestingValue;
7+
import static org.junit.Assert.assertEquals;
78
import static org.junit.Assert.assertFalse;
89
import static org.junit.Assert.assertNotSame;
910
import static org.junit.Assert.assertNull;
10-
import static org.junit.Assert.assertSame;
1111
import static org.junit.Assert.assertTrue;
1212
import javafx.beans.property.Property;
1313

1414
import org.codefx.libfx.nesting.Nesting;
15-
import org.codefx.libfx.nesting.property.NestedProperty;
1615
import org.codefx.libfx.nesting.testhelper.NestingAccess;
1716
import org.junit.Before;
1817
import org.junit.Test;
@@ -60,7 +59,7 @@ public void setUp() {
6059
*/
6160
@Test
6261
public void testInnerValueAfterConstruction() {
63-
assertSame(getNestingValue(nesting), property.getValue());
62+
assertEquals(getNestingValue(nesting), property.getValue());
6463
assertFalse(property.isInnerObservableNull());
6564
}
6665

@@ -72,11 +71,11 @@ public void testChangingValue() {
7271
T newValue = createNewValue();
7372
setNestingValue(nesting, newValue);
7473
// assert that setting the value worked
75-
assertSame(newValue, getNestingValue(nesting));
74+
assertEquals(newValue, getNestingValue(nesting));
7675

7776
// assert that nesting and property hold the new value
78-
assertSame(getNestingValue(nesting), property.getValue());
79-
assertSame(newValue, property.getValue());
77+
assertEquals(getNestingValue(nesting), property.getValue());
78+
assertEquals(newValue, property.getValue());
8079
}
8180

8281
/**
@@ -104,11 +103,11 @@ public void testChangingObservable() {
104103
P newObservable = createNewObservableWithValue(newValue);
105104
setNestingObservable(nesting, newObservable);
106105
// assert that setting the observable worked
107-
assertSame(newObservable, getNestingObservable(nesting));
106+
assertEquals(newObservable, getNestingObservable(nesting));
108107

109108
// assert that nesting and property hold the new value
110-
assertSame(getNestingValue(nesting), property.getValue());
111-
assertSame(newValue, property.getValue());
109+
assertEquals(getNestingValue(nesting), property.getValue());
110+
assertEquals(newValue, property.getValue());
112111
// assert that 'isInnerObservableNull' is still false
113112
assertFalse(property.isInnerObservableNull());
114113
}
@@ -124,7 +123,7 @@ public void testChangingObservableToNull() {
124123
assertNull(getNestingObservable(nesting));
125124

126125
// assert that the nesting still holds the old value
127-
assertSame(oldValue, property.getValue());
126+
assertEquals(oldValue, property.getValue());
128127
// assert that 'isInnerObservableNull' is now true
129128
assertTrue(property.isInnerObservableNull());
130129
}
@@ -138,15 +137,15 @@ public void testChangingNewObservablesValue() {
138137
P newObservable = createNewObservableWithSomeValue();
139138
setNestingObservable(nesting, newObservable);
140139
// (assert that setting the observable worked)
141-
assertSame(newObservable, getNestingObservable(nesting));
140+
assertEquals(newObservable, getNestingObservable(nesting));
142141

143142
// ... and change its value
144143
T newValue = createNewValue();
145144
newObservable.setValue(newValue);
146145

147146
// assert that nesting and property hold the new value
148-
assertSame(getNestingValue(nesting), property.getValue());
149-
assertSame(newValue, property.getValue());
147+
assertEquals(getNestingValue(nesting), property.getValue());
148+
assertEquals(newValue, property.getValue());
150149
}
151150

152151
/**
@@ -171,8 +170,8 @@ public void testChangingOldObservablesValue() {
171170
// assert that nesting and property do not hold the old observable's value ...
172171
assertNotSame(newValueInOldObservable, property.getValue());
173172
// ... but the new one
174-
assertSame(getNestingValue(nesting), property.getValue());
175-
assertSame(newValueInNewObservable, property.getValue());
173+
assertEquals(getNestingValue(nesting), property.getValue());
174+
assertEquals(newValueInNewObservable, property.getValue());
176175
}
177176

178177
//#end TESTS

0 commit comments

Comments
 (0)