- Timestamp:
- 2018-08-05T20:53:19+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.classpath
r14091 r14092 29 29 </classpathentry> 30 30 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"> 31 <attributes>32 <attribute name="test" value="true"/>33 </attributes>34 </classpathentry>35 <classpathentry kind="lib" path="test/lib/fest/fest-assert-1.0.jar">36 <attributes>37 <attribute name="test" value="true"/>38 </attributes>39 </classpathentry>40 <classpathentry kind="lib" path="test/lib/fest/fest-reflect-1.1.jar">41 <attributes>42 <attribute name="test" value="true"/>43 </attributes>44 </classpathentry>45 <classpathentry kind="lib" path="test/lib/fest/fest-swing-1.1.jar">46 <attributes>47 <attribute name="test" value="true"/>48 </attributes>49 </classpathentry>50 <classpathentry kind="lib" path="test/lib/fest/fest-util-1.0.jar">51 <attributes>52 <attribute name="test" value="true"/>53 </attributes>54 </classpathentry>55 <classpathentry kind="lib" path="test/lib/fest/jcip-annotations-1.0.jar">56 <attributes>57 <attribute name="test" value="true"/>58 </attributes>59 </classpathentry>60 <classpathentry kind="lib" path="test/lib/fest/MRJToolkitStubs-1.0.jar">61 31 <attributes> 62 32 <attribute name="test" value="true"/> … … 139 109 </attributes> 140 110 </classpathentry> 141 <classpathentry kind="lib" path="test/lib/fest/debug-1.0.jar">142 <attributes>143 <attribute name="test" value="true"/>144 </attributes>145 </classpathentry>146 111 <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"> 147 112 <attributes> -
trunk/netbeans/nbproject/project.properties
r14091 r14092 37 37 file.reference.commons-testing-2.1.0.jar=../test/lib/commons-testing/commons-testing-2.1.0.jar 38 38 file.reference.core-src=../src 39 file.reference.debug-1.0.jar=../test/lib/fest/debug-1.0.jar40 39 file.reference.equalsverifier-2.5.1.jar=../test/lib/equalsverifier-2.5.1.jar 41 file.reference.fest-assert-1.0.jar=../test/lib/fest/fest-assert-1.0.jar42 file.reference.fest-reflect-1.1.jar=../test/lib/fest/fest-reflect-1.1.jar43 file.reference.fest-swing-1.1.jar=../test/lib/fest/fest-swing-1.1.jar44 file.reference.fest-util-1.0.jar=../test/lib/fest/fest-util-1.0.jar45 40 file.reference.spotbugs.jar=../tools/spotbugs/spotbugs.jar 46 41 file.reference.guava-21.0.jar=../test/lib/reflections/guava-21.0.jar 47 42 file.reference.hamcrest-core-1.3.jar=../test/lib/junit/hamcrest-core-1.3.jar 48 43 file.reference.javassist-3.21.0-GA.jar=../test/lib/reflections/javassist-3.21.0-GA.jar 49 file.reference.jcip-annotations-1.0.jar=../test/lib/fest/jcip-annotations-1.0.jar50 44 file.reference.jfcunit.jar=../test/lib/jfcunit.jar 51 45 file.reference.jmockit-1.41.jar=../test/lib/jmockit-1.41.jar 52 46 file.reference.junit-4.12.jar=../test/lib/junit/junit-4.12.jar 53 file.reference.MRJToolkitStubs-1.0.jar=../test/lib/fest/MRJToolkitStubs-1.0.jar54 47 file.reference.ognl-2.6.9.jar=../test/lib/unitils-core/ognl-2.6.9.jar 55 48 file.reference.reflections-0.9.10.jar=../test/lib/reflections/reflections-0.9.10.jar … … 80 73 ${file.reference.equalsverifier-2.5.1.jar}:\ 81 74 ${file.reference.hamcrest-core-1.3.jar}:\ 82 ${file.reference.MRJToolkitStubs-1.0.jar}:\83 ${file.reference.debug-1.0.jar}:\84 ${file.reference.fest-assert-1.0.jar}:\85 ${file.reference.fest-reflect-1.1.jar}:\86 ${file.reference.fest-swing-1.1.jar}:\87 ${file.reference.fest-util-1.0.jar}:\88 ${file.reference.jcip-annotations-1.0.jar}:\89 75 ${file.reference.guava-21.0.jar}:\ 90 76 ${file.reference.javassist-3.21.0-GA.jar}:\ -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r14081 r14092 179 179 */ 180 180 public static Object getPrivateField(Object obj, String fieldName) throws ReflectiveOperationException { 181 Field f = obj.getClass().getDeclaredField(fieldName); 181 return getPrivateField(obj.getClass(), obj, fieldName); 182 } 183 184 /** 185 * Returns a private field value. 186 * @param cls object class 187 * @param obj object 188 * @param fieldName private field name 189 * @return private field value 190 * @throws ReflectiveOperationException if a reflection operation error occurs 191 */ 192 public static Object getPrivateField(Class<?> cls, Object obj, String fieldName) throws ReflectiveOperationException { 193 Field f = cls.getDeclaredField(fieldName); 182 194 AccessController.doPrivileged((PrivilegedAction<Void>) () -> { 183 195 f.setAccessible(true); -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java
r13897 r14092 9 9 import java.util.Arrays; 10 10 11 import org.fest.util.Collections;12 11 import org.junit.Rule; 13 12 import org.junit.Test; … … 122 121 ImageryLayerInfo.instance.loadDefaults(true, null, false); 123 122 ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0); 124 wmsImageryInfo.setDefaultLayers( Collections.list(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", "")));123 wmsImageryInfo.setDefaultLayers(Arrays.asList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", ""))); 125 124 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection()); 126 125 tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857")); -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r13765 r14092 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.openstreetmap.josm.TestUtils.getPrivateField; 3 5 4 6 import java.io.FileInputStream; … … 12 14 import java.util.Random; 13 15 14 import org.fest.reflect.core.Reflection;15 import org.fest.reflect.reference.TypeRef;16 16 import org.junit.Assert; 17 17 import org.junit.Rule; … … 38 38 public JOSMTestRules test = new JOSMTestRules(); 39 39 40 private void removeAllTest(DataSet ds) { 40 @SuppressWarnings("unchecked") 41 private void removeAllTest(DataSet ds) throws ReflectiveOperationException { 41 42 List<Node> allNodes = new ArrayList<>(ds.getNodes()); 42 43 List<Way> allWays = new ArrayList<>(ds.getWays()); 43 44 List<Relation> allRelations = new ArrayList<>(ds.getRelations()); 44 45 45 QuadBucketPrimitiveStore<Node, Way, Relation> s = Reflection.field("store").ofType( 46 new TypeRef<QuadBucketPrimitiveStore<Node, Way, Relation>>() {}).in(ds).get(); 47 QuadBuckets<Node> nodes = Reflection.field("nodes").ofType(new TypeRef<QuadBuckets<Node>>() {}).in(s).get(); 48 QuadBuckets<Way> ways = Reflection.field("ways").ofType(new TypeRef<QuadBuckets<Way>>() {}).in(s).get(); 49 Collection<Relation> relations = Reflection.field("relations").ofType(new TypeRef<Collection<Relation>>() {}).in(s).get(); 46 QuadBucketPrimitiveStore<Node, Way, Relation> s = (QuadBucketPrimitiveStore<Node, Way, Relation>) getPrivateField(ds, "store"); 47 QuadBuckets<Node> nodes = (QuadBuckets<Node>) getPrivateField(s, "nodes"); 48 QuadBuckets<Way> ways = (QuadBuckets<Way>) getPrivateField(s, "ways"); 49 Collection<Relation> relations = (Collection<Relation>) getPrivateField(s, "relations"); 50 50 51 51 int expectedCount = allNodes.size(); … … 77 77 } 78 78 79 /** 80 * Test that all primitives can be removed from the Quad Buckets. 81 * @throws Exception never 82 */ 79 83 @Test 80 84 public void testRemove() throws Exception { … … 86 90 } 87 91 92 /** 93 * Test that all primitives can be removed from the Quad Buckets, even if moved before. 94 * @throws Exception never 95 */ 88 96 @Test 89 97 public void testMove() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java
r12620 r14092 2 2 package org.openstreetmap.josm.gui.conflict.pair.nodes; 3 3 4 import static org.fest.reflect.core.Reflection.field;5 import static org.fest.reflect.core.Reflection.method;6 4 import static org.junit.Assert.assertEquals; 7 5 import static org.junit.Assert.assertFalse; … … 11 9 import java.beans.PropertyChangeEvent; 12 10 import java.beans.PropertyChangeListener; 11 import java.lang.reflect.Method; 12 import java.security.AccessController; 13 import java.security.PrivilegedAction; 13 14 import java.util.ArrayList; 14 15 import java.util.Arrays; … … 20 21 import org.junit.Rule; 21 22 import org.junit.Test; 23 import org.openstreetmap.josm.TestUtils; 22 24 import org.openstreetmap.josm.data.osm.Node; 23 25 import org.openstreetmap.josm.data.osm.Way; 26 import org.openstreetmap.josm.gui.conflict.pair.AbstractListMergeModel; 24 27 import org.openstreetmap.josm.testutils.DatasetFactory; 25 28 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 45 48 @SuppressWarnings("unchecked") 46 49 protected List<Node> inspectNodeList(NodeListMergeModel model, String name) { 47 return method("get" + name + "Entries") 48 .withReturnType(List.class) 49 .in(model) 50 .invoke(); 50 try { 51 Method getNamedEntries = AbstractListMergeModel.class.getDeclaredMethod("get" + name + "Entries"); 52 AccessController.doPrivileged((PrivilegedAction<Void>) () -> { 53 getNamedEntries.setAccessible(true); 54 return null; 55 }); 56 return (List<Node>) getNamedEntries.invoke(model); 57 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { 58 throw new RuntimeException(e); 59 } 51 60 } 52 61 53 62 protected DefaultListSelectionModel inspectListSelectionModel(NodeListMergeModel model, String name) { 54 return field(name).ofType(DefaultListSelectionModel.class) 55 .in(model) 56 .get(); 63 try { 64 return (DefaultListSelectionModel) TestUtils.getPrivateField(AbstractListMergeModel.class, model, name); 65 } catch (ReflectiveOperationException e) { 66 throw new RuntimeException(e); 67 } 68 } 69 70 @SuppressWarnings("unchecked") 71 protected Set<PropertyChangeListener> getListeners(NodeListMergeModel model) throws ReflectiveOperationException { 72 return (Set<PropertyChangeListener>) 73 TestUtils.getPrivateField(AbstractListMergeModel.class, model, "listeners"); 57 74 } 58 75 … … 644 661 @SuppressWarnings("unchecked") 645 662 @Test 646 public void testAddPropertyChangeListener() { 647 NodeListMergeModel model = new NodeListMergeModel(); 648 649 PropertyChangeListener listener = new PropertyChangeListener() { 650 651 public void propertyChange(PropertyChangeEvent evt) { 652 } 663 public void testAddPropertyChangeListener() throws ReflectiveOperationException { 664 NodeListMergeModel model = new NodeListMergeModel(); 665 666 PropertyChangeListener listener = evt -> { 653 667 }; 654 668 655 669 model.addPropertyChangeListener(listener); 656 670 657 Set<PropertyChangeListener> listeners = field("listeners") 658 .ofType(Set.class) 659 .in(model) 660 .get(); 671 Set<PropertyChangeListener> listeners = getListeners(model); 661 672 662 673 assertEquals(1, listeners.size()); … … 666 677 @SuppressWarnings("unchecked") 667 678 @Test 668 public void testRemovePropertyChangeListener() { 669 NodeListMergeModel model = new NodeListMergeModel(); 670 671 PropertyChangeListener listener = new PropertyChangeListener() { 672 673 public void propertyChange(PropertyChangeEvent evt) { 674 } 679 public void testRemovePropertyChangeListener() throws ReflectiveOperationException { 680 NodeListMergeModel model = new NodeListMergeModel(); 681 682 PropertyChangeListener listener = evt -> { 675 683 }; 676 684 … … 678 686 model.removePropertyChangeListener(listener); 679 687 680 Set<PropertyChangeListener> listeners = field("listeners") 681 .ofType(Set.class) 682 .in(model) 683 .get(); 688 Set<PropertyChangeListener> listeners = getListeners(model); 684 689 685 690 assertEquals(0, listeners.size()); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModelTest.java
r10962 r14092 2 2 package org.openstreetmap.josm.gui.conflict.pair.tags; 3 3 4 import static org.fest.reflect.core.Reflection.field;5 4 import static org.junit.Assert.assertEquals; 6 5 import static org.junit.Assert.assertNull; 7 6 8 import java.beans.PropertyChangeEvent;9 7 import java.beans.PropertyChangeListener; 10 8 import java.util.List; … … 13 11 import org.junit.Rule; 14 12 import org.junit.Test; 13 import org.openstreetmap.josm.TestUtils; 15 14 import org.openstreetmap.josm.data.osm.Node; 16 15 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 32 31 public JOSMTestRules test = new JOSMTestRules(); 33 32 34 @Test 35 public void testAddPropertyChangeListener() { 36 TagMergeModel model = new TagMergeModel(); 37 PropertyChangeListener listener = new PropertyChangeListener() { 38 39 public void propertyChange(PropertyChangeEvent evt) { 40 } 33 protected Set<PropertyChangeListener> getListeners(TagMergeModel model) throws ReflectiveOperationException { 34 return (Set<PropertyChangeListener>) TestUtils.getPrivateField(model, "listeners"); 35 } 36 37 protected List<TagMergeItem> getTagMergeItems(TagMergeModel model) throws ReflectiveOperationException { 38 return (List<TagMergeItem>) TestUtils.getPrivateField(model, "tagMergeItems"); 39 } 40 41 @Test 42 public void testAddPropertyChangeListener() throws ReflectiveOperationException { 43 TagMergeModel model = new TagMergeModel(); 44 PropertyChangeListener listener = evt -> { 41 45 }; 42 46 model.addPropertyChangeListener(listener); 43 47 44 Set<?> list = field("listeners").ofType(Set.class) 45 .in(model) 46 .get(); 48 Set<?> list = getListeners(model); 47 49 48 50 assertEquals(1, list.size()); … … 51 53 52 54 @Test 53 public void testRemovePropertyChangeListener() { 54 TagMergeModel model = new TagMergeModel(); 55 PropertyChangeListener listener = new PropertyChangeListener() { 56 57 public void propertyChange(PropertyChangeEvent evt) { 58 } 55 public void testRemovePropertyChangeListener() throws ReflectiveOperationException { 56 TagMergeModel model = new TagMergeModel(); 57 PropertyChangeListener listener = evt -> { 59 58 }; 60 59 model.addPropertyChangeListener(listener); 61 60 model.removePropertyChangeListener(listener); 62 61 63 Set<?> list = field("listeners") 64 .ofType(Set.class) 65 .in(model) 66 .get(); 62 Set<?> list = getListeners(model); 67 63 68 64 assertEquals(0, list.size()); … … 70 66 71 67 @Test 72 public void testPopulateNoConflichts() { 73 Node my = new Node(1); 74 Node their = new Node(1); 75 TagMergeModel model = new TagMergeModel(); 76 model.populate(my, their); 77 78 List<TagMergeItem> list = field("tagMergeItems") 79 .ofType(List.class) 80 .in(model) 81 .get(); 68 public void testPopulateNoConflichts() throws ReflectiveOperationException { 69 Node my = new Node(1); 70 Node their = new Node(1); 71 TagMergeModel model = new TagMergeModel(); 72 model.populate(my, their); 73 74 List<TagMergeItem> list = getTagMergeItems(model); 82 75 83 76 assertEquals(0, list.size()); … … 85 78 86 79 @Test 87 public void testPopulateNoConflicts1() {80 public void testPopulateNoConflicts1() throws ReflectiveOperationException { 88 81 Node my = new Node(1); 89 82 my.put("key", "value"); … … 93 86 model.populate(my, their); 94 87 95 List<TagMergeItem> list = field("tagMergeItems") 96 .ofType(List.class) 97 .in(model) 98 .get(); 88 List<TagMergeItem> list = getTagMergeItems(model); 99 89 100 90 assertEquals(0, list.size()); … … 102 92 103 93 @Test 104 public void testPopulateMissingKeyMine() {94 public void testPopulateMissingKeyMine() throws ReflectiveOperationException { 105 95 Node my = new Node(1); 106 96 Node their = new Node(1); … … 109 99 model.populate(my, their); 110 100 111 List<TagMergeItem> list = field("tagMergeItems") 112 .ofType(List.class) 113 .in(model) 114 .get(); 101 List<TagMergeItem> list = getTagMergeItems(model); 115 102 116 103 assertEquals(1, list.size()); … … 123 110 124 111 @Test 125 public void testPopulateMissingKeyTheir() {112 public void testPopulateMissingKeyTheir() throws ReflectiveOperationException { 126 113 Node my = new Node(1); 127 114 my.put("key", "value"); … … 130 117 model.populate(my, their); 131 118 132 List<TagMergeItem> list = field("tagMergeItems") 133 .ofType(List.class) 134 .in(model) 135 .get(); 119 List<TagMergeItem> list = getTagMergeItems(model); 136 120 137 121 assertEquals(1, list.size()); … … 144 128 145 129 @Test 146 public void testPopulateConflictingValues() {130 public void testPopulateConflictingValues() throws ReflectiveOperationException { 147 131 Node my = new Node(1); 148 132 my.put("key", "myvalue"); … … 152 136 model.populate(my, their); 153 137 154 List<TagMergeItem> list = field("tagMergeItems") 155 .ofType(List.class) 156 .in(model) 157 .get(); 138 List<TagMergeItem> list = getTagMergeItems(model); 158 139 159 140 assertEquals(1, list.size()); … … 166 147 167 148 @Test 168 public void testAddItem() {149 public void testAddItem() throws ReflectiveOperationException { 169 150 TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue"); 170 151 TagMergeModel model = new TagMergeModel(); 171 152 model.addItem(item); 172 153 173 List<TagMergeItem> list = field("tagMergeItems") 174 .ofType(List.class) 175 .in(model) 176 .get(); 154 List<TagMergeItem> list = getTagMergeItems(model); 177 155 178 156 assertEquals(1, list.size()); … … 185 163 186 164 @Test 187 public void testDecide() {165 public void testDecide() throws ReflectiveOperationException { 188 166 TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue"); 189 167 TagMergeModel model = new TagMergeModel(); 190 168 model.addItem(item); 191 169 192 List<TagMergeItem> list = field("tagMergeItems") 193 .ofType(List.class) 194 .in(model) 195 .get(); 170 List<TagMergeItem> list = getTagMergeItems(model); 196 171 197 172 model.decide(0, MergeDecisionType.KEEP_MINE); … … 212 187 213 188 @Test 214 public void testDecideMultiple() {189 public void testDecideMultiple() throws ReflectiveOperationException { 215 190 216 191 TagMergeModel model = new TagMergeModel(); … … 219 194 } 220 195 221 List<TagMergeItem> list = field("tagMergeItems") 222 .ofType(List.class) 223 .in(model) 224 .get(); 196 List<TagMergeItem> list = getTagMergeItems(model); 225 197 226 198 assertEquals(10, list.size());
Note:
See TracChangeset
for help on using the changeset viewer.