You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jr...@apache.org on 2018/03/20 18:33:37 UTC
[2/9] qpid-proton git commit: PROTON-1799: Remove deprecated bindings
and APIs
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/lib/messenger/subscription.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/subscription.rb b/proton-c/bindings/ruby/lib/messenger/subscription.rb
deleted file mode 100644
index 49fb50e..0000000
--- a/proton-c/bindings/ruby/lib/messenger/subscription.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-
-
-module Qpid::Proton::Messenger
-
- # A +Subscription+ is an opaque object for working with a +Messenger+'s
- # subscriptions.
- #
- class Subscription
-
- def initialize(impl) # :nodoc:
- @impl = impl
- end
-
- def impl # :nodoc:
- @impl
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/lib/messenger/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/tracker.rb b/proton-c/bindings/ruby/lib/messenger/tracker.rb
deleted file mode 100644
index 5fb98e5..0000000
--- a/proton-c/bindings/ruby/lib/messenger/tracker.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-
-
-module Qpid::Proton::Messenger
-
- # A +Tracker+ is used to track the disposition of a +Message+.
- #
- class Tracker
-
- CUMULATIVE = Cproton::PN_CUMULATIVE
-
- def initialize(impl) # :nodoc:
- @impl = impl
- end
-
- def impl # :nodoc:
- @impl
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/lib/messenger/tracker_status.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb
deleted file mode 100644
index ab77683..0000000
--- a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# 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.
-
-
-module Qpid::Proton::Messenger
-
- # TrackerStatus contains symbols that represent the status value for a
- # Tracker.
- #
- class TrackerStatus
-
- def initialize value, name # :nodoc:
- @value = value
- @name = name
- end
-
- def value # :nodoc:
- @value
- end
-
- def to_s # :nodoc:
- @name.to_s
- end
-
- def self.by_name(name) # :nodoc:
- @by_name[name.to_sym] unless name.nil?
- end
-
- def self.by_value(value) # :nodoc:
- @by_value[value] unless value.nil?
- end
-
- private
-
- def self.add_item(key, value) # :nodoc:
- @by_name ||= {}
- @by_name[key] = TrackerStatus.new value, key
- @by_value ||= {}
- @by_value[value] = @by_name[key]
- end
-
- def self.const_missing(key) # :nodoc:
- @by_name[key]
- end
-
- self.add_item :UNKNOWN, Cproton::PN_STATUS_UNKNOWN
- self.add_item :PENDING, Cproton::PN_STATUS_PENDING
- self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED
- self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED
- self.add_item :SETTLED, Cproton::PN_STATUS_SETTLED
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 79c8cb7..18f3ddd 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -93,10 +93,3 @@ require "core/container"
require "handler/reactor_messaging_adapter"
require "handler/messaging_handler" # Keep original name for compatibility
require "reactor/container"
-
-# DEPRECATED Messenger API classes
-require "messenger/subscription"
-require "messenger/tracker_status"
-require "messenger/tracker"
-require "messenger/messenger"
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
index b6700c3..a3f6ad1 100755
--- a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
@@ -52,14 +52,6 @@ class OldExampleTest < MiniTest::Test
assert_output want, ["simple_recv.rb", "-a", make_url($port, __method__)]
end
- def test_smoke
- url = "127.0.0.1:#{unused_port}"
- recv = run_script("recv.rb", "~#{url}")
- recv.readline # Wait for "Listening"
- assert_output("Status: ACCEPTED", ["send.rb", url])
- assert_equal "Got: Hello World!", recv.read.strip
- end
-
def test_client_server
want = <<EOS
-> Twas brillig, and the slithy toves
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/tests/old_examples/recv.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/recv.rb b/proton-c/bindings/ruby/tests/old_examples/recv.rb
deleted file mode 100755
index a29f123..0000000
--- a/proton-c/bindings/ruby/tests/old_examples/recv.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'qpid_proton.rb'
-
-messenger = Qpid::Proton::Messenger::Messenger.new()
-messenger.incoming_window = 1
-message = Qpid::Proton::Message.new()
-
-address = ARGV[0]
-if not address then
- address = "~0.0.0.0"
-end
-messenger.subscribe(address)
-
-messenger.start()
-
-puts "Listening"; STDOUT.flush
-messenger.receive()
-messenger.get(message)
-puts "Got: #{message.body}"
-messenger.accept()
-
-messenger.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/proton-c/bindings/ruby/tests/old_examples/send.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/send.rb b/proton-c/bindings/ruby/tests/old_examples/send.rb
deleted file mode 100755
index 73016d0..0000000
--- a/proton-c/bindings/ruby/tests/old_examples/send.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'qpid_proton.rb'
-
-messenger = Qpid::Proton::Messenger::Messenger.new()
-messenger.outgoing_window = 10
-message = Qpid::Proton::Message.new()
-
-address = ARGV[0]
-if not address then
- address = "0.0.0.0"
-end
-
-message.address = address
-message.body = "Hello World!"
-
-messenger.start()
-tracker = messenger.put(message)
-messenger.send()
-print "Status: ", messenger.status(tracker), "\n"
-messenger.stop()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/codec.js
----------------------------------------------------------------------
diff --git a/tests/javascript/codec.js b/tests/javascript/codec.js
deleted file mode 100755
index 5110f4f..0000000
--- a/tests/javascript/codec.js
+++ /dev/null
@@ -1,569 +0,0 @@
-#!/usr/bin/env node
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-/**
- * This is a fairly literal JavaScript port of codec.py used to unit test the
- * proton.Data wrapper class. This suite of tests is actually testing the low
- * level implementation methods used to access the AMQP type system and in
- * practice most normal users wouldn't need to call these directly, rather users
- * should simply use the putObject() and getObject() methods.
- */
-
-// Check if the environment is Node.js and if not log an error and exit.
-if (typeof process === 'object' && typeof require === 'function') {
- var unittest = require("./unittest.js");
- var assert = require("assert");
-
- // Increase the virtual heap available to the emscripten compiled C runtime.
- // This allows us to test a really big string.
- PROTON_TOTAL_MEMORY = 140000000;
- PROTON_TOTAL_STACK = 25000000; // Needs to be bigger than the biggest string.
- var proton = require("qpid-proton-messenger");
-
- // Extend TestCase by creating a prototype instance and adding test methods as properties.
- var DataTest = new unittest.TestCase();
-
- DataTest.setUp = function() {
- this.data = new proton.Data();
- };
-
- DataTest.tearDown = function() {
- this.data.free();
- this.data = null;
- };
-
- DataTest.testTopLevelNext = function() {
- console.log("testTopLevelNext");
- assert(this.data.next() === null);
- this.data.putNULL();
- this.data.putBOOL(false);
- this.data.putINT(0);
- assert(this.data.next() === null);
- this.data.rewind();
- assert(this.data.next() === proton.Data.NULL);
- assert(this.data.next() === proton.Data.BOOL);
- assert(this.data.next() === proton.Data.INT);
- assert(this.data.next() === null);
- console.log("OK\n");
- };
-
- DataTest.testNestedNext = function() {
- console.log("testNestedNext");
- assert(this.data.next() === null);
- this.data.putNULL();
- assert(this.data.next() === null);
- this.data.putLISTNODE();
- assert(this.data.next() === null);
- this.data.putBOOL(false);
- assert(this.data.next() === null);
- this.data.rewind();
- assert(this.data.next() === proton.Data.NULL);
- assert(this.data.next() === proton.Data.LIST);
- this.data.enter();
- assert(this.data.next() === null);
- this.data.putUBYTE(0);
- assert(this.data.next() === null);
- this.data.putUINT(0);
- assert(this.data.next() === null);
- this.data.putINT(0);
- assert(this.data.next() === null);
- this.data.exit();
- assert(this.data.next() === proton.Data.BOOL);
- assert(this.data.next() === null);
-
- this.data.rewind();
- assert(this.data.next() === proton.Data.NULL);
- assert(this.data.next() === proton.Data.LIST);
- assert(this.data.enter());
- assert(this.data.next() === proton.Data.UBYTE);
- assert(this.data.next() === proton.Data.UINT);
- assert(this.data.next() === proton.Data.INT);
- assert(this.data.next() === null);
- assert(this.data.exit());
- assert(this.data.next() === proton.Data.BOOL);
- assert(this.data.next() === null);
- console.log("OK\n");
- };
-
- DataTest.testEnterExit = function() {
- console.log("testEnterExit");
- assert(this.data.next() === null);
- assert(!this.data.enter());
- this.data.putLISTNODE();
- assert(this.data.enter());
- assert(this.data.next() === null);
- this.data.putLISTNODE();
- assert(this.data.enter());
- this.data.putLISTNODE();
- assert(this.data.enter());
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 0);
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 1);
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 1);
- assert(!this.data.exit());
- assert(this.data.getLISTNODE() === 1);
- assert(this.data.next() === null);
-
- this.data.rewind();
- assert(this.data.next() === proton.Data.LIST);
- assert(this.data.getLISTNODE() === 1);
- assert(this.data.enter());
- assert(this.data.next() === proton.Data.LIST);
- assert(this.data.getLISTNODE() === 1);
- assert(this.data.enter());
- assert(this.data.next() === proton.Data.LIST);
- assert(this.data.getLISTNODE() === 0);
- assert(this.data.enter());
- assert(this.data.next() === null);
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 0);
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 1);
- assert(this.data.exit());
- assert(this.data.getLISTNODE() === 1);
- assert(!this.data.exit());
- console.log("OK\n");
- };
-
- /**
- * This tests the "low level" putARRAYNODE/getARRAYNODE methods.
- * In general though applications would create a proton.Data.Array and use the
- * higher level putARRAY/getARRAY
- */
- DataTest._testArray = function(dtype, descriptor, atype, values) {
- var values = Array.prototype.slice.apply(arguments, [3]);
- dtype = (dtype == null) ? null : dtype.toUpperCase();
- atype = atype.toUpperCase();
-
- // Create an array node, enter it and put the descriptor (if present) and values.
- this.data.putARRAYNODE(dtype != null, proton.Data[atype]);
- this.data.enter();
- if (dtype != null) {
- var putter = 'put' + dtype;
- this.data[putter](descriptor);
- }
- var putter = 'put' + atype;
- for (var i = 0; i < values.length; i++) {
- this.data[putter](values[i]);
- }
- this.data.exit();
-
- // Check that we did indeed add an Array node
- this.data.rewind();
- assert(this.data.next() === proton.Data.ARRAY);
-
- // Get the count, described and type metadata from the array node and compare
- // with the values we passed to putARRAYNODE.
- var metadata = this.data.getARRAYNODE();
- var count = metadata.count;
- var described = metadata.described;
- var type = metadata.type;
-
- assert(count === values.length);
- if (dtype == null) {
- assert(described === false);
- } else {
- assert(described === true);
- }
- assert(type === proton.Data[atype]);
-
- // Enter the array node and compare the descriptor and values with those that
- // we put into the array.
- assert(this.data.enter());
- if (described) {
- assert(this.data.next() === proton.Data[dtype]);
- var getter = 'get' + dtype;
- var gotten = this.data[getter]();
- assert(gotten.toString() === descriptor.toString());
- }
- var getter = 'get' + atype;
- for (var i = 0; i < values.length; i++) {
- assert(this.data.next() === proton.Data[atype]);
- var gotten = this.data[getter]();
- assert(gotten.toString() === values[i].toString());
- }
- assert(this.data.next() === null);
- assert(this.data.exit());
- };
-
- DataTest.testStringArray = function() {
- console.log("testStringArray");
- this._testArray(null, null, "string", "one", "two", "three");
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array("STRING", ["four", "five", "six"]);
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest.testDescribedStringArray = function() {
- console.log("testDescribedStringArray");
- this._testArray("symbol", "url", "string", "one", "two", "three");
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array("STRING", ["four", "five", "six"], new proton.Data.Symbol("url"));
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest.testIntArray = function() {
- console.log("testIntArray");
- this._testArray(null, null, "int", 1, 2, 3);
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array("INT", [4, 5, 6]);
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest.testUUIDArray = function() {
- console.log("testUUIDArray");
- this._testArray(null, null, "uuid", new proton.Data.Uuid(), new proton.Data.Uuid(), new proton.Data.Uuid());
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array("UUID", [new proton.Data.Uuid(), new proton.Data.Uuid(), new proton.Data.Uuid()]);
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest.testEmptyArray = function() {
- console.log("testEmptyArray");
- this._testArray(null, null, "null");
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array();
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest.testDescribedEmptyArray = function() {
- console.log("testDescribedEmptyArray");
- this._testArray("long", 0, "null");
-
- // Now try using the proton.Data.Array class.
- this.data.clear();
- var put = new proton.Data.Array((0).long());
- this.data.putARRAY(put);
- var get = this.data.getARRAY();
- assert(get.equals(put));
- console.log("OK\n");
- };
-
- DataTest._test = function(dtype, values) {
- var values = Array.prototype.slice.apply(arguments, [1]);
- var lastValue = values[values.length - 1];
-
- // Default equality function. Note that we use valueOf because some of the
- // types we are trying to compare (Symbol, Timestamp, Uuid etc.) are object
- // types and we want to compare their value not whether they are the same object.
- var eq = function(x, y) {return x.valueOf() === y.valueOf();};
-
- if (typeof lastValue === 'function') {
- eq = values.pop();
- }
-
- dtype = dtype.toUpperCase();
- var ntype = proton.Data[dtype];
- var putter = 'put' + dtype;
- var getter = 'get' + dtype;
-
- for (var i = 0; i < values.length; i++) {
- var v = values[i];
- /*
- * Replace the array element with its value. We do this to make testing
- * simpler for Binary elements. In the case of Binary putBINARY "consumes"
- * the data, in other words ownership of the underlying raw data transfers
- * to the Data object so the v object becomes "empty" after calling the
- * putter. Calling its valueOf() happens to call its toString() which
- * provides a stringified version of the Binary whilst also working for
- * the other data types we want to test too.
- */
- values[i] = v.valueOf();
- this.data[putter](v);
- var gotten = this.data[getter]();
- assert(eq(gotten, values[i]));
- }
-
- this.data.rewind();
-
- for (var i = 0; i < values.length; i++) {
- var v = values[i];
- var vtype = this.data.next();
- assert(vtype === ntype);
- var gotten = this.data[getter]();
- assert(eq(gotten, v));
- }
-
- // Test encode and decode methods.
- var encoded = this.data.encode();
- var copy = new proton.Data();
- while (encoded) {
- encoded = copy.decode(encoded);
- }
- copy.rewind();
-
- for (var i = 0; i < values.length; i++) {
- var v = values[i];
- var vtype = copy.next();
- assert(vtype === ntype);
- var gotten = copy[getter]();
- assert(eq(gotten, v));
- }
- copy.free();
- };
-
- DataTest.testInt = function() {
- console.log("testInt");
- this._test("int", 1, 2, 3, -1, -2, -3);
- console.log("OK\n");
-
- };
-
- DataTest.testString = function() {
- console.log("testString");
- this._test("string", "one", "two", "three", "this is a test", "");
- console.log("OK\n");
- };
-
- DataTest.testBigString = function() {
- // Try a 2MB string, this is about as big as we can cope with using the default
- // emscripten heap size.
- console.log("testBigString");
- var data = "";
- for (var i = 0; i < 2000000; i++) {
- data += "*";
- }
- var string = "start\n" + data + "\nfinish\n";
- this._test("string", string);
- console.log("OK\n");
- };
-
-/* TODO - currently emscripten isn't respecting Module['TOTAL_STACK'] so setting PROTON_TOTAL_STACK doesn't actually increase the stack size.
- DataTest.testReallyBigString = function() {
- // Try a 20MB string, this needs a bigger emscripten heap size and more stack
- // as the default stack is 5MB and strings are allocated on the stack.
- console.log("testReallyBigString");
- var data = "";
- for (var i = 0; i < 20000000; i++) {
- data += "*";
- }
- var string = "start\n" + data + "\nfinish\n";
- this._test("string", string);
- console.log("OK\n");
- };
-*/
-
- DataTest.testFloat = function() {
- console.log("testFloat");
- // We have to use a special comparison here because JavaScript internally
- // only uses doubles and converting between floats and doubles is imprecise.
- this._test("float", 0, 1, 2, 3, 0.1, 0.2, 0.3, -1, -2, -3, -0.1, -0.2, -0.3,
- function(x, y) {return (x - y < 0.000001);});
- console.log("OK\n");
- };
-
- DataTest.testDouble = function() {
- console.log("testDouble");
- this._test("double", 0, 1, 2, 3, 0.1, 0.2, 0.3, -1, -2, -3, -0.1, -0.2, -0.3);
- console.log("OK\n");
- };
-
- DataTest.testBinary = function() {
- console.log("testBinary");
- this._test("binary", new proton.Data.Binary(["t".char(), "h".char(), "i".char(), "s".char()]),
- new proton.Data.Binary("is"), new proton.Data.Binary("a"), new proton.Data.Binary("test"),
- new proton.Data.Binary("of"), new proton.Data.Binary("двоичные данные"));
- console.log("OK\n");
- };
-
- DataTest.testSymbol = function() {
- console.log("testSymbol");
- this._test("symbol", new proton.Data.Symbol("this is a symbol test"),
- new proton.Data.Symbol("bleh"), new proton.Data.Symbol("blah"));
- console.log("OK\n");
- };
-
- DataTest.testTimestamp = function() {
- console.log("testTimestamp");
- this._test("timestamp", new Date(0), new Date(12345), new Date(1000000));
- console.log("OK\n");
- };
-
- DataTest.testChar = function() {
- console.log("testChar");
- this._test("char", 'a', 'b', 'c', '\u1234');
- console.log("OK\n");
- };
-
- DataTest.testUUID = function() {
- console.log("testUUID");
- this._test("uuid", new proton.Data.Uuid(), new proton.Data.Uuid(), new proton.Data.Uuid());
- console.log("OK\n");
- };
-
- /* TODO
- DataTest.testDecimal32 = function() {
- console.log("testDecimal32");
- //this._test("decimal32", 0, 1, 2, 3, 4, Math.pow(2, 30));
- };
-
- DataTest.testDecimal64 = function() {
- console.log("testDecimal64");
- //this._test("decimal64", 0, 1, 2, 3, 4, Math.pow(2, 60));
- };
-
- DataTest.testDecimal128 = function() {
- console.log("testDecimal128");
- // TODO
- };
- */
-
- DataTest.testCopy = function() {
- console.log("testCopy");
- this.data.putDESCRIBEDNODE();
- this.data.enter();
- this.data.putULONG(123);
- this.data.putMAPNODE();
- this.data.enter();
- this.data.putSTRING("pi");
- this.data.putDOUBLE(3.14159265359);
- this.data.exit();
- this.data.exit();
-
- var dst = this.data.copy();
- var copy = dst.format();
- var orig = this.data.format();
- assert(copy === orig);
- dst.free();
- console.log("OK\n");
- };
-
- DataTest.testCopyNested = function() {
- console.log("testCopyNested");
- var nested = [1, 2, 3, [4, 5, 6], 7, 8, 9];
- this.data.putObject(nested);
- var dst = this.data.copy();
- assert(dst.format() === this.data.format());
- dst.free();
- console.log("OK\n");
- };
-
- DataTest.testCopyNestedArray = function() {
- console.log("testCopyNestedArray");
- var nested = [new proton.Data.Array("LIST", [
- ["first", [new proton.Data.Array("INT", [1, 2, 3]), "this"]],
- ["second", [new proton.Data.Array("INT", [1, 2, 3]), "is"]],
- ["third", [new proton.Data.Array("INT", [1, 2, 3]), "fun"]]
- ]),
- "end"];
- this.data.putObject(nested);
- var dst = this.data.copy();
- assert(dst.format() === this.data.format());
- dst.free();
- console.log("OK\n");
- };
-
- DataTest.testRoundTrip = function() {
- console.log("testRoundTrip");
- var obj = {key: new Date(1234),
- 123: "blah",
- c: "bleh",
- desc: new proton.Data.Described("http://example.org", new proton.Data.Symbol("url")),
- array: new proton.Data.Array("INT", [1, 2, 3]),
- list: [1, 2, 3, null, 4],
- boolean: true};
- // Serialise obj into this.data.
- this.data.putObject(obj);
-
- // Encode this.data into a Binary representation.
- var enc = this.data.encode();
-
- // Create a new Data instance and decode from the Binary representation
- // consuming the Binary contents in the process.
- var data = new proton.Data();
- data.decode(enc);
-
- assert(data.format() === this.data.format());
-
- // Deserialize from the copied Data instance into a new JavaScript Object.
- data.rewind();
- assert(data.next());
- var copy = data.getObject();
-
- // Create yet another Data instance and serialise the new Object into that.
- var data1 = new proton.Data();
- data1.putObject(copy);
-
- // Compare the round tripped Data with the original one.
- assert(data1.format() === this.data.format());
-
- data.free();
- data1.free();
- console.log("OK\n");
- };
-
- DataTest.testLookup = function() {
- console.log("testLookup");
- var obj = {key: "value",
- pi: 3.14159,
- list: [1, 2, 3, 4]};
- // Serialise obj into this.data.
- this.data.putObject(obj);
- this.data.rewind();
- this.data.next();
- this.data.enter();
- this.data.narrow();
- assert(this.data.lookup("pi"));
- assert(this.data.getObject() === 3.14159);
- this.data.rewind();
- assert(this.data.lookup("key"));
- assert(this.data.getObject() === "value");
- this.data.rewind();
- assert(this.data.lookup("list"));
- assert(this.data.getObject().toString() === "1,2,3,4");
- this.data.widen();
- this.data.rewind();
- assert(!this.data.lookup("pi"));
- console.log("OK\n");
- };
-
- DataTest.run();
-} else {
- console.error("codec.js should be run in Node.js");
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/message.js
----------------------------------------------------------------------
diff --git a/tests/javascript/message.js b/tests/javascript/message.js
deleted file mode 100755
index 8e6ec2e..0000000
--- a/tests/javascript/message.js
+++ /dev/null
@@ -1,359 +0,0 @@
-#!/usr/bin/env node
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-/**
- * This is a fairly literal JavaScript port of message.py used to unit test the
- * proton.Message wrapper class.
- */
-
-// Check if the environment is Node.js and if not log an error and exit.
-if (typeof process === 'object' && typeof require === 'function') {
- var unittest = require("./unittest.js");
- var assert = require("assert");
- var proton = require("qpid-proton-messenger");
-
- /**
- * JavaScript Implementation of Python's range() function taken from:
- * http://stackoverflow.com/questions/8273047/javascript-function-similar-to-python-range
- */
- var range = function(start, stop, step) {
- if (typeof stop == 'undefined') {
- // one param defined
- stop = start;
- start = 0;
- };
- if (typeof step == 'undefined') {
- step = 1;
- };
- if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
- return [];
- };
- var result = [];
- for (var i = start; step > 0 ? i < stop : i > stop; i += step) {
- result.push(i);
- };
- return result;
- };
-
-
- // Extend TestCase by creating a new Test class as we're using it in a few places.
- var Test = function() { // Test constructor.
- /**
- * The following call is the equivalent of "super" in Java. It's not necessary
- * here as the unittest.TestCase constructor doesn't set any state, but it
- * is the correct thing to do when implementing classical inheritance in
- * JavaScript so I've kept it here as a useful reminder of the "pattern".
- */
- //unittest.TestCase.prototype.constructor.call(this);
- };
-
- Test.prototype = new unittest.TestCase(); // Here's where the inheritance occurs.
- Test.prototype.constructor = Test; // Otherwise instances of Test would have a constructor of unittest.TestCase.
-
- Test.prototype.setUp = function() {
- this.msg = new proton.Message();
- };
-
- Test.prototype.tearDown = function() {
- this.msg.free();
- this.msg = null;
- };
-
-
- // Extend Test more simply by creating a prototype instance and adding test methods as properties.
-
- var AccessorsTest = new Test();
-
- AccessorsTest._test = function(name, defaultValue, values) {
- /**
- * For the case of Binary values under test we retrieve their toString().
- * This is because the methods under test "consume" the data, in other
- * words ownership of the underlying raw data transfers to the Message
- * object so the sent Binary object becomes "empty" after calling the setter.
- * In addition Binary values merely contain a "pointer" to the raw data
- * so even a "deepEqual" comparison won't accurately compare two Binaries.
- * For these tests we "cheat" and store an array of characters in the
- * Binary so that we can use their String forms for comparison tests.
- *
- * We also get the String value of Uuid for the case of setUserID because
- * that method transparently creates Binary values from the String form
- * of non-Binary data passed to it. It's a convenience method, but makes
- * testing somewhat more fiddly.
- */
-
- // First get the values passed to the method.
- var values = Array.prototype.slice.apply(arguments, [2]);
- // If the first element of values is actually an Array then use the Array.
- // This scenario is what happens in the tests that use the range() function.
- values = (Object.prototype.toString.call(values[0]) === '[object Array]') ? values[0] : values;
-
- // Work out the accessor/mutator names noting that boolean accessors use "is" not "get".
- var setter = 'set' + name;
- var getter = (typeof defaultValue === 'boolean') ? 'is' + name : 'get' + name;
-
- // Get the message's default value first.
- var d = this.msg[getter]();
- d = (d instanceof proton.Data.Binary) ? d.toString() : d;
-
- // Compare the message's default with the expected default value passed in the test case.
- assert.deepEqual(d, defaultValue);
-
- for (var i = 0; i < values.length; i++) {
- var v = values[i];
-
- var value = (v instanceof proton.Data.Binary ||
- (name === 'UserID' && v instanceof proton.Data.Uuid)) ? v.toString() : v;
- value = (v instanceof Date) ? v.valueOf() : v;
-
- this.msg[setter](v); // This call will "consume" Binary data.
-
- var gotten = this.msg[getter]();
- gotten = (gotten instanceof proton.Data.Binary) ? gotten.toString() : gotten;
- gotten = (gotten instanceof Date) ? gotten.valueOf() : v;
-
- assert.deepEqual(value, gotten);
- }
- };
-
- AccessorsTest._testString = function(name) {
- this._test(name, "", "asdf", "fdsa", "");
- };
-
- AccessorsTest._testTime = function(name) {
- // The ExpiryTime and CreationTime methods can take either a number or a Date Object.
- this._test(name, new Date(0), new Date(0), 123456789, new Date(987654321));
- };
-
- AccessorsTest.testID = function() {
- console.log("testID");
- this._test("ID", null, "bytes", null, 123, "string", new proton.Data.Uuid(), new proton.Data.Binary("ВИНАРЫ"));
- console.log("OK\n");
- };
-
- AccessorsTest.testCorrelationID = function() {
- console.log("testCorrelationID");
- this._test("CorrelationID", null, "bytes", null, 123, "string", new proton.Data.Uuid(), new proton.Data.Binary("ВИНАРЫ"));
- console.log("OK\n");
- };
-
- AccessorsTest.testDurable = function() {
- console.log("testDurable");
- this._test("Durable", false, true, false);
- console.log("OK\n");
- };
-
- AccessorsTest.testPriority = function() {
- console.log("testPriority");
- this._test("Priority", proton.Message.DEFAULT_PRIORITY, range(0, 256));
- console.log("OK\n");
- };
-
- AccessorsTest.testTTL = function() {
- console.log("testTTL");
- this._test("TTL", 0, range(12345, 54321));
- console.log("OK\n");
- };
-
- AccessorsTest.testFirstAcquirer = function() {
- console.log("testFirstAcquirer");
- this._test("FirstAcquirer", false, true, false);
- console.log("OK\n");
- };
-
- AccessorsTest.testDeliveryCount = function() {
- console.log("testDeliveryCount");
- this._test("DeliveryCount", 0, range(0, 1024));
- console.log("OK\n");
- };
-
- AccessorsTest.testUserID = function() {
- console.log("testUserID");
- this._test("UserID", "", "asdf", "fdsa", 123, new proton.Data.Binary("ВИНАРЫ"), new proton.Data.Uuid(), "");
- console.log("OK\n");
- };
-
- AccessorsTest.testAddress = function() {
- console.log("testAddress");
- this._testString("Address");
- console.log("OK\n");
- };
-
- AccessorsTest.testSubject = function() {
- console.log("testSubject");
- this._testString("Subject");
- console.log("OK\n");
- };
-
- AccessorsTest.testReplyTo = function() {
- console.log("testReplyTo");
- this._testString("ReplyTo");
- console.log("OK\n");
- };
-
- AccessorsTest.testContentType = function() {
- console.log("testContentType");
- this._testString("ContentType");
- console.log("OK\n");
- };
-
- AccessorsTest.testContentEncoding = function() {
- console.log("testContentEncoding");
- this._testString("ContentEncoding");
- console.log("OK\n");
- };
-
- AccessorsTest.testExpiryTime = function() {
- console.log("testExpiryTime");
- this._testTime("ExpiryTime");
- console.log("OK\n");
- };
-
- AccessorsTest.testCreationTime = function() {
- console.log("testCreationTime");
- this._testTime("CreationTime");
- console.log("OK\n");
- };
-
- AccessorsTest.testGroupID = function() {
- console.log("testGroupID");
- this._testString("GroupID");
- console.log("OK\n");
- };
-
- AccessorsTest.testGroupSequence = function() {
- console.log("testGroupSequence");
- this._test("GroupSequence", 0, 0, -10, 10, 20, -20);
- console.log("OK\n");
- };
-
- AccessorsTest.testReplyToGroupID = function() {
- console.log("testReplyToGroupID");
- this._testString("ReplyToGroupID");
- console.log("OK\n");
- };
-
-
- var CodecTest = new Test();
-
- CodecTest.testRoundTrip = function() {
- console.log("testRoundTrip");
- this.msg.setID("asdf");
- this.msg.setCorrelationID(new proton.Data.Uuid());
- this.msg.setTTL(3);
- this.msg.setPriority(100);
- this.msg.setAddress("address");
- this.msg.setSubject("subject");
- this.msg.body = "Hello World!";
-
- var data = this.msg.encode();
- var msg2 = new proton.Message();
- msg2.decode(data);
-
- assert(this.msg.getID() === msg2.getID());
- assert(this.msg.getCorrelationID().toString() === msg2.getCorrelationID().toString());
- assert(this.msg.getTTL() === msg2.getTTL());
- assert(this.msg.getPriority() === msg2.getPriority());
- assert(this.msg.getAddress() === msg2.getAddress());
- assert(this.msg.getSubject() === msg2.getSubject());
- assert(this.msg.body === msg2.body);
-
- msg2.free();
- console.log("OK\n");
- };
-
- /**
- * This test tests the transparent serialization and deserialization of JavaScript
- * Objects using the AMQP type system (this is the default behaviour).
- */
- CodecTest.testRoundTripBodyObject = function() {
- console.log("testRoundTripBodyObject");
- this.msg.setAddress("address");
- this.msg.body = {array: [1, 2, 3, 4], object: {name: "John Smith", age: 65}};
-
- var data = this.msg.encode();
- var msg2 = new proton.Message();
- msg2.decode(data);
-
- assert(this.msg.getAddress() === msg2.getAddress());
- assert(this.msg.getContentType() === msg2.getContentType());
- assert.deepEqual(this.msg.body, msg2.body);
-
- msg2.free();
- console.log("OK\n");
- };
-
- /**
- * This test tests the transparent serialization and deserialization of JavaScript
- * Objects as JSON. In this case the "on-the-wire" representation is an AMQP binary
- * stored in the AMQP data section.
- */
- CodecTest.testRoundTripBodyObjectAsJSON = function() {
- console.log("testRoundTripBodyObjectAsJSON");
- this.msg.setAddress("address");
- this.msg.setContentType("application/json");
- this.msg.body = {array: [1, 2, 3, 4], object: {name: "John Smith", age: 65}};
-
- var data = this.msg.encode();
- var msg2 = new proton.Message();
- msg2.decode(data);
-
- assert(this.msg.getAddress() === msg2.getAddress());
- assert(this.msg.getContentType() === msg2.getContentType());
- assert.deepEqual(this.msg.body, msg2.body);
-
- msg2.free();
- console.log("OK\n");
- };
-
- /**
- * By default the API will encode using the AMQP type system, but is the content-type
- * is set it will encode as an opaque Binary in an AMQP data section. For certain
- * types however this isn't the most useful thing. For application/json (see
- * previous test) we convert to and from JavaScript Objects and for text/* MIME
- * types the API will automatically convert the received Binary into a String.
- */
- CodecTest.testRoundTripMIMETextObject = function() {
- console.log("testRoundTripMIMETextObject");
- this.msg.setAddress("address");
- this.msg.setContentType("text/plain");
- this.msg.body = "some text";
-
- var data = this.msg.encode();
- var msg2 = new proton.Message();
- msg2.decode(data);
-
- assert(this.msg.getAddress() === msg2.getAddress());
- assert(this.msg.getContentType() === msg2.getContentType());
- assert.deepEqual(this.msg.body, msg2.body);
-
- msg2.free();
- console.log("OK\n");
- };
-
-
- // load and save are deprecated so not implemented in the JavaScript binding.
-
- AccessorsTest.run();
- CodecTest.run();
-} else {
- console.error("message.js should be run in Node.js");
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/msgr-recv.js
----------------------------------------------------------------------
diff --git a/tests/javascript/msgr-recv.js b/tests/javascript/msgr-recv.js
deleted file mode 100755
index 24bdcae..0000000
--- a/tests/javascript/msgr-recv.js
+++ /dev/null
@@ -1,265 +0,0 @@
-#!/usr/bin/env node
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-var Statistics = function() {
- this.startTime = 0;
- this.latencySamples = 0;
- this.latencyTotal = 0;
- this.latencyMin = 0;
- this.latencyMax = 0;
-};
-
-Statistics.prototype.start = function() {
- this.startTime = +new Date();
-};
-
-Statistics.prototype.messageReceived = function(msg) {
- var ts = +msg.getCreationTime(); // The + gets the value of the returned Data Object.
- if (ts) {
- var l = +new Date() - ts;
- if (l) {
- this.latencyTotal += l;
- this.latencySamples += 1;
- if (this.latencySamples === 1) {
- this.latencyMin = this.latencyMax = l;
- } else {
- if (this.latencyMin > l) {
- this.latencyMin = l;
- }
- if (this.latencyMax < l) {
- this.latencyMax = l;
- }
- }
- }
- }
-};
-
-Statistics.prototype.report = function(sent, received) {
- var seconds = (+new Date() - this.startTime)/1000;
- console.log("Messages sent: " + sent + " received: " + received);
- console.log("Total time: " + seconds + " seconds");
- if (seconds) {
- console.log("Throughput: " + (sent/seconds) + " msgs/sec sent");
- console.log("Throughput: " + (received/seconds) + " msgs/sec received");
- }
-
- if (this.latencySamples) {
- console.log("Latency (ms): " + this.latencyMin + " min " +
- this.latencyMax + " max " +
- (this.latencyTotal/this.latencySamples) + " avg");
- }
-};
-
-
-var MessengerReceive = function(opts, callback) {
- //if (opts.verbose) {
- console.log("subscriptions = " + opts.subscriptions);
- console.log("messageCount = " + opts.messageCount);
- console.log("recvCount = " + opts.recvCount);
- console.log("incomingWindow = " + opts.incomingWindow);
- console.log("reportInterval = " + opts.reportInterval);
- console.log("reply = " + opts.reply);
- console.log("forwardingTargets = " + opts.forwardingTargets);
- console.log("name = " + opts.name);
- console.log("readyText = " + opts.readyText);
- console.log("verbose = " + opts.verbose);
- console.log();
- //}
-
- var stats = new Statistics();
- var running = true; // Used to avoid calling stop multiple times.
- var sent = 0;
- var received = 0;
- var forwardingIndex = 0;
-
- var message = new proton.Message();
- var messenger = new proton.Messenger(opts.name);
-
- var pumpData = function() {
- if (opts.verbose) {
- console.log("Calling messenger.recv(" + opts.recvCount + ")");
- }
- messenger.recv(opts.recvCount);
-
- if (opts.verbose) {
- console.log("Messages on incoming queue: " + messenger.incoming());
- }
- while (messenger.incoming()) {
- // start the timer only after receiving the first msg
- if (received === 0) {
- stats.start();
- }
-
- messenger.get(message);
- received += 1;
- //console.log("Address: " + message.getAddress());
- //console.log("CorrelationID: " + message.getCorrelationID());
- //console.log("Content: " + message.body);
- stats.messageReceived(message);
-
- if (opts.reply) {
- var replyTo = message.getReplyTo();
- if (replyTo) {
- if (opts.verbose) {
- console.log("Replying to: " + replyTo);
- }
- message.setAddress(replyTo);
- message.setCreationTime(new Date());
- messenger.put(message);
- sent += 1;
- }
- }
- }
-
- // Check for exit condition.
- if (running && !(opts.messageCount === 0 || received < opts.messageCount)) {
- // Wait for outgoing to be zero before calling stop so pending sends
- // get flushed properly.
- if (messenger.outgoing()) {
- if (opts.verbose) {
- console.log("Flushing pending sends");
- }
- } else {
-//console.log("******* messenger.stop()");
- messenger.stop();
- running = false;
- stats.report(sent, received);
- if (callback) {
- callback(stats);
- }
- }
- }
-
- if (messenger.isStopped()) {
-//console.log("-------------------- messenger.isStopped()");
- message.free();
- messenger.free();
- }
- };
-
- this.start = function() {
- messenger.on('error', function(error) {console.log("** error **"); console.log(error);});
- messenger.on('work', pumpData);
- messenger.on('subscription', function(subscription) {
- // Hack to let test scripts know when the receivers are ready (so that the
- // senders may be started).
-console.log("****** subscription " + subscription.getAddress() + " succeeded")
- if (opts.readyText) {
- console.log(opts.readyText);
- }
- });
-
- if (opts.incomingWindow) {
- messenger.setIncomingWindow(opts.incomingWindow);
- }
- messenger.start();
-
- // Unpack addresses that were specified using comma-separated list
- var subscriptions = opts.subscriptions.split(',');
- for (var i = 0; i < subscriptions.length; i++) {
- var subscription = subscriptions[i];
- if (opts.verbose) {
- console.log("Subscribing to " + subscription);
- }
- messenger.subscribe(subscription);
- }
- };
-};
-
-
-// Check if the environment is Node.js and if not log an error and exit.
-if (typeof process === 'object' && typeof require === 'function') {
- var usage =
- 'Usage: msgr-recv [OPTIONS]\n' +
- ' -a <addr>[,<addr>]* \tAddresses to listen on [amqp://~0.0.0.0]\n' +
- ' -c # \tNumber of messages to receive before exiting [0=forever]\n' +
- ' -b # \tArgument to Messenger::recv(n) [2048]\n' +
- ' -w # \tSize for incoming window [0]\n' +
- ' -e # \t# seconds to report statistics, 0 = end of test [0] *TBD*\n' +
- ' -R \tSend reply if \'reply-to\' present\n' +
- ' -F <addr>[,<addr>]* \tAddresses used for forwarding received messages\n' +
- ' -N <name> \tSet the container name to <name>\n' +
- ' -X <text> \tPrint \'<text>\\n\' to stdout after all subscriptions are created\n' +
- ' -V \tEnable debug logging\n';
-
- // Increase the virtual heap available to the emscripten compiled C runtime.
- // This allows us to test a really big string.
- PROTON_TOTAL_MEMORY = 140000000;
- PROTON_TOTAL_STACK = 25000000; // Needs to be bigger than the biggest string.
- var proton = require("qpid-proton-messenger");
-
- var opts = {};
- opts.subscriptions = 'amqp://~0.0.0.0';
- opts.messageCount = 0;
- opts.recvCount = -1;
- opts.incomingWindow;
- opts.reportInterval = 0;
- opts.reply = false;
- opts.forwardingTargets;
- opts.name;
- opts.readyText;
- opts.verbose = false;
-
- var args = process.argv.slice(2);
- if (args.length > 0) {
- if (args[0] === '-h' || args[0] === '--help') {
- console.log(usage);
- process.exit(0);
- }
-
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
- if (arg.charAt(0) === '-') {
- if (arg === '-V') {
- opts.verbose = true;
- } else if (arg === '-R') {
- opts.reply = true;
- } else {
- i++;
- var val = args[i];
- if (arg === '-a') {
- opts.subscriptions = val;
- } else if (arg === '-c') {
- opts.messageCount = val;
- } else if (arg === '-b') {
- opts.recvCount = val;
- } else if (arg === '-w') {
- opts.incomingWindow = val;
- } else if (arg === '-e') {
- opts.reportInterval = val;
- } else if (arg === '-F') {
- opts.forwardingTargets = val;
- } else if (arg === '-N') {
- opts.name = val;
- } else if (arg === '-X') {
- opts.readyText = val;
- }
- }
- }
- }
- }
-
- var receiver = new MessengerReceive(opts);
- receiver.start();
-} else {
- console.error("msgr-recv.js should be run in Node.js");
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/msgr-send-common.js
----------------------------------------------------------------------
diff --git a/tests/javascript/msgr-send-common.js b/tests/javascript/msgr-send-common.js
deleted file mode 100644
index 4e68097..0000000
--- a/tests/javascript/msgr-send-common.js
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-/**
- * This file is essentially a "module" that is common to msgr-send.js and msgr-send.html.
- * It defines the Statistics and MessengerSend classes and if the environment is Node.js
- * it will import qpid-proton-messenger and export MessengerSend for use in msgr-send.js.
- * Because it's really a module/library trying to execute msgr-send-common.js won't
- * itself do anything terribly exciting.
- */
-
-var Statistics = function() {
- this.startTime = 0;
- this.latencySamples = 0;
- this.latencyTotal = 0;
- this.latencyMin = 0;
- this.latencyMax = 0;
-};
-
-Statistics.prototype.start = function() {
- this.startTime = +new Date();
-};
-
-Statistics.prototype.messageReceived = function(msg) {
- var ts = +msg.getCreationTime(); // The + gets the value of the returned Data Object.
- if (ts) {
- var l = +new Date() - ts;
- if (l) {
- this.latencyTotal += l;
- this.latencySamples += 1;
- if (this.latencySamples === 1) {
- this.latencyMin = this.latencyMax = l;
- } else {
- if (this.latencyMin > l) {
- this.latencyMin = l;
- }
- if (this.latencyMax < l) {
- this.latencyMax = l;
- }
- }
- }
- }
-};
-
-Statistics.prototype.report = function(sent, received) {
- var seconds = (+new Date() - this.startTime)/1000;
- console.log("Messages sent: " + sent + " received: " + received);
- console.log("Total time: " + seconds + " seconds");
- if (seconds) {
- console.log("Throughput: " + (sent/seconds) + " msgs/sec sent");
- console.log("Throughput: " + (received/seconds) + " msgs/sec received");
- }
-
- if (this.latencySamples) {
- console.log("Latency (ms): " + this.latencyMin + " min " +
- this.latencyMax + " max " +
- (this.latencyTotal/this.latencySamples) + " avg");
- }
-};
-
-
-var MessengerSend = function(opts, callback) {
- //if (opts.verbose) {
- console.log("addresses = " + opts.addresses);
- console.log("messageCount = " + opts.messageCount);
- console.log("messageSize = " + opts.messageSize);
- console.log("recvCount = " + opts.recvCount);
- console.log("sendBatch = " + opts.sendBatch);
- console.log("outgoingWindow = " + opts.outgoingWindow);
- console.log("reportInterval = " + opts.reportInterval);
- console.log("getReplies = " + opts.getReplies);
- console.log("name = " + opts.name);
- console.log("verbose = " + opts.verbose);
- console.log();
- //}
-
- var stats = new Statistics();
- var targets = [];
- var running = true; // Used to avoid calling stop multiple times.
- var sent = 0;
- var received = 0;
-
- var message = new proton.Message();
- var replyMessage = new proton.Message();
- var messenger = new proton.Messenger(opts.name);
-
- // Retrieve replies and return the number of reply messages received.
- var processReplies = function() {
- var received = 0;
- if (opts.verbose) {
- console.log("Calling messenger.recv(" + opts.recvCount + ")");
- }
- messenger.recv(opts.recvCount);
-
- if (opts.verbose) {
- console.log("Messages on incoming queue: " + messenger.incoming());
- }
- while (messenger.incoming()) {
- messenger.get(replyMessage);
- received += 1;
- //console.log("Address: " + replyMessage.getAddress());
- //console.log("Content: " + replyMessage.body);
- stats.messageReceived(replyMessage);
- }
- return received;
- };
-
- // Send messages as fast as possible. This is analogous to the while loop in
- // the Python msgr-send.py but we wrap in a function in JavaScript so that
- // we can schedule on the JavaScript Event queue via setTimeout. This is needed
- // otherwise the JavaScript Event loop is blocked and no data gets sent.
- var sendData = function() {
- var delay = 0;
- while (opts.messageCount === 0 || (sent < opts.messageCount)) {
- // Check the amount of data buffered on the socket, if it's non-zero
- // exit the loop and call senData again after a short delay. This
- // will throttle the send rate if necessary.
- if (messenger.getBufferedAmount()) {
-console.log("messenger.getBufferedAmount() = " + messenger.getBufferedAmount());
- delay = 100;
- break; // Exit loop to check for exit condition and schedule to Event queue.
- }
-
- var index = sent % targets.length;
-//console.log("sent = " + sent + ", index = " + index);
-
- message.setAddress(targets[index]);
- message.setCorrelationID(sent);
- message.setCreationTime(new Date());
- messenger.put(message);
- sent += 1;
-
- if (opts.sendBatch && (messenger.outgoing() >= opts.sendBatch)) {
- if (opts.verbose) {
- console.log("Calling messenger.send()")
- }
- messenger.send();
-
- if (opts.getReplies) {
- received += processReplies();
- }
- break; // Exit loop to check for exit condition and yield to Event loop.
- }
- }
-
- // Check for exit condition.
- if (running && !(opts.messageCount === 0 || (sent < opts.messageCount))) {
- if (opts.getReplies && (received < sent)) {
- received += processReplies();
- if (opts.verbose) {
- console.log("Messages sent = " + sent + ", received = " + received);
- }
- } else if (messenger.outgoing()) {
- if (opts.verbose) {
- console.log("Flushing pending sends");
- }
- messenger.send();
- } else {
-//console.log("******* calling stop")
- messenger.stop();
- running = false;
- stats.report(sent, received);
- if (callback) {
- callback(stats);
- }
- }
- }
-
- if (messenger.isStopped()) {
-//console.log("-------------------- messenger.isStopped()");
- message.free();
- messenger.free();
- } else {
- // schedule next call on the JavaScript Event queue. If we don't do this
- // our messages won't get sent because none of the internal JavaScript
- // network code will get any CPU.
-
- // If available we call setImmediate rather than setTimeout when the delay
- // is zero. setImmediate is more efficient, in particular I noticed that
- // with Node.js v0.10.18 I could get max throughput and max out CPU using
- // setTimeout, but when I upgraded to v0.10.33 my throughput dropped and
- // my CPU was hovering around 55% but using setImmediate the performance
- // improved again. My guess is that v0.10.18 was checking for zero delay
- // and calling setImmediate internally whereas v0.10.33 wasn't, but I
- // can't say for sure. TODO it's possible that some browsers might do a
- // better job with setImmediate too (given what I'm seeing with Node.js),
- // Chrome might be one such case, but it's not universally supported.
- // It might be worth adding a proper polyfill to handle this.
- if (delay === 0 && typeof setImmediate === 'function') {
- setImmediate(sendData);
- } else {
- setTimeout(sendData, delay);
- }
- }
- };
-
- this.start = function() {
- message.body = Array(+opts.messageSize + 1).join('X');
- message.setReplyTo('~');
-
- messenger.on('error', function(error) {
- console.log(error);
- opts.messageCount = -1; // Force exit condition.
- });
-
- if (opts.outgoingWindow) {
- messenger.setOutgoingWindow(opts.outgoingWindow);
- }
- messenger.start();
-
- // Unpack targets that were specified using comma-separated list
- var addresses = opts.addresses.split(',');
- for (var i = 0; i < addresses.length; i++) {
- var address = addresses[i];
- targets.push(address);
- }
-
- stats.start();
- sendData();
- };
-};
-
-// If running in Node.js import the proton library and export MessengerSend.
-if (typeof module === 'object') {
- var proton = require("qpid-proton-messenger");
- module.exports.MessengerSend = MessengerSend;
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/msgr-send.html
----------------------------------------------------------------------
diff --git a/tests/javascript/msgr-send.html b/tests/javascript/msgr-send.html
deleted file mode 100644
index 531d886..0000000
--- a/tests/javascript/msgr-send.html
+++ /dev/null
@@ -1,123 +0,0 @@
-<!DOCTYPE html> <!-- HTML5 doctype -->
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- 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.
--->
-
-<html>
-
-<head>
- <title>Proton Messenger Send Benchmark</title>
- <meta http-equiv="content-type" content="text/html;charset=utf-8" />
-
-<!--
- Import the Messenger Binding proton.js. Note that this simple example pulls
- it from the node_modules/qpid-proton/lib, which is created by the build process
- so that the node.js based examples "just work", in a real Web App you would
- clearly need to copy the proton.js to your own server.
-
- In actual fact the CMake build actually builds proton.js into the directory:
- <build>/proton-c/bindings/javascript
- where <build> is the build directory created to run cmake from, it is then
- copied to the node_modules/qpid-proton/lib directory.
-
- In this example we also set the global variable PROTON_TOTAL_MEMORY in order to
- increase the virtual heap available to the emscripten compiled C runtime. It
- is not really necessary to do this for this application as the default value
- of 16777216 is fine, it is simply done here to illustrate how to do it.
--->
-<script type="text/javascript">PROTON_TOTAL_MEMORY = 140000000;</script>
-<script type="text/javascript">PROTON_TOTAL_STACK = 25000000;</script>
-<script type="text/javascript" src="../../node_modules/qpid-proton-messenger/lib/proton-messenger.js"></script>
-<script type="text/javascript" src="./msgr-send-common.js"></script>
-
-<script type="text/javascript">
-
-var start = function() {
- var opts = {};
- opts.addresses = document.getElementById("address").value;
- opts.messageCount = parseInt(document.getElementById("messageCount").value, 10);
- opts.messageSize = parseInt(document.getElementById("messageSize").value, 10);
- opts.sendBatch = parseInt(document.getElementById("sendBatch").value, 10);
-
- opts.recvCount = -1;
- opts.outgoingWindow;
- opts.reportInterval = 0;
- opts.getReplies = false;
- opts.name;
- opts.verbose = false;
-
- var sender = new MessengerSend(opts);
- sender.start();
-};
-
-</script>
-
-<style>
-body
-{
- font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;
- overflow-x: hidden; /* Hide horizontal scrollbar */
- background: #dddddd;
-}
-
-label
-{
- display: block;
- font-size: 17px;
-}
-
-input, textarea
-{
- font-size: 13px;
- margin-bottom: 10px;
-}
-</style>
-
-</head>
-
-<body>
-<div>
- <label for="address">Address:</label>
- <input type="text" id="address" size="40"
- placeholder="amqp://user:password@host:port"
- name="address" value="amqp://guest:guest@0.0.0.0" />
-</div>
-<div>
- <label for="messageCount">Message Count:</label>
- <input type="text" id="messageCount" size="40"
- name="messageCount" value="0" />
-</div>
-<div>
- <label for="messageSize">Message Size:</label>
- <input type="text" id="messageSize" size="40"
- name="messageSize" value="1024" />
-</div>
-<div>
- <label for="sendBatch">Send Batch Size:</label>
- <input type="text" id="sendBatch" size="40"
- name="sendBatch" value="1024" />
-</div>
-
-
-<div>
- <input type="button" value="start" onclick="start()"/>
-</div>
-</body>
-
-</html>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/msgr-send.js
----------------------------------------------------------------------
diff --git a/tests/javascript/msgr-send.js b/tests/javascript/msgr-send.js
deleted file mode 100755
index 124f29e..0000000
--- a/tests/javascript/msgr-send.js
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env node
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-// Check if the environment is Node.js and if not log an error and exit.
-if (typeof process === 'object' && typeof require === 'function') {
- var usage =
- 'Usage: msgr-send [OPTIONS]\n' +
- ' -a <addr>[,<addr>]* \tThe target address [amqp://~0.0.0.0]\n' +
- ' -c # \tNumber of messages to send before exiting [0=forever]\n' +
- ' -b # \tSize of message body in bytes [1024]\n' +
- ' -p # \tSend batches of # messages (wait for replies before sending next batch if -R) [1024]\n' +
- ' -w # \tSize for outgoing window [0]\n' +
- ' -e # \t# seconds to report statistics, 0 = end of test [0] *TBD*\n' +
- ' -R \tWait for a reply to each sent message\n' +
- ' -B # \tArgument to Messenger::recv(n) [-1]\n' +
- ' -N <name> \tSet the container name to <name>\n' +
- ' -V \tEnable debug logging\n';
-
- // Increase the virtual heap available to the emscripten compiled C runtime.
- // This allows us to test a really big string.
- PROTON_TOTAL_MEMORY = 140000000;
- PROTON_TOTAL_STACK = 25000000; // Needs to be bigger than the biggest string.
- var proton = require("qpid-proton-messenger");
- var benchmark = require("./msgr-send-common.js");
-
- var opts = {};
- opts.addresses = 'amqp://0.0.0.0';
- opts.messageCount = 0;
- opts.messageSize = 1024;
- opts.recvCount = -1;
- opts.sendBatch = 1024;
- opts.outgoingWindow;
- opts.reportInterval = 0;
- opts.getReplies = false;
- opts.name;
- opts.verbose = false;
-
- var args = process.argv.slice(2);
- if (args.length > 0) {
- if (args[0] === '-h' || args[0] === '--help') {
- console.log(usage);
- process.exit(0);
- }
-
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
- if (arg.charAt(0) === '-') {
- if (arg === '-V') {
- opts.verbose = true;
- } else if (arg === '-R') {
- opts.getReplies = true;
- } else {
- i++;
- var val = args[i];
- if (arg === '-a') {
- opts.addresses = val;
- } else if (arg === '-c') {
- opts.messageCount = val;
- } else if (arg === '-b') {
- opts.messageSize = val;
- } else if (arg === '-B') {
- opts.recvCount = val;
- } else if (arg === '-p') {
- opts.sendBatch = val;
- } else if (arg === '-w') {
- opts.outgoingWindow = val;
- } else if (arg === '-e') {
- opts.reportInterval = val;
- } else if (arg === '-N') {
- opts.name = val;
- }
- }
- }
- }
- }
-
- var sender = new benchmark.MessengerSend(opts);
- sender.start();
-} else {
- console.error("msgr-send.js should be run in Node.js");
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/soak.js
----------------------------------------------------------------------
diff --git a/tests/javascript/soak.js b/tests/javascript/soak.js
deleted file mode 100755
index 50bf921..0000000
--- a/tests/javascript/soak.js
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env node
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-// Check if the environment is Node.js and if not log an error and exit.
-if (typeof process === 'object' && typeof require === 'function') {
- var proton = require("qpid-proton-messenger");
-
- var addr = 'guest:guest@localhost:5673';
- //var addr = 'localhost:5673';
- var address = 'amqp://' + addr;
- console.log(address);
-
- var subscriptionQueue = '';
- var count = 0;
- var start = 0; // Start Time.
-
- var message = new proton.Message();
- var messenger = new proton.Messenger();
-
- var pumpData = function() {
- while (messenger.incoming()) {
- // The second parameter forces Binary payloads to be decoded as strings
- // this is useful because the broker QMF Agent encodes strings as AMQP
- // binary, which is a right pain from an interoperability perspective.
- var t = messenger.get(message, true);
- //console.log("Address: " + message.getAddress());
- //console.log("Content: " + message.body);
- messenger.accept(t);
-
- if (count % 1000 === 0) {
- var time = +new Date();
- console.log("count = " + count + ", duration = " + (time - start) + ", rate = " + ((count*1000)/(time - start)));
- }
-
- sendMessage();
- }
-
- if (messenger.isStopped()) {
- message.free();
- messenger.free();
- }
- };
-
- var sendMessage = function() {
- var msgtext = "Message Number " + count;
- count++;
-
- message.setAddress(address + '/' + subscriptionQueue);
- message.body = msgtext;
- messenger.put(message);
- //messenger.settle();
- };
-
- messenger.on('error', function(error) {console.log(error);});
- messenger.on('work', pumpData);
- messenger.on('subscription', function(subscription) {
- var subscriptionAddress = subscription.getAddress();
- var splitAddress = subscriptionAddress.split('/');
- subscriptionQueue = splitAddress[splitAddress.length - 1];
-
- console.log("Subscription Queue: " + subscriptionQueue);
- start = +new Date();
- sendMessage();
- });
-
- //messenger.setOutgoingWindow(1024);
- messenger.setIncomingWindow(1024); // The Java Broker seems to need this.
- messenger.recv(); // Receive as many messages as messenger can buffer.
- messenger.start();
-
- messenger.subscribe('amqp://' + addr + '/#');
-} else {
- console.error("soak.js should be run in Node.js");
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/javascript/unittest.js
----------------------------------------------------------------------
diff --git a/tests/javascript/unittest.js b/tests/javascript/unittest.js
deleted file mode 100644
index bc1567c..0000000
--- a/tests/javascript/unittest.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * 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.
- *
- */
-
-/**
- * The TestCase class provides a simple dependency-free Unit Test framework to
- * automagically invoke methods that start with "test" on classes that extend it.
- */
-
-// TestCase Constructor
-var TestCase = function() {};
-
-// Enumerate all functions of the class and invoke those beginning with "test".
-TestCase.prototype.run = function() {
- for (var property in this) {
- if ((typeof this[property] === 'function') &&
- property.lastIndexOf('test', 0) === 0) {
- this.setUp();
- this[property]();
- this.tearDown();
- }
- }
-};
-
-TestCase.prototype.setUp = function() {};
-TestCase.prototype.tearDown = function() {};
-
-module.exports.TestCase = TestCase;
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/python/proton_tests/__init__.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/__init__.py b/tests/python/proton_tests/__init__.py
index 66ce650..66792f5 100644
--- a/tests/python/proton_tests/__init__.py
+++ b/tests/python/proton_tests/__init__.py
@@ -22,7 +22,6 @@ import proton_tests.engine
import proton_tests.message
import proton_tests.handler
import proton_tests.reactor
-import proton_tests.messenger
import proton_tests.sasl
import proton_tests.transport
import proton_tests.ssl
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0c9bb9ff/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 019c47d..b3f93fb 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -509,19 +509,6 @@ class MessengerReceiverValgrind(MessengerReceiverC):
def __init__(self, suppressions=None):
setup_valgrind(self)
-class MessengerSenderPython(MessengerSender):
- def __init__(self):
- MessengerSender.__init__(self)
- self._command = ["msgr-send.py"]
-
-
-class MessengerReceiverPython(MessengerReceiver):
- def __init__(self):
- MessengerReceiver.__init__(self)
- self._command = ["msgr-recv.py"]
-
-
-
class ReactorSenderC(MessengerSender):
def __init__(self):
MessengerSender.__init__(self)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org