Changeset 6881 in josm
- Timestamp:
- 2014-02-24T17:49:12+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java
r6093 r6881 11 11 import org.openstreetmap.josm.tools.ImageProvider; 12 12 13 14 13 /** 15 14 * Creates a new relation with a copy of the current editor state … … 17 16 */ 18 17 public class DuplicateRelationAction extends AbstractRelationAction { 19 18 20 19 /** 21 * Constructs a new {@code DuplicateRelationAction}. 20 * Constructs a new {@code DuplicateRelationAction}. 22 21 */ 23 22 public DuplicateRelationAction() { … … 27 26 } 28 27 28 /** 29 * Duplicates the given relation and launches the relation editor for the created copy. 30 * @param original The relation to duplicate 31 */ 29 32 public static void duplicateRelationAndLaunchEditor(Relation original) { 30 33 Relation copy = new Relation(original, true); … … 50 53 // only one selected relation can be edited 51 54 setEnabled( relations.size()==1 ); 52 } 55 } 53 56 } -
trunk/src/org/openstreetmap/josm/command/AddCommand.java
r6380 r6881 17 17 18 18 /** 19 * A command that adds an osm primitive to a dataset. Keys cannot be added this 20 * way. 19 * A command that adds an osm primitive to a dataset. Keys cannot be added this way. 21 20 * 22 21 * See {@link ChangeCommand} for comments on relation back references. … … 32 31 33 32 /** 34 * Create the command and specify the element to add. 33 * Creates the command and specify the element to add in the context of the current edit layer, if any. 34 * @param osm The primitive to add 35 35 */ 36 36 public AddCommand(OsmPrimitive osm) { 37 super();38 37 this.osm = osm; 39 38 } 40 39 41 40 /** 42 * Create the command and specify the element to add. 41 * Creates the command and specify the element to add in the context of the given data layer. 42 * @param layer The data layer. Must not be {@code null} 43 * @param osm The primitive to add 43 44 */ 44 45 public AddCommand(OsmDataLayer layer, OsmPrimitive osm) { … … 47 48 } 48 49 49 @Override public boolean executeCommand() { 50 @Override 51 public boolean executeCommand() { 50 52 getLayer().data.addPrimitive(osm); 51 53 osm.setModified(true); … … 53 55 } 54 56 55 @Override public void undoCommand() { 57 @Override 58 public void undoCommand() { 56 59 getLayer().data.removePrimitive(osm); 57 60 } 58 61 59 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 62 @Override 63 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 60 64 added.add(osm); 61 65 } -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r6380 r6881 27 27 private final OsmPrimitive newOsm; 28 28 29 /** 30 * Constructs a new {@code ChangeCommand} in the context of the current edit layer, if any. 31 * @param osm The existing primitive to modify 32 * @param newOsm The new primitive 33 */ 29 34 public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) { 30 super();31 35 this.osm = osm; 32 36 this.newOsm = newOsm; … … 34 38 } 35 39 40 /** 41 * Constructs a new {@code ChangeCommand} in the context of a given data layer. 42 * @param layer The data layer 43 * @param osm The existing primitive to modify 44 * @param newOsm The new primitive 45 */ 36 46 public ChangeCommand(OsmDataLayer layer, OsmPrimitive osm, OsmPrimitive newOsm) { 37 47 super(layer); … … 40 50 sanityChecks(); 41 51 } 42 52 43 53 private void sanityChecks() { 44 54 CheckParameterUtil.ensureParameterNotNull(osm, "osm"); -
trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java
r4918 r6881 6 6 import java.util.Collection; 7 7 import java.util.List; 8 8 9 import javax.swing.Icon; 9 10 10 11 import org.openstreetmap.josm.data.osm.Node; 11 import org.openstreetmap.josm.data.osm.Way;12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 14 import org.openstreetmap.josm.data.osm.Way; 14 15 import org.openstreetmap.josm.gui.DefaultNameFormatter; 15 16 import org.openstreetmap.josm.tools.ImageProvider; … … 28 29 private final List<Node> newNodes; 29 30 31 /** 32 * Constructs a new {@code ChangeNodesCommand}. 33 * @param way The way to modify 34 * @param newNodes The new list of nodes for the given way 35 */ 30 36 public ChangeNodesCommand(Way way, List<Node> newNodes) { 31 super();32 37 this.way = way; 33 38 this.newNodes = newNodes; 34 39 } 35 40 36 @Override public boolean executeCommand() { 41 @Override 42 public boolean executeCommand() { 37 43 super.executeCommand(); 38 44 way.setNodes(newNodes); … … 41 47 } 42 48 43 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 49 @Override 50 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 44 51 modified.add(way); 45 52 } -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r6679 r6881 49 49 */ 50 50 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, AbstractMap<String, String> tags) { 51 super();52 51 this.objects = new LinkedList<OsmPrimitive>(); 53 52 this.tags = tags; … … 184 183 185 184 if (allnull) { 186 /* I18n: plural form detected for objects only (but value < 2 not possible!), try to do your best for tags */ 185 /* I18n: plural form detected for objects only (but value < 2 not possible!), try to do your best for tags */ 187 186 text = trn("Deleted {0} tags for {1} object", "Deleted {0} tags for {1} objects", objects.size(), tags.size(), objects.size()); 188 187 } else { … … 222 221 } 223 222 223 /** 224 * Returns the tags to set (key/value pairs). 225 * @return the tags to set (key/value pairs) 226 */ 224 227 public Map<String, String> getTags() { 225 228 return Collections.unmodifiableMap(tags); -
trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r6830 r6881 33 33 private Boolean oldModified; 34 34 35 /** 36 * Constructs a new {@code ChangeRelationMemberRoleCommand}. 37 * @param relation The relation to be changed 38 * @param position Member position 39 * @param newRole New role 40 */ 35 41 public ChangeRelationMemberRoleCommand(Relation relation, int position, String newRole) { 36 super();37 42 this.relation = relation; 38 43 this.position = position; … … 40 45 } 41 46 42 @Override public boolean executeCommand() { 47 @Override 48 public boolean executeCommand() { 43 49 if (position < 0 || position >= relation.getMembersCount()) 44 50 return false; … … 53 59 } 54 60 55 @Override public void undoCommand() { 61 @Override 62 public void undoCommand() { 56 63 relation.setMember(position, new RelationMember(oldRole, relation.getMember(position).getMember())); 57 64 relation.setModified(oldModified); 58 65 } 59 66 60 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 67 @Override 68 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 61 69 modified.add(relation); 62 70 } -
trunk/src/org/openstreetmap/josm/command/Command.java
r6639 r6881 3 3 4 4 import java.awt.GridBagLayout; 5 import java.awt.geom.Area;6 5 import java.util.ArrayList; 7 6 import java.util.Collection; … … 160 159 * 161 160 */ 162 protected 161 protected OsmDataLayer getLayer() { 163 162 return layer; 164 163 } -
trunk/src/org/openstreetmap/josm/command/ConflictResolveCommand.java
r6248 r6881 21 21 private ConflictCollection resolvedConflicts; 22 22 23 /** 24 * Constructs a new {@code ConflictResolveCommand} in the context of the current edit layer, if any. 25 */ 23 26 public ConflictResolveCommand() { 24 27 super(); … … 26 29 } 27 30 31 /** 32 * Constructs a new {@code ConflictResolveCommand} in the context of a given data layer. 33 * @param layer the data layer. Must not be null. 34 */ 28 35 public ConflictResolveCommand(OsmDataLayer layer) { 29 36 super(layer); -
trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java
r5816 r6881 5 5 6 6 import java.util.Collection; 7 7 8 import javax.swing.Icon; 8 9 … … 14 15 15 16 /** 16 * Represents a the resolution of a conflict between the coordinates of two {@link Node}s17 * Represents the resolution of a conflict between the coordinates of two {@link Node}s. 17 18 * 18 19 */ -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r6639 r6881 348 348 349 349 if (alsoDeleteNodesInWay) { 350 // delete untagged nodes only referenced by primitives in primitivesToDelete, 351 // too 350 // delete untagged nodes only referenced by primitives in primitivesToDelete, too 352 351 Collection<Node> nodesToDelete = computeNodesToDelete(layer, primitivesToDelete); 353 352 primitivesToDelete.addAll(nodesToDelete); … … 371 370 } 372 371 373 // get a confirmation that the objects to delete can be removed from their parent 374 // relations 372 // get a confirmation that the objects to delete can be removed from their parent relations 375 373 // 376 374 if (!silent) { -
trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r5816 r6881 9 9 10 10 import org.openstreetmap.josm.data.conflict.Conflict; 11 import org.openstreetmap.josm.data.osm.Node;12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 12 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 16 15 17 16 /** 18 * Represents a the resolution of a conflict between the coordinates of two {@link Node}s17 * Represents the resolution of a conflict between the deleted flag of two {@link OsmPrimitive}s. 19 18 * 20 19 */ -
trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java
r5926 r6881 15 15 16 16 /** 17 * Represents a command for to set the modified flag {@link OsmPrimitive}17 * Represents the resolution of a conflict between the modified flag of two {@link OsmPrimitive}s. 18 18 * 19 19 * -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r6380 r6881 53 53 private List<OldNodeState> oldState = new LinkedList<OldNodeState>(); 54 54 55 /** 56 * Constructs a new {@code MoveCommand} to move a primitive. 57 * @param osm The primitive to move 58 * @param x X difference movement. Coordinates are in northern/eastern 59 * @param y Y difference movement. Coordinates are in northern/eastern 60 */ 55 61 public MoveCommand(OsmPrimitive osm, double x, double y) { 56 62 this(Collections.singleton(osm), x, y); 57 63 } 58 64 65 /** 66 * Constructs a new {@code MoveCommand} to move a node. 67 * @param node The node to move 68 */ 59 69 public MoveCommand(Node node, LatLon position) { 60 70 this(Collections.singleton((OsmPrimitive) node), node.getEastNorth().sub(Projections.project(position))); 61 71 } 62 72 73 /** 74 * Constructs a new {@code MoveCommand} to move a collection of primitives. 75 * @param objects The primitives to move 76 * @param offset The movement vector 77 */ 63 78 public MoveCommand(Collection<OsmPrimitive> objects, EastNorth offset) { 64 79 this(objects, offset.getX(), offset.getY()); … … 66 81 67 82 /** 68 * Create a MoveCommand and assign the initial object set and movement vector. 83 * Constructs a new {@code MoveCommand} and assign the initial object set and movement vector. 84 * @param objects The primitives to move 85 * @param x X difference movement. Coordinates are in northern/eastern 86 * @param y Y difference movement. Coordinates are in northern/eastern 69 87 */ 70 88 public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) { 71 super();72 89 startEN = null; 73 90 saveCheckpoint(); // (0,0) displacement will be saved … … 97 114 * The move is immediately executed and any undo will undo both vectors to 98 115 * the original position the objects had before first moving. 116 * 117 * @param x X difference movement. Coordinates are in northern/eastern 118 * @param y Y difference movement. Coordinates are in northern/eastern 99 119 */ 100 120 public void moveAgain(double x, double y) { … … 157 177 } 158 178 159 @Override public boolean executeCommand() { 179 @Override 180 public boolean executeCommand() { 160 181 for (Node n : nodes) { 161 182 // in case #3892 happens again … … 171 192 } 172 193 173 @Override public void undoCommand() { 194 @Override 195 public void undoCommand() { 174 196 Iterator<OldNodeState> it = oldState.iterator(); 175 197 for (Node n : nodes) { … … 180 202 } 181 203 182 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 204 @Override 205 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 183 206 for (OsmPrimitive osm : nodes) { 184 207 modified.add(osm); -
trunk/src/org/openstreetmap/josm/command/RelationMemberConflictResolverCommand.java
r6336 r6881 17 17 18 18 /** 19 * Represent a command for resolving conflicts in the member lists of two 20 * {@link Relation}s. 19 * Represents the resolution of conflicts in the member list of two {@link Relation}s. 21 20 * 22 21 */ 23 public class RelationMemberConflictResolverCommand extends Co mmand {22 public class RelationMemberConflictResolverCommand extends ConflictResolveCommand { 24 23 /** my relation */ 25 24 private final Relation my; … … 30 29 */ 31 30 private final List<RelationMember> mergedMembers; 32 33 /** the layer this conflict is resolved in */34 private OsmDataLayer layer;35 31 36 32 /** … … 62 58 super.executeCommand(); 63 59 64 // replace the list of members of 'my' relation by the list of merged 65 // members 60 // replace the list of members of 'my' relation by the list of merged members 66 61 // 67 62 my.setMembers(mergedMembers); 68 63 69 // remember the layer70 layer = Main.main.getEditLayer();71 64 return true; 72 65 } … … 80 73 @Override 81 74 public void undoCommand() { 75 OsmDataLayer layer = getLayer(); 82 76 if (! Main.map.mapView.hasLayer(layer)) { 83 77 Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", -
trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java
r6316 r6881 12 12 13 13 import org.openstreetmap.josm.data.osm.Node; 14 import org.openstreetmap.josm.data.osm.Way;15 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 import org.openstreetmap.josm.data.osm.Way; 17 17 import org.openstreetmap.josm.gui.DefaultNameFormatter; 18 18 import org.openstreetmap.josm.tools.ImageProvider; … … 30 30 private final Set<Node> rmNodes; 31 31 32 /** 33 * Constructs a new {@code RemoveNodesCommand}. 34 * @param way The way to modify 35 * @param rmNodes The list of nodes to remove 36 */ 32 37 public RemoveNodesCommand(Way way, List<Node> rmNodes) { 33 super();34 38 this.way = way; 35 39 this.rmNodes = new HashSet<Node>(rmNodes); 36 40 } 37 41 38 @Override public boolean executeCommand() { 42 @Override 43 public boolean executeCommand() { 39 44 super.executeCommand(); 40 45 way.removeNodes(rmNodes); … … 43 48 } 44 49 45 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 50 @Override 51 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 46 52 modified.add(way); 47 53 } -
trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java
r6679 r6881 2 2 package org.openstreetmap.josm.command; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 import static org.openstreetmap.josm.tools.I18n.tr;6 4 import static org.openstreetmap.josm.tools.I18n.trn; 7 5 8 6 import java.util.Collection; 9 7 import java.util.List; 8 10 9 import javax.swing.Icon; 11 12 10 13 11 import org.openstreetmap.josm.data.conflict.Conflict; … … 19 17 20 18 /** 21 * Represents a the resolution of a tag conflict in an {@link OsmPrimitive}19 * Represents the resolution of a tag conflict in an {@link OsmPrimitive}. 22 20 * 23 21 */ -
trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java
r5816 r6881 6 6 7 7 import java.util.Collection; 8 8 9 import javax.swing.Icon; 9 10 … … 14 15 15 16 /** 16 * Represents a command for resolving a version conflict between two {@link OsmPrimitive}17 * Represents the resolution of a version conflict between two {@link OsmPrimitive}s. 17 18 * 18 19 * -
trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java
r6248 r6881 17 17 18 18 /** 19 * Represent a command for resolving conflicts in the node list of two 20 * {@link Way}s. 19 * Represents the resolution of conflicts in the node list of two {@link Way}s. 21 20 * 22 21 */ … … 39 38 this.mergedNodeList = mergedNodeList; 40 39 } 40 41 41 @Override 42 42 public String getDescriptionText() { -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r6316 r6881 393 393 * 394 394 * See {@link #getConflicts()} for a map of conflicts after the merge operation. 395 * @param progressMonitor The progress monitor 395 396 */ 396 397 public void merge(ProgressMonitor progressMonitor) { -
trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java
r5927 r6881 14 14 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 15 15 16 /** 17 * Reader for <a href="http://wiki.openstreetmap.org/wiki/OsmChange">OsmChange</a> file format. 18 */ 16 19 public class OsmChangeReader extends OsmReader { 17 20 21 /** 22 * List of possible actions. 23 */ 18 24 public static final String[] ACTIONS = {"create", "modify", "delete"}; 19 25 20 26 /** 21 27 * constructor (for private and subclasses use only) … … 25 31 protected OsmChangeReader() { 26 32 } 27 28 /* (non-Javadoc) 29 * @see org.openstreetmap.josm.io.OsmReader#parseRoot() 30 */ 33 31 34 @Override 32 35 protected void parseRoot() throws XMLStreamException { … … 43 46 throwException(tr("Missing mandatory attribute ''{0}''.", "version")); 44 47 } 45 if (! v.equals("0.6")) {48 if (!"0.6".equals(v)) { 46 49 throwException(tr("Unsupported version: {0}", v)); 47 50 } … … 87 90 } 88 91 } 89 92 90 93 /** 91 94 * Parse the given input source and return the dataset. -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java
r6264 r6881 60 60 } 61 61 62 /** 63 * Constructs a new {@code NodeListMergerTest}. 64 */ 62 65 public NodeListMergerTest() { 63 66 build(); … … 70 73 test.setVisible(true); 71 74 } 72 73 74 75 } -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java
r5556 r6881 35 35 } 36 36 37 /** 38 * Constructs a new {@code PropertiesMergerTest}. 39 */ 37 40 public PropertiesMergerTest() { 38 41 build(); … … 45 48 app.setVisible(true); 46 49 } 47 48 50 } -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java
r3034 r6881 39 39 } 40 40 41 /** 42 * Constructs a new {@code RelationMemberMergerTest}. 43 */ 41 44 public RelationMemberMergerTest() { 42 45 build(); -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergerTest.java
r2041 r6881 6 6 import javax.swing.JFrame; 7 7 8 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeItem;9 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMerger;10 11 8 public class TagMergerTest extends JFrame { 12 9 13 10 private TagMerger tagMerger; 14 11 15 12 protected void build() { 16 13 tagMerger = new TagMerger(); 17 14 getContentPane().setLayout(new BorderLayout()); 18 getContentPane().add(tagMerger, BorderLayout.CENTER); 15 getContentPane().add(tagMerger, BorderLayout.CENTER); 19 16 } 20 17 18 /** 19 * Constructs a new {@code TagMergerTest}. 20 */ 21 21 public TagMergerTest() { 22 22 build(); … … 29 29 } 30 30 } 31 31 32 32 public static void main(String args[]) { 33 33 TagMergerTest test = new TagMergerTest(); … … 35 35 test.setVisible(true); 36 36 } 37 38 37 } -
trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java
r3034 r6881 17 17 dialog = new ConflictResolutionDialog(this); 18 18 dialog.setSize(600,600); 19 } 19 20 20 21 }22 21 protected void populate() { 23 22 Way w1 = new Way(1); … … 36 35 } 37 36 37 /** 38 * Constructs a new {@code ConflictResolutionDialogTest}. 39 */ 38 40 public ConflictResolutionDialogTest() { 39 41 build(); -
trunk/test/functional/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java
r2690 r6881 7 7 8 8 private ChangesetCacheManager manager; 9 10 public ChangesetCacheManagerTest() {11 }12 9 13 10 public void start() { -
trunk/test/functional/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialogTest.java
r2986 r6881 8 8 private ChangesetQueryDialog dialog; 9 9 10 public ChangesetQueryDialogTest() {11 }12 13 10 public void start() { 14 11 dialog = new ChangesetQueryDialog(this); … … 17 14 } 18 15 19 20 16 static public void main(String args[]) { 21 17 new ChangesetQueryDialogTest().start(); -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r6289 r6881 229 229 private DataSet ds; 230 230 231 231 /** 232 * Setup test. 233 */ 232 234 @Before 233 235 public void setUp() throws IOException, IllegalDataException { -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r6289 r6881 236 236 private DataSet ds; 237 237 238 /** 239 * Setup test. 240 */ 238 241 @Before 239 242 public void setUp() throws IOException, IllegalDataException { -
trunk/test/unit/org/openstreetmap/TestUtils.java
r6601 r6881 2 2 package org.openstreetmap; 3 3 4 import org.junit.Before; 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 6 import static org.junit.Assert.assertTrue; 7 8 import java.util.Map; 9 5 10 import org.junit.Test; 6 11 import org.openstreetmap.josm.Main; … … 10 15 import org.openstreetmap.josm.data.osm.Way; 11 16 import org.openstreetmap.josm.tools.TextTagParser; 12 13 import java.util.Map;14 15 import static org.hamcrest.CoreMatchers.is;16 import static org.junit.Assert.assertThat;17 import static org.junit.Assert.assertTrue;18 17 19 18 public class TestUtils { -
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r6471 r6881 5 5 import org.junit.Test; 6 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.data.Preferences;8 7 import org.openstreetmap.josm.data.osm.Node; 9 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 11 10 public class SearchCompilerTest { 12 11 12 /** 13 * Setup test. 14 */ 13 15 @Before 14 public void setUp() throws Exception{16 public void setUp() { 15 17 Main.initApplicationPreferences(); 16 18 } -
trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java
r6471 r6881 6 6 import org.junit.Test; 7 7 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.Preferences;9 8 import org.openstreetmap.josm.data.osm.Tag; 10 9 … … 21 20 Main.initApplicationPreferences(); 22 21 } 23 22 24 23 /** 25 24 * Test of {@link ReverseWayTagCorrector.TagSwitcher#apply} method. … … 93 92 assertSwitch(new Tag("type", "drawdown"), new Tag("type", "drawdown")); 94 93 } 95 94 96 95 private void assertSwitch(Tag oldTag, Tag newTag) { 97 96 Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag); -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r6801 r6881 12 12 import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException; 13 13 import org.openstreetmap.josm.data.APIDataSet; 14 import org.openstreetmap.josm.data.Preferences;15 16 14 17 15 public class APIDataSetTest { -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r6471 r6881 18 18 import org.junit.Test; 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.data.Preferences;21 20 import org.openstreetmap.josm.data.coor.LatLon; 22 21 import org.openstreetmap.josm.data.projection.Projections; 23 22 24 23 public class DataSetMergerTest { 25 /*private static Logger logger = Logger.getLogger(DataSetMergerTest.class.getName());26 27 static Properties testProperties;28 29 @BeforeClass30 static public void init() {31 32 if(System.getProperty("josm.home") == null){33 testProperties = new Properties();34 35 // load properties36 //37 try {38 testProperties.load(DataSetMergerTest.class.getResourceAsStream("/test-unit-env.properties"));39 } catch(Exception e){40 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));41 fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));42 }43 44 // check josm.home45 //46 String josmHome = testProperties.getProperty("josm.home");47 if (josmHome == null) {48 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));49 } else {50 File f = new File(josmHome);51 if (! f.exists() || ! f.canRead()) {52 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));53 }54 }55 System.setProperty("josm.home", josmHome);56 }57 Main.pref.init(false);58 59 // init projection60 Main.proj = new Mercator();61 }*/62 24 63 25 @BeforeClass … … 69 31 private DataSet their; 70 32 33 /** 34 * Setup test. 35 */ 71 36 @Before 72 37 public void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r6471 r6881 17 17 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 18 18 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 19 import org.openstreetmap.josm.data.Preferences;20 19 import org.openstreetmap.josm.data.coor.LatLon; 21 20 import org.openstreetmap.josm.data.projection.Projections; … … 24 23 import org.openstreetmap.josm.io.OsmReader; 25 24 26 27 25 public class FilterTest { 28 26 27 /** 28 * Setup test. 29 */ 29 30 @BeforeClass 30 31 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandling.java
r6830 r6881 36 36 37 37 /** 38 * Add a tag to an empty node and test the query and get methods. 39 * 38 * Adds a tag to an empty node and test the query and get methods. 40 39 */ 41 40 @Test … … 51 50 52 51 /** 53 * Add two tags to an empty node and test the query and get methods.52 * Adds two tags to an empty node and test the query and get methods. 54 53 */ 55 54 @Test … … 68 67 69 68 /** 70 * Remove tags from a node with two tags and test the state of the node. 71 * 69 * Removes tags from a node with two tags and test the state of the node. 72 70 */ 73 71 @Test … … 96 94 97 95 /** 98 * Remove all tags from a node 99 * 96 * Removes all tags from a node. 100 97 */ 101 98 @Test … … 132 129 * Test hasEqualSemanticAttributes on two nodes with different tags. 133 130 */ 134 135 131 @Test 136 132 public void hasEqualSemanticAttributes_2() { … … 147 143 assertTrue(!n1.hasEqualSemanticAttributes(n2)); 148 144 } 149 150 145 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r6471 r6881 9 9 import org.junit.Test; 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.Preferences;12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.projection.Projections; … … 27 26 private DataSet dataSet = new DataSet(); 28 27 28 /** 29 * Setup test. 30 */ 29 31 @BeforeClass 30 32 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r6471 r6881 14 14 import org.junit.Test; 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.Preferences;17 16 import org.openstreetmap.josm.data.coor.LatLon; 18 17 import org.openstreetmap.josm.data.projection.Projections; … … 82 81 removeAllTest(ds); 83 82 } 84 85 83 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
r6471 r6881 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.data.Preferences;11 10 import org.openstreetmap.josm.data.coor.LatLon; 12 11 import org.openstreetmap.josm.data.projection.Projections; … … 14 13 public class RelationTest { 15 14 15 /** 16 * Setup test. 17 */ 16 18 @BeforeClass 17 19 public static void setUp() { … … 104 106 Assert.assertEquals(new BBox(w1), r1.getBBox()); 105 107 } 106 107 108 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java
r4603 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm.history; 3 4 3 5 4 import static org.junit.Assert.assertEquals; -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r6471 r6881 12 12 import org.junit.Test; 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.Preferences;15 14 import org.openstreetmap.josm.data.coor.LatLon; 16 15 import org.openstreetmap.josm.data.osm.DataSet; … … 35 34 } 36 35 36 /** 37 * Setup test. 38 */ 37 39 @BeforeClass 38 40 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r6334 r6881 41 41 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 42 42 } 43 //System.err.println(String.format("maxerror lat: %s maxerror lon: %s", maxErrLat, maxErrLon));44 43 } 45 44 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r6471 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 3 5 4 import java.io.BufferedReader; … … 25 24 import org.openstreetmap.josm.Main; 26 25 import org.openstreetmap.josm.data.Bounds; 27 import org.openstreetmap.josm.data.Preferences;28 26 import org.openstreetmap.josm.data.coor.EastNorth; 29 27 import org.openstreetmap.josm.data.coor.LatLon; … … 147 145 } 148 146 147 /** 148 * Setup test. 149 */ 149 150 @BeforeClass 150 151 public static void setUp() { … … 198 199 throw new AssertionError(fail.toString()); 199 200 } 200 201 201 } 202 202 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r6334 r6881 12 12 public class ProjectionTest { 13 13 14 private static final boolean debug = false;15 14 private static Random rand = new Random(System.currentTimeMillis()); 16 15 … … 64 63 double maxErrLat = 0, maxErrLon = 0; 65 64 Bounds b = p.getWorldBoundsLatLon(); 66 65 67 66 text += String.format("*** %s %s%n", p.toString(), p.toCode()); 68 67 for (int num=0; num < 1000; ++num) { 69 68 70 69 double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat(); 71 70 double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon(); 72 71 73 72 LatLon ll = new LatLon(lat, lon); 74 73 75 74 for (int i=0; i<10; ++i) { 76 75 EastNorth en = p.latlon2eastNorth(ll); … … 80 79 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 81 80 } 82 81 83 82 String mark = ""; 84 83 if (maxErrLat + maxErrLon > 1e-5) { -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r6334 r6881 13 13 private boolean debug = false; 14 14 15 /** 16 * Setup test. 17 */ 15 18 @BeforeClass 16 19 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateNodeTest.java
r6471 r6881 7 7 import org.junit.Test; 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.data.Preferences;10 9 import org.openstreetmap.josm.data.coor.LatLon; 11 10 import org.openstreetmap.josm.data.osm.DataSet; … … 15 14 16 15 /** 17 * JUnit Test of "Duplicate node" validation test. 16 * JUnit Test of "Duplicate node" validation test. 18 17 */ 19 18 public class DuplicateNodeTest { 20 19 21 20 /** 22 * Setup test by initializing JOSM preferences and projection. 21 * Setup test by initializing JOSM preferences and projection. 23 22 */ 24 23 @BeforeClass … … 44 43 test.visit(ds.allPrimitives()); 45 44 test.endTest(); 46 45 47 46 assertEquals(1, test.getErrors().size()); 48 47 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6677 r6881 28 28 public class MapCSSTagCheckerTest { 29 29 30 /** 31 * Setup test. 32 */ 30 33 @Before 31 34 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r6858 r6881 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import org.junit.Before; 5 import org.junit.Test; 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.data.osm.Tag; 8 import org.openstreetmap.josm.data.validation.Severity; 9 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 10 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 11 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 12 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems; 13 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 14 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction; 4 import static org.CustomMatchers.hasSize; 5 import static org.CustomMatchers.isEmpty; 6 import static org.hamcrest.CoreMatchers.is; 7 import static org.hamcrest.CoreMatchers.not; 8 import static org.junit.Assert.assertThat; 15 9 16 10 import java.util.Arrays; … … 20 14 import java.util.Set; 21 15 22 import static org.CustomMatchers.hasSize; 23 import static org.CustomMatchers.isEmpty; 24 import static org.hamcrest.CoreMatchers.is; 25 import static org.hamcrest.CoreMatchers.not; 26 import static org.junit.Assert.assertThat; 16 import org.junit.Before; 17 import org.junit.Test; 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.data.osm.Tag; 20 import org.openstreetmap.josm.data.validation.Severity; 21 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 22 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 23 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems; 24 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 27 25 28 26 /** 29 * JUnit Test of "Opening hours" validation test. 27 * JUnit Test of "Opening hours" validation test. 30 28 */ 31 29 public class OpeningHourTestTest { … … 33 31 private static final OpeningHourTest OPENING_HOUR_TEST = new OpeningHourTest(); 34 32 33 /** 34 * Setup test. 35 */ 35 36 @Before 36 37 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java
r6603 r6881 19 19 UnconnectedWays bib; 20 20 21 /** 22 * Setup test. 23 */ 21 24 @Before 22 25 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java
r6471 r6881 1 1 package org.openstreetmap.josm.gui; 2 2 3 import static org.junit.Assert.*; 3 import static org.junit.Assert.assertEquals; 4 5 import java.text.DecimalFormat; 6 import java.text.DecimalFormatSymbols; 7 import java.util.Locale; 4 8 5 9 import org.junit.BeforeClass; 6 10 import org.junit.Test; 7 11 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.Preferences;9 12 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement; 10 11 import java.text.DecimalFormat;12 import java.text.DecimalFormatSymbols;13 import java.util.Locale;14 13 15 14 /** … … 25 24 Main.initApplicationPreferences(); 26 25 } 27 26 28 27 /** 29 28 * Test of {@link SystemOfMeasurement#getDistText} method. … … 31 30 @Test 32 31 public void testGetDistText() { 33 32 34 33 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1)); 35 34 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99)); … … 38 37 39 38 assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01)); 40 39 41 40 assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99)); 42 41 assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0)); … … 67 66 } 68 67 68 /** 69 * Test of {@link SystemOfMeasurement#getDistText} method with a non-English locale. 70 */ 69 71 @Test 70 72 public void testGetDistTextLocalized() { … … 88 90 89 91 assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01)); 90 92 91 93 assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99)); 92 94 assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0)); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r6471 r6881 13 13 import org.junit.Test; 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.Preferences;16 15 import org.openstreetmap.josm.data.conflict.Conflict; 17 16 import org.openstreetmap.josm.data.coor.LatLon; … … 51 50 } 52 51 52 /** 53 * Setup test. 54 */ 53 55 @Before 54 56 public void setUp() { … … 141 143 model.deleteObserver(observerTest); 142 144 } 143 144 145 145 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r6562 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging; 3 4 import static org.CustomMatchers.hasSize; 5 import static org.hamcrest.CoreMatchers.is; 6 import static org.junit.Assert.assertThat; 7 8 import java.io.IOException; 9 import java.util.Collection; 10 import java.util.List; 3 11 4 12 import org.junit.Assert; … … 10 18 import org.xml.sax.SAXException; 11 19 12 import java.io.IOException;13 import java.util.Collection;14 import java.util.List;15 16 import static org.CustomMatchers.hasSize;17 import static org.hamcrest.CoreMatchers.is;18 import static org.junit.Assert.assertThat;19 20 20 /** 21 21 * Unit tests of {@link TaggingPresetReader} class. … … 23 23 public class TaggingPresetReaderTest { 24 24 25 /** 26 * Setup test. 27 */ 25 28 @BeforeClass 26 public static void setUp Class() {29 public static void setUp() { 27 30 Main.initApplicationPreferences(); 28 31 } … … 30 33 /** 31 34 * Gets path to test data directory for given ticketid. 32 * @param ticketid 33 * @return 35 * @param ticketid 36 * @return 34 37 */ 35 38 protected static String getRegressionDataDir(int ticketid) { … … 41 44 * @param ticketid 42 45 * @param filename 43 * @return 46 * @return 44 47 */ 45 48 protected static String getRegressionDataFile(int ticketid, String filename) { … … 85 88 Assert.assertTrue("Default presets are empty", presets.size()>0); 86 89 } 87 88 90 } -
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r6471 r6881 10 10 import org.junit.Test; 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.Preferences;13 12 14 13 public class TextTagParserTest { 14 15 /** 16 * Setup test. 17 */ 15 18 @BeforeClass 16 public static void before() {19 public static void setUp() { 17 20 Main.initApplicationPreferences(); 18 21 } … … 26 29 s = "\"2 \\\"3\\\" 4\""; s1 = "2 \"3\" 4"; 27 30 Assert.assertEquals(s1, TextTagParser.unescape(s)); 28 31 29 32 s = "\"2 3 ===4===\""; s1 = "2 3 ===4==="; 30 33 Assert.assertEquals(s1, TextTagParser.unescape(s)); … … 33 36 Assert.assertEquals(s1, TextTagParser.unescape(s)); 34 37 } 35 38 36 39 @Test 37 40 public void testTNformat() { … … 63 66 tags = TextTagParser.readTagsFromText(txt); 64 67 Assert.assertEquals(correctTags, tags); 65 68 66 69 txt = "\"a\" : \"1 1 1\", \"b2\" :\"2 \\\"3 qwe\\\" 4\""; 67 70 correctTags= new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4");}}; 68 71 tags = TextTagParser.readTagsFromText(txt); 69 72 Assert.assertEquals(correctTags, tags); 70 73 71 74 txt = " \"aыыы\" : \"val\\\"\\\"\\\"ue1\""; 72 75 correctTags= new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1");} }; … … 74 77 Assert.assertEquals(correctTags, tags); 75 78 } 76 79 77 80 @Test 78 81 public void testFreeformat() { … … 84 87 Assert.assertEquals(correctTags, tags); 85 88 } 86 89 87 90 @Test 88 91 public void errorDetect() { … … 90 93 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 91 94 Assert.assertEquals(Collections.EMPTY_MAP, tags); 92 95 93 96 } 94 97 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java
r6471 r6881 19 19 public class TemplateEngineTest { 20 20 21 /** 22 * Setup test. 23 */ 21 24 @BeforeClass 22 public static void before() {25 public static void setUp() { 23 26 Main.initApplicationPreferences(); 24 27 }
Note:
See TracChangeset
for help on using the changeset viewer.