Changeset 14092 in josm for trunk


Ignore:
Timestamp:
2018-08-05T20:53:19+02:00 (6 years ago)
Author:
Don-vip
Message:

drop FEST library. This project seems to have vanished years ago, and we don't use it a lot

Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r14091 r14092  
    2929        </classpathentry>
    3030        <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">
    6131                <attributes>
    6232                        <attribute name="test" value="true"/>
     
    139109                </attributes>
    140110        </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>
    146111        <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT">
    147112                <attributes>
  • trunk/netbeans/nbproject/project.properties

    r14091 r14092  
    3737file.reference.commons-testing-2.1.0.jar=../test/lib/commons-testing/commons-testing-2.1.0.jar
    3838file.reference.core-src=../src
    39 file.reference.debug-1.0.jar=../test/lib/fest/debug-1.0.jar
    4039file.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.jar
    42 file.reference.fest-reflect-1.1.jar=../test/lib/fest/fest-reflect-1.1.jar
    43 file.reference.fest-swing-1.1.jar=../test/lib/fest/fest-swing-1.1.jar
    44 file.reference.fest-util-1.0.jar=../test/lib/fest/fest-util-1.0.jar
    4540file.reference.spotbugs.jar=../tools/spotbugs/spotbugs.jar
    4641file.reference.guava-21.0.jar=../test/lib/reflections/guava-21.0.jar
    4742file.reference.hamcrest-core-1.3.jar=../test/lib/junit/hamcrest-core-1.3.jar
    4843file.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.jar
    5044file.reference.jfcunit.jar=../test/lib/jfcunit.jar
    5145file.reference.jmockit-1.41.jar=../test/lib/jmockit-1.41.jar
    5246file.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.jar
    5447file.reference.ognl-2.6.9.jar=../test/lib/unitils-core/ognl-2.6.9.jar
    5548file.reference.reflections-0.9.10.jar=../test/lib/reflections/reflections-0.9.10.jar
     
    8073    ${file.reference.equalsverifier-2.5.1.jar}:\
    8174    ${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}:\
    8975    ${file.reference.guava-21.0.jar}:\
    9076    ${file.reference.javassist-3.21.0-GA.jar}:\
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r14081 r14092  
    179179     */
    180180    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);
    182194        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
    183195            f.setAccessible(true);
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r13897 r14092  
    99import java.util.Arrays;
    1010
    11 import org.fest.util.Collections;
    1211import org.junit.Rule;
    1312import org.junit.Test;
     
    122121        ImageryLayerInfo.instance.loadDefaults(true, null, false);
    123122        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", "", "")));
    125124        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
    126125        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r13765 r14092  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import static org.openstreetmap.josm.TestUtils.getPrivateField;
    35
    46import java.io.FileInputStream;
     
    1214import java.util.Random;
    1315
    14 import org.fest.reflect.core.Reflection;
    15 import org.fest.reflect.reference.TypeRef;
    1616import org.junit.Assert;
    1717import org.junit.Rule;
     
    3838    public JOSMTestRules test = new JOSMTestRules();
    3939
    40     private void removeAllTest(DataSet ds) {
     40    @SuppressWarnings("unchecked")
     41    private void removeAllTest(DataSet ds) throws ReflectiveOperationException {
    4142        List<Node> allNodes = new ArrayList<>(ds.getNodes());
    4243        List<Way> allWays = new ArrayList<>(ds.getWays());
    4344        List<Relation> allRelations = new ArrayList<>(ds.getRelations());
    4445
    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");
    5050
    5151        int expectedCount = allNodes.size();
     
    7777    }
    7878
     79    /**
     80     * Test that all primitives can be removed from the Quad Buckets.
     81     * @throws Exception never
     82     */
    7983    @Test
    8084    public void testRemove() throws Exception {
     
    8690    }
    8791
     92    /**
     93     * Test that all primitives can be removed from the Quad Buckets, even if moved before.
     94     * @throws Exception never
     95     */
    8896    @Test
    8997    public void testMove() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java

    r12620 r14092  
    22package org.openstreetmap.josm.gui.conflict.pair.nodes;
    33
    4 import static org.fest.reflect.core.Reflection.field;
    5 import static org.fest.reflect.core.Reflection.method;
    64import static org.junit.Assert.assertEquals;
    75import static org.junit.Assert.assertFalse;
     
    119import java.beans.PropertyChangeEvent;
    1210import java.beans.PropertyChangeListener;
     11import java.lang.reflect.Method;
     12import java.security.AccessController;
     13import java.security.PrivilegedAction;
    1314import java.util.ArrayList;
    1415import java.util.Arrays;
     
    2021import org.junit.Rule;
    2122import org.junit.Test;
     23import org.openstreetmap.josm.TestUtils;
    2224import org.openstreetmap.josm.data.osm.Node;
    2325import org.openstreetmap.josm.data.osm.Way;
     26import org.openstreetmap.josm.gui.conflict.pair.AbstractListMergeModel;
    2427import org.openstreetmap.josm.testutils.DatasetFactory;
    2528import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4548    @SuppressWarnings("unchecked")
    4649    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        }
    5160    }
    5261
    5362    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");
    5774    }
    5875
     
    644661    @SuppressWarnings("unchecked")
    645662    @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 -> {
    653667        };
    654668
    655669        model.addPropertyChangeListener(listener);
    656670
    657         Set<PropertyChangeListener> listeners = field("listeners")
    658         .ofType(Set.class)
    659         .in(model)
    660         .get();
     671        Set<PropertyChangeListener> listeners = getListeners(model);
    661672
    662673        assertEquals(1, listeners.size());
     
    666677    @SuppressWarnings("unchecked")
    667678    @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 -> {
    675683        };
    676684
     
    678686        model.removePropertyChangeListener(listener);
    679687
    680         Set<PropertyChangeListener> listeners = field("listeners")
    681         .ofType(Set.class)
    682         .in(model)
    683         .get();
     688        Set<PropertyChangeListener> listeners = getListeners(model);
    684689
    685690        assertEquals(0, listeners.size());
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModelTest.java

    r10962 r14092  
    22package org.openstreetmap.josm.gui.conflict.pair.tags;
    33
    4 import static org.fest.reflect.core.Reflection.field;
    54import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertNull;
    76
    8 import java.beans.PropertyChangeEvent;
    97import java.beans.PropertyChangeListener;
    108import java.util.List;
     
    1311import org.junit.Rule;
    1412import org.junit.Test;
     13import org.openstreetmap.josm.TestUtils;
    1514import org.openstreetmap.josm.data.osm.Node;
    1615import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     
    3231    public JOSMTestRules test = new JOSMTestRules();
    3332
    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 -> {
    4145        };
    4246        model.addPropertyChangeListener(listener);
    4347
    44         Set<?> list = field("listeners").ofType(Set.class)
    45         .in(model)
    46         .get();
     48        Set<?> list = getListeners(model);
    4749
    4850        assertEquals(1, list.size());
     
    5153
    5254    @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 -> {
    5958        };
    6059        model.addPropertyChangeListener(listener);
    6160        model.removePropertyChangeListener(listener);
    6261
    63         Set<?> list = field("listeners")
    64         .ofType(Set.class)
    65         .in(model)
    66         .get();
     62        Set<?> list = getListeners(model);
    6763
    6864        assertEquals(0, list.size());
     
    7066
    7167    @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);
    8275
    8376        assertEquals(0, list.size());
     
    8578
    8679    @Test
    87     public void testPopulateNoConflicts1() {
     80    public void testPopulateNoConflicts1() throws ReflectiveOperationException {
    8881        Node my = new Node(1);
    8982        my.put("key", "value");
     
    9386        model.populate(my, their);
    9487
    95         List<TagMergeItem> list = field("tagMergeItems")
    96         .ofType(List.class)
    97         .in(model)
    98         .get();
     88        List<TagMergeItem> list = getTagMergeItems(model);
    9989
    10090        assertEquals(0, list.size());
     
    10292
    10393    @Test
    104     public void testPopulateMissingKeyMine() {
     94    public void testPopulateMissingKeyMine() throws ReflectiveOperationException {
    10595        Node my = new Node(1);
    10696        Node their = new Node(1);
     
    10999        model.populate(my, their);
    110100
    111         List<TagMergeItem> list = field("tagMergeItems")
    112         .ofType(List.class)
    113         .in(model)
    114         .get();
     101        List<TagMergeItem> list = getTagMergeItems(model);
    115102
    116103        assertEquals(1, list.size());
     
    123110
    124111    @Test
    125     public void testPopulateMissingKeyTheir() {
     112    public void testPopulateMissingKeyTheir() throws ReflectiveOperationException {
    126113        Node my = new Node(1);
    127114        my.put("key", "value");
     
    130117        model.populate(my, their);
    131118
    132         List<TagMergeItem> list = field("tagMergeItems")
    133         .ofType(List.class)
    134         .in(model)
    135         .get();
     119        List<TagMergeItem> list = getTagMergeItems(model);
    136120
    137121        assertEquals(1, list.size());
     
    144128
    145129    @Test
    146     public void testPopulateConflictingValues() {
     130    public void testPopulateConflictingValues() throws ReflectiveOperationException {
    147131        Node my = new Node(1);
    148132        my.put("key", "myvalue");
     
    152136        model.populate(my, their);
    153137
    154         List<TagMergeItem> list = field("tagMergeItems")
    155         .ofType(List.class)
    156         .in(model)
    157         .get();
     138        List<TagMergeItem> list = getTagMergeItems(model);
    158139
    159140        assertEquals(1, list.size());
     
    166147
    167148    @Test
    168     public void testAddItem() {
     149    public void testAddItem() throws ReflectiveOperationException {
    169150        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    170151        TagMergeModel model = new TagMergeModel();
    171152        model.addItem(item);
    172153
    173         List<TagMergeItem> list = field("tagMergeItems")
    174         .ofType(List.class)
    175         .in(model)
    176         .get();
     154        List<TagMergeItem> list = getTagMergeItems(model);
    177155
    178156        assertEquals(1, list.size());
     
    185163
    186164    @Test
    187     public void testDecide() {
     165    public void testDecide() throws ReflectiveOperationException {
    188166        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    189167        TagMergeModel model = new TagMergeModel();
    190168        model.addItem(item);
    191169
    192         List<TagMergeItem> list = field("tagMergeItems")
    193         .ofType(List.class)
    194         .in(model)
    195         .get();
     170        List<TagMergeItem> list = getTagMergeItems(model);
    196171
    197172        model.decide(0, MergeDecisionType.KEEP_MINE);
     
    212187
    213188    @Test
    214     public void testDecideMultiple() {
     189    public void testDecideMultiple() throws ReflectiveOperationException {
    215190
    216191        TagMergeModel model = new TagMergeModel();
     
    219194        }
    220195
    221         List<TagMergeItem> list = field("tagMergeItems")
    222         .ofType(List.class)
    223         .in(model)
    224         .get();
     196        List<TagMergeItem> list = getTagMergeItems(model);
    225197
    226198        assertEquals(10, list.size());
Note: See TracChangeset for help on using the changeset viewer.