Index: /src/org/openstreetmap/josm/actions/CombineWayAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 270)
+++ /src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 271)
@@ -84,5 +84,6 @@
 				p.add(c, GBC.eol());
 				components.put(e.getKey(), c);
-			}
+			} else
+				newWay.put(e.getKey(), e.getValue().iterator().next());
 		}
 		if (!components.isEmpty()) {
Index: /src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 270)
+++ /src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 271)
@@ -106,10 +106,11 @@
 	}
 
-	public void setSelected(OsmPrimitive osm) {
+	public void setSelected(OsmPrimitive... osm) {
 		clearSelection();
-		if (osm == null)
+		if (osm.length == 0)
 			return;
-		osm.selected = true;
-		fireSelectionChanged(Arrays.asList(new OsmPrimitive[]{osm}));
+		for (OsmPrimitive o : osm)
+			o.selected = true;
+		fireSelectionChanged(Arrays.asList(osm));
 	}
 
Index: /test/org/openstreetmap/josm/actions/CombineWayActionTest.java
===================================================================
--- /test/org/openstreetmap/josm/actions/CombineWayActionTest.java	(revision 271)
+++ /test/org/openstreetmap/josm/actions/CombineWayActionTest.java	(revision 271)
@@ -0,0 +1,83 @@
+package org.openstreetmap.josm.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.openstreetmap.josm.testframework.MotherObject.createSegment;
+import static org.openstreetmap.josm.testframework.MotherObject.createWay;
+
+import javax.swing.Action;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Segment;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.testframework.MainMock;
+import org.openstreetmap.josm.testframework.MotherObject;
+
+
+public class CombineWayActionTest extends MainMock {
+
+	private Action action = Main.main.menu.combineWay;
+	private Way way1;
+	private Way way2;
+	private Segment segment1;
+	private Segment segment2;
+
+	@Before public void createTwoWays() {
+		Main.ds = new DataSet();
+		MotherObject.dataSet = Main.ds;
+		segment1 = createSegment();
+		segment2 = createSegment();
+		way1 = createWay(segment1);
+		way2 = createWay(segment2);
+		Main.ds.setSelected(way1, way2);
+	}
+	
+	@Test public void noSelectionBreaks() throws Exception {
+		Main.ds.setSelected();
+		action.actionPerformed(null);
+		assertPopup();
+	}
+	
+	@Test public void oneSelectedWayBreaks() throws Exception {
+		Main.ds.setSelected(way1);
+		action.actionPerformed(null);
+		assertPopup();
+	}
+	
+	@Test public void segmentsAreMergedInNewWay() throws Exception {
+	    action.actionPerformed(null);
+	    Way w = way1.deleted ? way2 : way1;
+	    assertFalse(w.deleted);
+	    assertEquals(2, w.segments.size());
+    }
+	
+	@Test public void nonConflictingPropertiesAreMerged() throws Exception {
+	    way1.put("foo", "bar");
+	    way2.put("baz", "imi");
+	    
+	    action.actionPerformed(null);
+	    Way w = way1.deleted ? way2 : way1;
+
+	    assertEquals(2, w.keys.size());
+	    assertEquals("bar", w.get("foo"));
+	    assertEquals("imi", w.get("baz"));
+    }
+	
+	@Test public void conflictingPropertiesOpenResolveDialog() throws Exception {
+	    way1.put("foo", "bar");
+	    way2.put("foo", "baz");
+	    way2.put("imi", "ada");
+	    
+	    action.actionPerformed(null);
+	    assertPopup();
+	    Way w = way1.deleted ? way2 : way1;
+
+	    assertEquals(2, w.keys.size());
+	    assertTrue(w.get("foo").equals("bar") || w.get("foo").equals("bar"));
+	    assertEquals("ada", w.get("imi"));
+	}
+}
Index: /test/org/openstreetmap/josm/testframework/MainMock.java
===================================================================
--- /test/org/openstreetmap/josm/testframework/MainMock.java	(revision 270)
+++ /test/org/openstreetmap/josm/testframework/MainMock.java	(revision 271)
@@ -1,10 +1,19 @@
 package org.openstreetmap.josm.testframework;
 
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.Toolkit;
+import java.awt.event.AWTEventListener;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 
+import javax.swing.JButton;
+import javax.swing.JDialog;
 import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
 
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.openstreetmap.josm.Main;
@@ -15,4 +24,10 @@
 public class MainMock {
 
+	private static JDialog lastPopup;
+
+	@Before public void clearFoundPopup() {
+		lastPopup = null;
+	}
+	
 	@BeforeClass public static void mockMain() throws Exception {
 		Main.pref = new Preferences(){
@@ -27,3 +42,31 @@
 		Main.main = new Main(){};
 	}
+
+	@BeforeClass public static void startPopupKiller() throws AWTException {
+		Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){
+			public void eventDispatched(AWTEvent event) {
+				if (event.getSource() instanceof JButton) {
+					JButton b = (JButton)event.getSource();
+					if (b.getParent().getParent() instanceof JOptionPane) {
+						lastPopup = (JDialog)SwingUtilities.getRoot(b);
+						b.doClick();
+					}
+				}
+            }
+		}, AWTEvent.FOCUS_EVENT_MASK);
+    }
+
+	public void assertPopup() {
+		waitForPopup();
+		lastPopup = null;
+	}
+
+	public JDialog waitForPopup() {
+	    for (int i = 0; i < 100; ++i) {
+			if (lastPopup != null)
+				return lastPopup;
+			try {Thread.sleep(10);} catch (InterruptedException e) {}
+		}
+		throw new AssertionError("Expected Popup dialog");
+    }
 }
Index: /test/org/openstreetmap/josm/testframework/MotherObject.java
===================================================================
--- /test/org/openstreetmap/josm/testframework/MotherObject.java	(revision 270)
+++ /test/org/openstreetmap/josm/testframework/MotherObject.java	(revision 271)
@@ -16,6 +16,8 @@
 import org.openstreetmap.josm.data.projection.Epsg4326;
 
-public class MotherObject extends TestCase {
+abstract public class MotherObject extends TestCase {
 
+	public static DataSet dataSet;
+	
 	@Override protected void setUp() throws Exception {
 	    super.setUp();
@@ -23,9 +25,9 @@
     }
 
-	public Node createNode(int id) {
+	public static Node createNode(int id) {
 		return createNode(id, 0, 0);
 	}
 	
-	public Node createNode(int id, double lat, double lon) {
+	public static Node createNode(int id, double lat, double lon) {
 		Node n = createNode(lat, lon);
 		n.id = id;
@@ -33,42 +35,50 @@
 	}
 
-	public Node createNode() {
+	public static Node createNode() {
 		return createNode(Math.random()*360-180, Math.random()*180-90);
 	}
 
-	public Node createNode(double lat, double lon) {
-	    return new Node(new LatLon(lat,lon));
+	public static Node createNode(double lat, double lon) {
+	    Node node = new Node(new LatLon(lat,lon));
+	    if (dataSet != null)
+	    	dataSet.nodes.add(node);
+		return node;
     }
 	
 	
-	public Segment createSegment(long id) {
+	public static Segment createSegment(long id) {
 		Segment s = createSegment();
 		s.id = id;
 		return s;
 	}
-	public Segment createSegment(long id, Node from, Node to) {
+	public static Segment createSegment(long id, Node from, Node to) {
 		Segment s = new Segment(from, to);
 		s.id = id;
 		return s;
 	}
-	public Segment createSegment() {
-		return new Segment(createNode(), createNode());
+	public static Segment createSegment() {
+		Segment segment = new Segment(createNode(), createNode());
+		if (dataSet != null)
+			dataSet.segments.add(segment);
+		return segment;
 	}
 	
 	
-	public Way createWay() {
+	public static Way createWay() {
 		return createWay(0);
 	}
-	public Way createWay(Segment... segments) {
+	public static Way createWay(Segment... segments) {
 		return createWay(0, segments);
 	}
-	public Way createWay(long id, Segment... segments) {
+	public static Way createWay(long id, Segment... segments) {
 		Way way = new Way();
 		way.segments.addAll(Arrays.asList(segments));
 		way.id = id;
+		if (dataSet != null)
+			dataSet.ways.add(way);
 		return way;
 	}
 	
-	public DataSet createDataSet() {
+	public static DataSet createDataSet() {
 	    DataSet ds = new DataSet();
 		Node node1 = createNode();
@@ -85,14 +95,8 @@
     }
 
-	public void assertContainsSame(Collection<OsmPrimitive> data, OsmPrimitive... all) {
+	public static void assertContainsSame(Collection<OsmPrimitive> data, OsmPrimitive... all) {
 		Collection<OsmPrimitive> copy = new LinkedList<OsmPrimitive>(data);
 		copy.removeAll(Arrays.asList(all));
 		assertEquals(0, copy.size());
     }
-	
-	/**
-	 * To have JUnit shut up.
-	 */
-	public void test() {
-	}
 }
