diff --git a/sonos-java/src/main/java/org/tensin/sonos/commands/ZoneCommandDispatcher.java b/sonos-java/src/main/java/org/tensin/sonos/commands/ZoneCommandDispatcher.java
index 675602c..cc2fb12 100644
--- a/sonos-java/src/main/java/org/tensin/sonos/commands/ZoneCommandDispatcher.java
+++ b/sonos-java/src/main/java/org/tensin/sonos/commands/ZoneCommandDispatcher.java
@@ -30,6 +30,11 @@ public class ZoneCommandDispatcher implements IZoneCommandDispatcher {
/** The Constant INSTANCE. */
private static final ZoneCommandDispatcher INSTANCE = new ZoneCommandDispatcher();
+ private ZoneCommandDispatcher()
+ {
+
+ }
+
/**
* Gets the single instance of ZoneCommandDispatcher.
*
@@ -145,6 +150,7 @@ public ZoneCommandExecutor registerZoneExecutor(final String zoneName) {
ZoneCommandExecutor executor;
synchronized (executors) {
if (!executors.containsKey(zoneNameUppercase)) {
+ LOGGER.info("new ZoneCommandExecutor thread spawned: " + zoneNameUppercase);
executor = new ZoneCommandExecutor(zoneNameUppercase);
executor.start();
executors.put(zoneNameUppercase, executor);
diff --git a/sonos-java/src/main/java/org/tensin/sonos/control/AbstractService.java b/sonos-java/src/main/java/org/tensin/sonos/control/AbstractService.java
index edf8afd..97f0043 100644
--- a/sonos-java/src/main/java/org/tensin/sonos/control/AbstractService.java
+++ b/sonos-java/src/main/java/org/tensin/sonos/control/AbstractService.java
@@ -125,7 +125,7 @@ public static Service findService(final RemoteDevice device, final String servic
* the type
*/
public AbstractService(final UpnpService upnpService, final Service service, final String type) {
- if (!service.getServiceType().toString().equals(type)) {
+ if (service != null && !service.getServiceType().toString().equals(type)) {
throw new IllegalArgumentException("service must be " + type + ", not " + service.getServiceType());
}
diff --git a/sonos-java/src/main/java/org/tensin/sonos/control/ZonePlayer.java b/sonos-java/src/main/java/org/tensin/sonos/control/ZonePlayer.java
index bcdfc59..556f88d 100644
--- a/sonos-java/src/main/java/org/tensin/sonos/control/ZonePlayer.java
+++ b/sonos-java/src/main/java/org/tensin/sonos/control/ZonePlayer.java
@@ -18,6 +18,7 @@
import java.net.UnknownHostException;
import org.teleal.cling.UpnpService;
+import org.teleal.cling.model.meta.Device;
import org.teleal.cling.model.meta.RemoteDevice;
import org.tensin.sonos.SonosException;
import org.tensin.sonos.model.Entry;
@@ -325,4 +326,13 @@ public void playQueueEntry(final int index) throws SonosException {
serv.play();
}
}
+
+ @Override
+ public String toString() {
+
+ return String.format("%s ZonePlayer[%s, ip = %s]",
+ dev.getDetails().getModelDetails().getModelNumber(),
+ dev.getDisplayString(),
+ ip);
+ }
}
diff --git a/sonos-java/src/main/java/org/tensin/sonos/helpers/RemoteDeviceHelper.java b/sonos-java/src/main/java/org/tensin/sonos/helpers/RemoteDeviceHelper.java
index 79396a6..b2ccbcc 100644
--- a/sonos-java/src/main/java/org/tensin/sonos/helpers/RemoteDeviceHelper.java
+++ b/sonos-java/src/main/java/org/tensin/sonos/helpers/RemoteDeviceHelper.java
@@ -1,6 +1,7 @@
package org.tensin.sonos.helpers;
import org.teleal.cling.model.meta.Action;
+import org.teleal.cling.model.meta.Device;
import org.teleal.cling.model.meta.RemoteDevice;
import org.teleal.cling.model.meta.Service;
import org.teleal.cling.model.types.ServiceType;
@@ -19,6 +20,9 @@ public class RemoteDeviceHelper {
* @return the string
*/
public static String dumpRemoteDevice(final RemoteDevice device) {
+ return dumpDevice(device);
+ }
+ public static String dumpDevice(final Device device) {
final StringBuilder sb = new StringBuilder();
sb.append(device.toString()).append(SonosConstants.NEWLINE);
@@ -38,18 +42,24 @@ public static String dumpRemoteDevice(final RemoteDevice device) {
sb.append(" Model Number [").append(device.getDetails().getModelDetails().getModelNumber()).append("]").append(SonosConstants.NEWLINE);
sb.append(" Model URI [").append(device.getDetails().getModelDetails().getModelURI()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" Identity :").append(SonosConstants.NEWLINE);
- sb.append(" UDN [").append(device.getIdentity().getUdn()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" Descriptor URL [").append(device.getIdentity().getDescriptorURL()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" Discovered on local address [").append(device.getIdentity().getDiscoveredOnLocalAddress()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" Interface MAC addresss [").append(device.getIdentity().getInterfaceMacAddress()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" Max age (seconds) [").append(device.getIdentity().getMaxAgeSeconds()).append("]").append(SonosConstants.NEWLINE);
- sb.append(" WoL bytes [").append(device.getIdentity().getWakeOnLANBytes()).append("]").append(SonosConstants.NEWLINE);
-
+ if(device instanceof RemoteDevice){
+ RemoteDevice rdevice = (RemoteDevice)device;
+ sb.append(" Identity :").append(SonosConstants.NEWLINE);
+ sb.append(" UDN [").append(device.getIdentity().getUdn()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" Descriptor URL [").append(rdevice.getIdentity().getDescriptorURL()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" Discovered on local address [").append(rdevice.getIdentity().getDiscoveredOnLocalAddress()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" Interface MAC addresss [").append(rdevice.getIdentity().getInterfaceMacAddress()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" Max age (seconds) [").append(rdevice.getIdentity().getMaxAgeSeconds()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" WoL bytes [").append(rdevice.getIdentity().getWakeOnLANBytes()).append("]").append(SonosConstants.NEWLINE);
+ }else{
+ sb.append(" Identity :").append(SonosConstants.NEWLINE);
+ sb.append(" UDN [").append(device.getIdentity().getUdn()).append("]").append(SonosConstants.NEWLINE);
+ sb.append(" Max age (seconds) [").append(device.getIdentity().getMaxAgeSeconds()).append("]").append(SonosConstants.NEWLINE);
+ }
sb.append(" Identity [").append(device.getVersion().toString()).append("]").append(SonosConstants.NEWLINE);
sb.append(" Embedded devices :").append(SonosConstants.NEWLINE);
- for (final RemoteDevice remoteDevice : device.findEmbeddedDevices()) {
+ for (final Device remoteDevice : device.findEmbeddedDevices()) {
sb.append(" - ").append(remoteDevice.toString()).append(SonosConstants.NEWLINE);
}
diff --git a/sonos-java/src/main/java/org/tensin/sonos/model/ZonePlayerModel.java b/sonos-java/src/main/java/org/tensin/sonos/model/ZonePlayerModel.java
index 7a41a78..f611964 100644
--- a/sonos-java/src/main/java/org/tensin/sonos/model/ZonePlayerModel.java
+++ b/sonos-java/src/main/java/org/tensin/sonos/model/ZonePlayerModel.java
@@ -39,6 +39,24 @@ public ZonePlayerModel() {
}
+ /**
+ * Checks if is zone player already defined.
+ *
+ * @param UDN
+ * the udn
+ * @return true, if is zone player already defined
+ */
+ public boolean containsZonePlayer(final String UDN) {
+ ZonePlayer other = null;
+ for (final ZonePlayer zone : getAllZones()) {
+ if (zone.getRootDevice().getIdentity().getUdn().getIdentifierString().equals(UDN)) {
+ other = zone;
+ break;
+ }
+ }
+ return (other != null);
+ }
+
/**
* Adds the given zone player to the list in a sorted order.
*
diff --git a/sonos-java/src/test/java/org/tensin/sonos/CLITestCase.java b/sonos-java/src/test/java/org/tensin/sonos/ClientIT.java
similarity index 92%
rename from sonos-java/src/test/java/org/tensin/sonos/CLITestCase.java
rename to sonos-java/src/test/java/org/tensin/sonos/ClientIT.java
index 2fa3057..c7ce258 100644
--- a/sonos-java/src/test/java/org/tensin/sonos/CLITestCase.java
+++ b/sonos-java/src/test/java/org/tensin/sonos/ClientIT.java
@@ -17,11 +17,13 @@
/**
* The Class CLITestCase.
*/
-public class CLITestCase {
+public class ClientIT {
/** The zone command dispatcher. */
private final ZoneCommandDispatcher zoneCommandDispatcher = ZoneCommandDispatcher.getInstance();
+ private static final String TEST_ROOM_ONE = "salon";
+ private static final String TEST_ROOM_TWO = "chambre";
/**
* Sets the up.
*/
@@ -82,7 +84,7 @@ public void testDummyCommand() throws SonosException {
*/
@Test
public void testList() throws SonosException {
- CLIController.main(new String[] { "--command", "list", "A:", "--zone", "salon" });
+ CLIController.main(new String[] { "--command", "list", "A:", "--zone", TEST_ROOM_ONE});
}
/**
@@ -93,13 +95,13 @@ public void testList() throws SonosException {
*/
@Test
public void testMute() throws SonosException {
- CLIController.main(new String[] { "--command", "mute", "--zone", "salon" });
+ CLIController.main(new String[] { "--command", "mute", "--zone",TEST_ROOM_ONE });
- ZoneCommandExecutor executor = zoneCommandDispatcher.getZoneCommandExecutor("SALON");
+ ZoneCommandExecutor executor = zoneCommandDispatcher.getZoneCommandExecutor(TEST_ROOM_ONE.toUpperCase());
Assert.assertTrue(executor != null);
Assert.assertEquals(1, executor.getExecutedCommandsCount());
- executor = zoneCommandDispatcher.getZoneCommandExecutor("CHAMBRE");
+ executor = zoneCommandDispatcher.getZoneCommandExecutor(TEST_ROOM_TWO.toUpperCase());
Assert.assertTrue(executor != null);
Assert.assertEquals(0, executor.getExecutedCommandsCount());
}
@@ -112,7 +114,7 @@ public void testMute() throws SonosException {
*/
@Test
public void testNext() throws SonosException {
- CLIController.main(new String[] { "--command", "next", "--zone", "chambre" });
+ CLIController.main(new String[] { "--command", "next", "--zone", TEST_ROOM_TWO });
}
/**
@@ -134,7 +136,7 @@ public void testPause() throws SonosException {
*/
@Test
public void testPlay() throws SonosException {
- CLIController.main(new String[] { "--command", "play", "--zone", "salon" });
+ CLIController.main(new String[] { "--command", "play", "--zone", TEST_ROOM_ONE });
}
/**
@@ -182,7 +184,7 @@ public void testUnknownZone() throws SonosException {
*/
@Test
public void testUnmute() throws SonosException {
- CLIController.main(new String[] { "--command", "unmute", "--zone", "salon" });
+ CLIController.main(new String[] { "--command", "unmute", "--zone", TEST_ROOM_ONE });
}
/**
@@ -204,7 +206,7 @@ public void testUsage() throws SonosException {
*/
@Test
public void testVolume() throws SonosException {
- CLIController.main(new String[] { "--command", "volume", "--zone", "chambre" });
+ CLIController.main(new String[] { "--command", "volume", "--zone", TEST_ROOM_TWO });
}
/**
@@ -215,7 +217,7 @@ public void testVolume() throws SonosException {
*/
@Test
public void testVolumeDown() throws SonosException {
- CLIController.main(new String[] { "--command", "down", "--zone", "chambre" });
+ CLIController.main(new String[] { "--command", "down", "--zone", TEST_ROOM_TWO });
}
/**
@@ -226,7 +228,7 @@ public void testVolumeDown() throws SonosException {
*/
@Test
public void testVolumeSet() throws SonosException {
- CLIController.main(new String[] { "--command", "volume", "25", "--zone", "chambre" });
+ CLIController.main(new String[] { "--command", "volume", "25", "--zone", TEST_ROOM_TWO });
}
/**
@@ -237,7 +239,7 @@ public void testVolumeSet() throws SonosException {
*/
@Test
public void testVolumeUp() throws SonosException {
- CLIController.main(new String[] { "--command", "up", "--zone", "chambre" });
+ CLIController.main(new String[] { "--command", "up", "--zone", TEST_ROOM_TWO });
}
}
diff --git a/sonos-java/src/test/java/org/tensin/sonos/ClingTestCase.java b/sonos-java/src/test/java/org/tensin/sonos/ClingIT.java
similarity index 99%
rename from sonos-java/src/test/java/org/tensin/sonos/ClingTestCase.java
rename to sonos-java/src/test/java/org/tensin/sonos/ClingIT.java
index 8c7b2e4..ee96aca 100644
--- a/sonos-java/src/test/java/org/tensin/sonos/ClingTestCase.java
+++ b/sonos-java/src/test/java/org/tensin/sonos/ClingIT.java
@@ -13,7 +13,7 @@
/**
* The Class ClingTestCase.
*/
-public class ClingTestCase {
+public class ClingIT {
/**
* Test discovery.
diff --git a/sonos-root/pom.xml b/sonos-root/pom.xml
index c7d8392..fe7fb59 100644
--- a/sonos-root/pom.xml
+++ b/sonos-root/pom.xml
@@ -104,7 +104,19 @@
compile
-
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.12.4
+
+
+
+ integration-test
+ verify
+
+
+
+
maven-eclipse-plugin
2.8
diff --git a/sonos-web/src/main/java/org/tensin/sonos/web/SonosState.java b/sonos-web/src/main/java/org/tensin/sonos/web/SonosState.java
index 3f0cea6..5bf19f6 100644
--- a/sonos-web/src/main/java/org/tensin/sonos/web/SonosState.java
+++ b/sonos-web/src/main/java/org/tensin/sonos/web/SonosState.java
@@ -20,7 +20,7 @@
public class SonosState implements ISonosState {
/** The zone command dispatcher. */
- private final ZoneCommandDispatcher zoneCommandDispatcher = new ZoneCommandDispatcher();
+ private final ZoneCommandDispatcher zoneCommandDispatcher = ZoneCommandDispatcher.getInstance();
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(SonosState.class);