@Test public void ByteArrayBase64EncodeSerializeDeserializeDecodeTest() throws Exception { byte[] dati = new byte[] { (byte) 0x03, (byte) 0x08, (byte) 0x60, (byte) 0x99 }; Base64.encodeBase64(dati); Gson gson = GsonParserBuilder.getInstance(); String serializedMessage = gson.toJson(dati); System.out.println(serializedMessage.toString()); byte[] gsondecoded = gson.fromJson(serializedMessage, byte[].class); System.out.println(Arrays.equals(dati, gsondecoded)); assert (Arrays.equals(dati, gsondecoded)); }
public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); DeployMessageType getMessageType(); void setMessageType(DeployMessageType messageType); String toString(); DeployPayload getPayload(); BrokerMessageTypes getMType(); PeerCard[] getReceivers(); }
DeployMessage implements BrokerMessage { public String toString() { String serializedMessage = null; try { Gson gson = GsonParserBuilder.getInstance(); serializedMessage = gson.toJson(this); } catch (Exception e) { e.printStackTrace(); } return serializedMessage; } DeployMessage(DeployMessageType messageType, DeployPayload payload);  DeployMessage(); DeployMessageType getMessageType(); void setMessageType(DeployMessageType messageType); String toString(); DeployPayload getPayload(); BrokerMessageTypes getMType(); PeerCard[] getReceivers(); public BrokerMessageTypes mType; }