-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from muzzammilshahid/interop-pubsub
Add Interoperability tests for PubSub
- Loading branch information
Showing
7 changed files
with
361 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import "package:collection/collection.dart"; | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Event", () { | ||
const equality = DeepCollectionEquality(); | ||
|
||
bool isEqual(Event msg1, Event msg2) => | ||
msg1.subscriptionID == msg2.subscriptionID && | ||
msg1.publicationID == msg2.publicationID && | ||
equality.equals(msg1.details, msg2.details) && | ||
equality.equals(msg1.args, msg2.args) && | ||
equality.equals(msg1.kwargs, msg2.kwargs); | ||
|
||
test("JSONSerializer", () async { | ||
var msg = Event(1, 1); | ||
var command = "message event ${msg.subscriptionID} ${msg.publicationID} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Event; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = Event(1, 1, args: ["abc"]); | ||
var command = "message event ${msg.subscriptionID} ${msg.publicationID} abc --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as Event; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = Event(1, 1, details: {"abc": 1}, args: ["abc"], kwargs: {"a": 1}); | ||
var command = | ||
"message event ${msg.subscriptionID} ${msg.publicationID} abc -d abc=1 -k a=1 --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as Event; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import "package:collection/collection.dart"; | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Publish", () { | ||
const equality = DeepCollectionEquality(); | ||
|
||
bool isEqual(Publish msg1, Publish msg2) => | ||
msg1.requestID == msg2.requestID && | ||
msg1.uri == msg2.uri && | ||
equality.equals(msg1.options, msg2.options) && | ||
equality.equals(msg1.args, msg2.args) && | ||
equality.equals(msg1.kwargs, msg2.kwargs); | ||
|
||
test("JSONSerializer", () async { | ||
var msg = Publish(1, "io.xconn.topic"); | ||
var command = "message publish ${msg.requestID} ${msg.uri} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Publish; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = Publish(1, "io.xconn.topic", args: ["abc"]); | ||
var command = "message publish ${msg.requestID} ${msg.uri} abc --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as Publish; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = Publish(1, "io.xconn.topic", options: {"abc": 1}, args: ["abc"], kwargs: {"a": 1}); | ||
var command = "message publish ${msg.requestID} ${msg.uri} abc -o abc=1 -k a=1 --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as Publish; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Published", () { | ||
bool isEqual(Published msg1, Published msg2) => | ||
msg1.requestID == msg2.requestID && msg1.publicationID == msg2.publicationID; | ||
|
||
test("JSONSerializer", () async { | ||
var msg = Published(1, 1); | ||
var command = "message published ${msg.requestID} ${msg.publicationID} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Published; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = Published(1, 1); | ||
var command = "message published ${msg.requestID} ${msg.publicationID} --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as Published; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = Published(1, 1); | ||
var command = "message published ${msg.requestID} ${msg.publicationID} --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as Published; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import "package:collection/collection.dart"; | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Subscribe", () { | ||
const equality = DeepCollectionEquality(); | ||
const topic = "io.xconn.test"; | ||
|
||
bool isEqual(Subscribe msg1, Subscribe msg2) => | ||
msg1.requestID == msg2.requestID && msg1.topic == msg2.topic && equality.equals(msg1.options, msg2.options); | ||
|
||
test("JSONSerializer", () async { | ||
var msg = Subscribe(1, topic); | ||
var command = "message subscribe ${msg.requestID} ${msg.topic} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Subscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = Subscribe(1, topic); | ||
var command = "message subscribe ${msg.requestID} ${msg.topic} --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as Subscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = Subscribe(1, topic, options: {"a": 1}); | ||
var command = "message subscribe ${msg.requestID} ${msg.topic} -o a=1 --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as Subscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Subscribed", () { | ||
bool isEqual(Subscribed msg1, Subscribed msg2) => | ||
msg1.requestID == msg2.requestID && msg1.subscriptionID == msg2.subscriptionID; | ||
|
||
test("JSONSerializer", () async { | ||
var msg = Subscribed(1, 1); | ||
var command = "message subscribed ${msg.requestID} ${msg.subscriptionID} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as Subscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = Subscribed(1, 1); | ||
var command = "message subscribed ${msg.requestID} ${msg.subscriptionID} --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as Subscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = Subscribed(1, 1); | ||
var command = "message subscribed ${msg.requestID} ${msg.subscriptionID} --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as Subscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Unsubscribed", () { | ||
bool isEqual(UnSubscribed msg1, UnSubscribed msg2) => msg1.requestID == msg2.requestID; | ||
|
||
test("JSONSerializer", () async { | ||
var msg = UnSubscribed(1); | ||
var command = "message unsubscribed ${msg.requestID} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as UnSubscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = UnSubscribed(1); | ||
var command = "message unsubscribed ${msg.requestID} --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as UnSubscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = UnSubscribed(1); | ||
var command = "message unsubscribed ${msg.requestID} --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as UnSubscribed; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import "package:pinenacl/encoding.dart"; | ||
import "package:test/test.dart"; | ||
|
||
import "package:wampproto/messages.dart"; | ||
import "package:wampproto/serializers.dart"; | ||
|
||
import "../helper.dart"; | ||
|
||
void main() { | ||
group("Unsubscribe", () { | ||
bool isEqual(UnSubscribe msg1, UnSubscribe msg2) => | ||
msg1.requestID == msg2.requestID && msg1.subscriptionID == msg2.subscriptionID; | ||
|
||
test("JSONSerializer", () async { | ||
var msg = UnSubscribe(1, 1); | ||
var command = "message unsubscribe ${msg.requestID} ${msg.subscriptionID} --serializer json"; | ||
|
||
var output = await runCommand(command); | ||
|
||
var jsonSerializer = JSONSerializer(); | ||
var message = jsonSerializer.deserialize(output) as UnSubscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("CBORSerializer", () async { | ||
var msg = UnSubscribe(1, 1); | ||
var command = "message unsubscribe ${msg.requestID} ${msg.subscriptionID} --serializer cbor --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var cborSerializer = CBORSerializer(); | ||
var message = cborSerializer.deserialize(outputBytes) as UnSubscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
|
||
test("MsgPackSerializer", () async { | ||
var msg = UnSubscribe(1, 1); | ||
var command = "message unsubscribe ${msg.requestID} ${msg.subscriptionID} --serializer msgpack --output hex"; | ||
|
||
var output = await runCommand(command); | ||
var outputBytes = Base16Encoder.instance.decode(output.trim()); | ||
|
||
var msgPackSerializer = MsgPackSerializer(); | ||
var message = msgPackSerializer.deserialize(outputBytes) as UnSubscribe; | ||
expect(isEqual(message, msg), true); | ||
}); | ||
}); | ||
} |