Skip to content

Commit

Permalink
[max] Revert of openhab#8418 and move standard max tests to binding (o…
Browse files Browse the repository at this point in the history
…penhab#8423)

This reverts commit 6aa1793.
It breaks the build because test fails.

Moved standard unit test to binding itself.

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
  • Loading branch information
Hilbrand authored and markus7017 committed Sep 18, 2020
1 parent fe27e51 commit 4d15c36
Show file tree
Hide file tree
Showing 24 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.Device;
import org.openhab.binding.max.internal.device.RoomInformation;
Expand Down Expand Up @@ -165,7 +165,7 @@ public String getCommandString() {

}

final String encodedString = Base64.getEncoder().encodeToString(message.toByteArray());
final String encodedString = Base64.encodeBase64StringUnChunked(message.toByteArray());
final StringBuilder commandStringBuilder = new StringBuilder();
int parts = (int) Math.round(encodedString.length() / MAX_MSG_LENGTH + 0.5);
for (int i = 0; i < parts; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
*/
package org.openhab.binding.max.internal.command;

import java.util.Base64;

import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.ThermostatModeType;

Expand Down Expand Up @@ -97,7 +96,7 @@ public String getCommandString() {

final String commandString = baseString + rfAddress + Utils.toHex(roomId) + Utils.toHex(bits);

final String encodedString = Base64.getEncoder().encodeToString(Utils.hexStringToByteArray(commandString));
final String encodedString = Base64.encodeBase64String(Utils.hexStringToByteArray(commandString));

return "s:" + encodedString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
*/
package org.openhab.binding.max.internal.command;

import java.util.Base64;

import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -152,7 +151,7 @@ public String getCommandString() {
commandString = commandString + Utils.toHex(roomId) + commandConfigString;
}

String encodedString = Base64.getEncoder().encodeToString(Utils.hexStringToByteArray(commandString));
String encodedString = Base64.encodeBase64String(Utils.hexStringToByteArray(commandString));
return "s:" + encodedString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
package org.openhab.binding.max.internal.command;

import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ public String getCommandString() {
for (String rfAddress : rfAddresses) {
commandArray = ArrayUtils.addAll(Utils.hexStringToByteArray(rfAddress), commandArray);
}
String encodedString = Base64.getEncoder().encodeToString(commandArray);
String encodedString = Base64.encodeBase64StringUnChunked(commandArray);

return "t:" + String.format("%02d", rfAddresses.size()) + "," + updateForced + "," + encodedString + '\r'
+ '\n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.DeviceType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -67,7 +67,8 @@ public CMessage(String raw) {
String[] tokens = this.getPayload().split(Message.DELIMETER);

rfAddress = tokens[0];
byte[] bytes = Base64.getDecoder().decode((tokens[1].getBytes(StandardCharsets.UTF_8)));

byte[] bytes = Base64.decodeBase64(tokens[1].getBytes(StandardCharsets.UTF_8));

int[] data = new int[bytes.length];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collection;
import java.util.List;

import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.Device;
import org.openhab.binding.max.internal.device.DeviceConfiguration;
Expand All @@ -39,7 +39,7 @@ public LMessage(String raw) {
public Collection<? extends Device> getDevices(List<DeviceConfiguration> configurations) {
final List<Device> devices = new ArrayList<>();

final byte[] decodedRawMessage = Base64.getDecoder().decode(getPayload().getBytes(StandardCharsets.UTF_8));
final byte[] decodedRawMessage = Base64.decodeBase64(getPayload().getBytes(StandardCharsets.UTF_8));

final MaxTokenizer tokenizer = new MaxTokenizer(decodedRawMessage);

Expand All @@ -55,7 +55,7 @@ public Collection<? extends Device> getDevices(List<DeviceConfiguration> configu
}

public Collection<? extends Device> updateDevices(List<Device> devices, List<DeviceConfiguration> configurations) {
byte[] decodedRawMessage = Base64.getDecoder().decode(getPayload().getBytes(StandardCharsets.UTF_8));
byte[] decodedRawMessage = Base64.decodeBase64(getPayload().getBytes(StandardCharsets.UTF_8));

MaxTokenizer tokenizer = new MaxTokenizer(decodedRawMessage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.DeviceInformation;
import org.openhab.binding.max.internal.device.DeviceType;
Expand Down Expand Up @@ -49,7 +49,7 @@ public MMessage(String raw) {
return;
}
try {
byte[] bytes = Base64.getDecoder().decode(tokens[2].getBytes(StandardCharsets.UTF_8));
byte[] bytes = Base64.decodeBase64(tokens[2].getBytes(StandardCharsets.UTF_8));

hasConfiguration = true;
logger.trace("*** M Message trace**** ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
package org.openhab.binding.max.internal.message;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

import org.apache.commons.net.util.Base64;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.DeviceType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -45,8 +45,8 @@ public NMessage(String raw) {

if (msgPayload.length() > 0) {
try {
decodedPayload = new String(Base64.getDecoder().decode(msgPayload), StandardCharsets.UTF_8);
byte[] bytes = Base64.getDecoder().decode(msgPayload);
decodedPayload = new String(Base64.decodeBase64(msgPayload), StandardCharsets.UTF_8);
byte[] bytes = Base64.decodeBase64(msgPayload);

deviceType = DeviceType.create(bytes[0] & 0xFF);
rfAddress = Utils.toHex(bytes[1] & 0xFF, bytes[2] & 0xFF, bytes[3] & 0xFF);
Expand Down

0 comments on commit 4d15c36

Please sign in to comment.