[bosesoundtouch] Fix regression and add tests (#14097)
* Fix regression and add tests Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
@@ -155,7 +155,6 @@ public class CommandExecutor implements AvailableSources {
|
||||
contentItem.setPresetID(presetID);
|
||||
|
||||
currentContentItem = contentItem;
|
||||
|
||||
}
|
||||
updateOperatingValues();
|
||||
}
|
||||
|
||||
@@ -97,11 +97,6 @@ public class XMLResponseHandler extends DefaultHandler {
|
||||
// showing a
|
||||
// warning for unhandled states
|
||||
|
||||
XMLHandlerState localState = null;
|
||||
if (stateMap != null) {
|
||||
localState = stateMap.get(localName);
|
||||
}
|
||||
|
||||
switch (curState) {
|
||||
case INIT:
|
||||
if ("updates".equals(localName)) {
|
||||
@@ -112,10 +107,13 @@ public class XMLResponseHandler extends DefaultHandler {
|
||||
state = XMLHandlerState.Unprocessed;
|
||||
}
|
||||
} else {
|
||||
XMLHandlerState localState = stateMap.get(localName);
|
||||
if (localState == null) {
|
||||
logger.debug("{}: Unhandled XML entity during {}: '{}", handler.getDeviceName(), curState,
|
||||
logger.warn("{}: Unhandled XML entity during {}: '{}", handler.getDeviceName(), curState,
|
||||
localName);
|
||||
state = XMLHandlerState.Unprocessed;
|
||||
} else {
|
||||
state = localState;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -196,9 +194,11 @@ public class XMLResponseHandler extends DefaultHandler {
|
||||
state = XMLHandlerState.Presets;
|
||||
} else if ("group".equals(localName)) {
|
||||
this.masterDeviceId = new BoseSoundTouchConfiguration();
|
||||
state = stateMap.get(localName);
|
||||
} else {
|
||||
if (localState == null) {
|
||||
logger.debug("{}: Unhandled XML entity during {}: '{}", handler.getDeviceName(), curState,
|
||||
state = stateMap.get(localName);
|
||||
if (state == null) {
|
||||
logger.warn("{}: Unhandled XML entity during {}: '{}", handler.getDeviceName(), curState,
|
||||
localName);
|
||||
|
||||
state = XMLHandlerState.Unprocessed;
|
||||
@@ -366,16 +366,12 @@ public class XMLResponseHandler extends DefaultHandler {
|
||||
if (contentItem == null) {
|
||||
contentItem = new ContentItem();
|
||||
}
|
||||
String source = "";
|
||||
String location = "";
|
||||
String sourceAccount = "";
|
||||
Boolean isPresetable = false;
|
||||
|
||||
if (attributes != null) {
|
||||
source = attributes.getValue("source");
|
||||
sourceAccount = attributes.getValue("sourceAccount");
|
||||
location = attributes.getValue("location");
|
||||
isPresetable = Boolean.parseBoolean(attributes.getValue("isPresetable"));
|
||||
String source = attributes.getValue("source");
|
||||
String location = attributes.getValue("location");
|
||||
String sourceAccount = attributes.getValue("sourceAccount");
|
||||
Boolean isPresetable = Boolean.parseBoolean(attributes.getValue("isPresetable"));
|
||||
|
||||
if (source != null) {
|
||||
contentItem.setSource(source);
|
||||
|
||||
@@ -47,6 +47,7 @@ public class XMLResponseProcessor {
|
||||
|
||||
public void handleMessage(String msg) throws SAXException, IOException, ParserConfigurationException {
|
||||
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
|
||||
parserFactory.setNamespaceAware(true);
|
||||
SAXParser parser = parserFactory.newSAXParser();
|
||||
XMLReader reader = parser.getXMLReader();
|
||||
reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
|
||||
@@ -306,6 +306,14 @@ public class BoseSoundTouchHandler extends BaseThingHandler implements WebSocket
|
||||
return commandExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the CommandExecutor of this handler
|
||||
*
|
||||
*/
|
||||
public void setCommandExecutor(@Nullable CommandExecutor commandExecutor) {
|
||||
this.commandExecutor = commandExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Session this handler has opened
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user