# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import java.net.NetworkInterface import java.net.InetAddress import vertx from test_utils import TestUtils tu = TestUtils() tu.check_thread() peer1 = vertx.create_datagram_socket() peer2 = vertx.create_datagram_socket() class DatagramTest(object): def test_send_receive(self): @peer2.exception_handler def exception_handler(err): tu.azzert(False) def peer2_listen_handler(err, serv): tu.check_thread() tu.azzert(err is None) tu.azzert(serv == peer2)
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import vertx from test_utils import TestUtils from core.event_bus import EventBus tu = TestUtils() tu.check_thread() class EventBusTest(object): def test_simple_send(self): json = {'message' : 'hello world!'} address = "some-address" def handler(msg): tu.azzert(msg.body['message'] == json['message']) EventBus.unregister_handler(id) tu.test_complete() id = EventBus.register_handler(address, handler=handler) tu.azzert(id != None) EventBus.send(address, json) def test_send_empty(self):