You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2014/03/14 12:31:12 UTC

svn commit: r1577487 - in /qpid/proton/branches/fadams-javascript-binding: proton-c/ tests/ tests/java/org/apache/qpid/proton/ tests/java/org/apache/qpid/proton/systemtests/ tests/python/ tests/python/proton_tests/

Author: fadams
Date: Fri Mar 14 11:31:11 2014
New Revision: 1577487

URL: http://svn.apache.org/r1577487
Log:
update tests after merge from trunk

Removed:
    qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/systemtests/
Modified:
    qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt
    qpid/proton/branches/fadams-javascript-binding/tests/   (props changed)
    qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/JythonTest.java
    qpid/proton/branches/fadams-javascript-binding/tests/pom.xml
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton-test
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py   (contents, props changed)
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py   (contents, props changed)
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py   (contents, props changed)
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/transport.py

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt Fri Mar 14 11:31:11 2014
@@ -44,8 +44,6 @@ endif()
 # Set the default SSL/TLS implementation
 find_package(OpenSSL)
 
-find_package (PythonInterp REQUIRED)
-
 set(ssl_impl, none)
 if (OPENSSL_FOUND)
   set(ssl_impl openssl)
@@ -64,24 +62,20 @@ include_directories ("${CMAKE_CURRENT_SO
 
 add_custom_command (
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py > ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
+  COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} python ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py > ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py
   )
 
 add_custom_command (
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py > ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
+  COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} python ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py > ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py
   )
 
 # Select driver
 if(PN_WINAPI)
-  set (pn_io_impl src/windows/io.c)
-  set (pn_selector_impl src/windows/selector.c)
   set (pn_driver_impl src/windows/driver.c)
 else(PN_WINAPI)
-  set (pn_io_impl src/posix/io.c)
-  set (pn_selector_impl src/posix/selector.c)
   set (pn_driver_impl src/posix/driver.c)
 endif(PN_WINAPI)
 
@@ -193,9 +187,8 @@ if (CMAKE_COMPILER_IS_GNUCC)
   if (ENABLE_WARNING_ERROR)
     set (WERROR "-Werror")
   endif (ENABLE_WARNING_ERROR)
-  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors")
+  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors -Wno-comment")
   if (NOT BUILD_WITH_CXX)
-    set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wstrict-prototypes")
     set (COMPILE_LANGUAGE_FLAGS "-std=c99")
     set (COMPILE_PLATFORM_FLAGS "-std=gnu99")
 
@@ -227,14 +220,25 @@ if (SWIG_FOUND)
   add_subdirectory(bindings)
 endif (SWIG_FOUND)
 
+# Build the JavaScript language binding.
+# This is somewhat different to the other language bindings in that it does not use swig. It uses a C/C++ to
+# JavaScript cross-compiler called emscripten (https://github.com/kripken/emscripten). Emscripten takes C/C++
+# and compiles it into a highly optimisable subset of JavaScript called asm.js (http://asmjs.org/) that can be
+# aggressively optimised and run at near-native speed (usually between 1.5 to 10 times slower than native C/C++).
+option("BUILD_JAVASCRIPT" "Build JavaScript language binding" ON)
+if (BUILD_JAVASCRIPT)
+  find_package(Emscripten)
+  if (EMSCRIPTEN_FOUND)
+    add_subdirectory(bindings/javascript)
+  endif (EMSCRIPTEN_FOUND)
+endif (BUILD_JAVASCRIPT)
+
 add_subdirectory(docs/api)
 add_subdirectory(docs/man)
 add_subdirectory(../examples/messenger/c examples/messenger/c)
 add_subdirectory(../tests/tools/apps/c ../tests/tools/apps/c)
 
 set (qpid-proton-platform
-  ${pn_io_impl}
-  ${pn_selector_impl}
   ${pn_driver_impl}
   src/platform.c
   ${pn_driver_ssl_impl}
@@ -258,7 +262,6 @@ set (qpid-proton-core
 
   src/dispatcher/dispatcher.c
   src/engine/engine.c
-  src/engine/event.c
   src/transport/transport.c
   src/message/message.c
   src/sasl/sasl.c
@@ -267,7 +270,6 @@ set (qpid-proton-core
   src/messenger/subscription.c
   src/messenger/store.c
   src/messenger/transform.c
-  src/selectable.c
 
   ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
   ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
@@ -430,13 +432,11 @@ set (env_py "${CMAKE_CURRENT_SOURCE_DIR}
 
 find_program(VALGRIND valgrind DOC "Location of the valgrind program")
 option(ENABLE_VALGRIND "Use valgrind to detect run-time problems" ON)
-if (ENABLE_VALGRIND)
-  if (VALGRIND STREQUAL VALGRIND-NOTFOUND)
-    message(STATUS "Can't locate the valgrind command; no run-time error detection")
-  else (VALGRIND STREQUAL VALGRIND-NOTFOUND)
-    set (VALGRIND_ENV "VALGRIND=${VALGRIND}")
-  endif (VALGRIND STREQUAL VALGRIND-NOTFOUND)
-endif (ENABLE_VALGRIND)
+if (ENABLE_VALGRIND AND NOT VALGRIND)
+  message(STATUS "Can't locate the valgrind command; no run-time error detection")
+else (ENABLE_VALGRIND AND NOT VALGRIND)
+  set (VALGRIND_ENV "VALGRIND=1")
+endif (ENABLE_VALGRIND AND NOT VALGRIND)
 
 # c tests:
 
@@ -454,7 +454,7 @@ set_path (py_pythonpath "$ENV{PYTHONPATH
 if (CMAKE_SYSTEM_NAME STREQUAL Windows)
   set_path (py_pythonpath "${py_pythonpath}:${py_bin}${bld_suffix}")
 endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
-add_test (python-test ${PYTHON_EXECUTABLE} ${env_py}
+add_test (python-test python ${env_py}
          "PATH=${py_path}" "PYTHONPATH=${py_pythonpath}" ${VALGRIND_ENV}
          ${PYTHON_EXECUTABLE} "${py_root}/proton-test")
 set_tests_properties(python-test PROPERTIES PASS_REGULAR_EXPRESSION "Totals: .* 0 failed")
@@ -470,7 +470,7 @@ if (ruby_exe)
   set (rb_rubylib "${rb_root}:${rb_src}:${rb_bin}:${rb_bld}:${rb_lib}")
 
   # ruby unit tests:  tests/ruby/proton-test
-  add_test (ruby-unit-test ${PYTHON_EXECUTABLE} ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
+  add_test (ruby-unit-test python ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
     "${rb_root}/proton-test")
 
   # ruby spec tests
@@ -478,7 +478,7 @@ if (ruby_exe)
   if (rspec_exe)
     add_test (NAME ruby-spec-test
               WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby
-              COMMAND ${PYTHON_EXECUTABLE} ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
+              COMMAND python ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
                       ${rspec_exe})
 
   else(rspec_exe)

Propchange: qpid/proton/branches/fadams-javascript-binding/tests/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Mar 14 11:31:11 2014
@@ -0,0 +1,6 @@
+/qpid/proton/branches/jni-binding/tests:1421251-1441392
+/qpid/proton/branches/kgiusti-msvc2010/tests:1404579-1405897
+/qpid/proton/branches/kgiusti-proton-136/tests:1417075-1423611
+/qpid/proton/branches/kgiusti-proton-225/tests:1445892-1446694
+/qpid/proton/branches/openssl/tests:1387623-1387788
+/qpid/proton/trunk/tests:1544559-1577485

Modified: qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/JythonTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/JythonTest.java?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/JythonTest.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/java/org/apache/qpid/proton/JythonTest.java Fri Mar 14 11:31:11 2014
@@ -45,6 +45,7 @@ public class JythonTest
     private static final Logger LOGGER = Logger.getLogger(JythonTest.class.getName());
 
     /* System properties expected to be defined in test/pom.xml */
+    private static final String PROTON_JYTHON_BINDING = "protonJythonBinding";
     private static final String PROTON_JYTHON_TEST_ROOT = "protonJythonTestRoot";
     private static final String PROTON_JYTHON_TEST_SCRIPT = "protonJythonTestScript";
     private static final String PROTON_JYTHON_TESTS_XML_OUTPUT_DIRECTORY = "protonJythonTestXmlOutputDirectory";
@@ -65,11 +66,13 @@ public class JythonTest
     public void test() throws Exception
     {
         String testScript = getJythonTestScript();
+        String binding = getJythonBinding();
         String testRoot = getJythonTestRoot();
         String xmlReportFile = getOptionalXmlReportFilename();
         String ignoreFile = getOptionalIgnoreFile();
 
         PythonInterpreter interp = createInterpreterWithArgs(xmlReportFile, ignoreFile);
+        interp.getSystemState().path.insert(0, new PyString(binding));
         interp.getSystemState().path.insert(0, new PyString(testRoot));
 
         LOGGER.info("About to call Jython test script: '" + testScript
@@ -166,6 +169,17 @@ public class JythonTest
         return testScript.getAbsolutePath();
     }
 
+    private String getJythonBinding() throws FileNotFoundException
+    {
+        String str = getNonNullSystemProperty(PROTON_JYTHON_BINDING, "System property '%s' must provide the location of the python test root");
+        File file = new File(str);
+        if (!file.isDirectory())
+        {
+            throw new FileNotFoundException("Binding location '" + file + "' should be a directory.");
+        }
+        return file.getAbsolutePath();
+    }
+
 
     private String getJythonTestRoot() throws FileNotFoundException
     {

Modified: qpid/proton/branches/fadams-javascript-binding/tests/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/pom.xml?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/pom.xml (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/pom.xml Fri Mar 14 11:31:11 2014
@@ -24,15 +24,20 @@
   <artifactId>proton-tests</artifactId>
   <name>proton-tests</name>
 
+  <parent>
+    <groupId>org.apache.qpid</groupId>
+    <artifactId>proton-project</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
   <description>The Proton system tests execute against either the Java or the C implementations,
 based on the chosen profile.
 
-To execute, run either &quot;mvn test&quot; or &quot;mvn test -P proton-jni&quot;.
+To execute, &quot;mvn test&quot;.
 
 Example of advanced usage (all of the -D flags are optional):
 
 mvn test \
--P proton-jni \
 -Dproton.pythontest.pattern='proton_tests.transport.TransportTest.*' \
 -Dproton.pythontest.invocations=20 \
 -Dproton.pythontest.always_colorize=true \
@@ -41,6 +46,10 @@ mvn test \
 By default, the proton-jni profile looks for the JNI jar and native libraries under
 directory &lt;basedir&gt;/build/proton-c.</description>
 
+  <scm>
+    <url>http://svn.apache.org/viewvc/qpid/proton/</url>
+  </scm>
+
   <properties>
     <testReportOutputDirectory>${basedir}/target/surefire-reports</testReportOutputDirectory>
   </properties>
@@ -59,6 +68,7 @@ directory &lt;basedir&gt;/build/proton-c
           <systemPropertyVariables>
             <protonJythonIgnoreFile>${basedir}/java/pythonTests.ignore</protonJythonIgnoreFile>
             <protonJythonTestRoot>${basedir}/python</protonJythonTestRoot>
+            <protonJythonBinding>${basedir}/../proton-c/bindings/python</protonJythonBinding>
             <protonJythonTestScript>${basedir}/python/proton-test</protonJythonTestScript>
             <protonJythonTestXmlOutputDirectory>${testReportOutputDirectory}</protonJythonTestXmlOutputDirectory>
             <java.util.logging.config.file>${project.build.outputDirectory}/logging.properties</java.util.logging.config.file>
@@ -71,15 +81,14 @@ directory &lt;basedir&gt;/build/proton-c
 
   <dependencies>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit-version}</version>
-      <scope>test</scope>
+      <groupId>org.apache.qpid</groupId>
+      <artifactId>proton-j</artifactId>
+      <version>${project.parent.version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.qpid</groupId>
-      <artifactId>proton-api</artifactId>
-      <version>1.0-SNAPSHOT</version>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcpkix-jdk15on</artifactId>
+      <version>1.47</version>
     </dependency>
     <dependency>
         <groupId>org.python</groupId>
@@ -87,87 +96,5 @@ directory &lt;basedir&gt;/build/proton-c
         <version>2.5.3</version>
       <scope>test</scope>
     </dependency>
-
-    <dependency>
-      <!-- proton-j-impl is even required for profile proton-jni so we can use EncoderImpl and DecoderImpl to
-           generate test data, hence this dependency appearing here and not just in the proton-j profile -->
-      <groupId>org.apache.qpid</groupId>
-      <artifactId>proton-j-impl</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <!-- Depend on test helper classes contained with test-jar from proton-j-impl -->
-      <groupId>org.apache.qpid</groupId>
-      <artifactId>proton-j-impl</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <scope>test</scope>
-      <type>test-jar</type>
-    </dependency>
   </dependencies>
-
-  <profiles>
-    <profile>
-      <id>proton-j</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <systemPropertyVariables>
-                <qpid.proton.implementationtype>PROTON_J</qpid.proton.implementationtype>
-              </systemPropertyVariables>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-    <profile>
-      <id>proton-jni</id>
-      <properties>
-        <!-- Uses the JNI jar and the native libraries, neither of which are built by Maven,
-             therefore their location needs to be set explicitly in the following properties. -->
-        <proton-c-build-dir>${basedir}/../build/proton-c</proton-c-build-dir>
-        <jni-native-path>${proton-c-build-dir}:${proton-c-build-dir}/bindings/java</jni-native-path>
-        <jni-jar>${proton-c-build-dir}/bindings/java/proton-jni.jar</jni-jar>
-      </properties>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <forkMode>once</forkMode>
-              <argLine>-Djava.library.path=${jni-native-path}</argLine>
-              <systemPropertyVariables>
-                <qpid.proton.implementationtype>PROTON_C</qpid.proton.implementationtype>
-              </systemPropertyVariables>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-      <dependencies>
-        <dependency>
-          <groupId>org.apache.qpid</groupId>
-          <artifactId>proton-jni</artifactId>
-          <version>${project.parent.version}</version>
-          <scope>system</scope>
-          <systemPath>${jni-jar}</systemPath>
-        </dependency>
-      </dependencies>
-    </profile>
-  </profiles>
-
-  <parent>
-    <groupId>org.apache.qpid</groupId>
-    <artifactId>proton-project</artifactId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-  <scm>
-    <url>http://svn.apache.org/viewvc/qpid/proton/</url>
-  </scm>
 </project>

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton-test
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton-test?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton-test (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton-test Fri Mar 14 11:31:11 2014
@@ -671,13 +671,17 @@ def runthrough():
 
 limit = opts.count
 count = 0
+failures = False
 while limit == 0 or count < limit:
   count += 1
   if runthrough():
+    failures = True
     if count > 1:
       print " -- (failures after %s runthroughs)" % count
-    sys.exit(1)
   else:
     continue
 
-sys.exit(0)
+if failures:
+  sys.exit(1)
+else:
+  sys.exit(0)

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py Fri Mar 14 11:31:11 2014
@@ -93,7 +93,7 @@ def isSSLPresent():
         # SSL libraries not installed
         return False
 
-class Test:
+class Test(object):
 
   def __init__(self, name):
     self.name = name
@@ -336,8 +336,6 @@ class MessengerApp(object):
 
     def start(self, verbose=False):
         """ Begin executing the test """
-        if sys.platform.startswith("java"):
-            raise Skipped("Skipping soak tests - not supported under Jython")
         cmd = self.cmdline()
         self._verbose = verbose
         if self._verbose:
@@ -525,7 +523,7 @@ class MessengerSenderValgrind(MessengerS
         if not suppressions:
             suppressions = os.path.join(os.path.dirname(__file__),
                                         "valgrind.supp" )
-        self._command = ["valgrind", "--error-exitcode=1", "--quiet",
+        self._command = [os.environ["VALGRIND"], "--error-exitcode=1", "--quiet",
                          "--trace-children=yes", "--leak-check=full",
                          "--suppressions=%s" % suppressions] + self._command
 
@@ -544,7 +542,7 @@ class MessengerReceiverValgrind(Messenge
         if not suppressions:
             suppressions = os.path.join(os.path.dirname(__file__),
                                         "valgrind.supp" )
-        self._command = ["valgrind", "--error-exitcode=1", "--quiet",
+        self._command = [os.environ["VALGRIND"], "--error-exitcode=1", "--quiet",
                          "--trace-children=yes", "--leak-check=full",
                          "--suppressions=%s" % suppressions] + self._command
 

Propchange: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/common.py
------------------------------------------------------------------------------
  Merged /qpid/proton/trunk/tests/python/proton_tests/common.py:r1544559-1577485

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py Fri Mar 14 11:31:11 2014
@@ -6,9 +6,9 @@
 # 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
@@ -17,11 +17,15 @@
 # under the License.
 #
 
-import os, common
+import os, common, gc
 from time import time, sleep
 from proton import *
 from common import pump
 
+# older versions of gc do not provide the garbage list
+if not hasattr(gc, "garbage"):
+  gc.garbage=[]
+
 # future test areas
 #  + different permutations of setup
 #   - creating deliveries and calling input/output before opening the session/link
@@ -84,7 +88,11 @@ class Test(common.Test):
     return snd, rcv
 
   def cleanup(self):
-    pass
+    # release resources created by this class
+    for w in self._wires:
+        w[0]._transport = None
+        w[2]._transport = None
+    self._wires = []
 
   def pump(self, buffer_size=OUTPUT_SIZE):
     for c1, t1, c2, t2 in self._wires:
@@ -93,10 +101,19 @@ class Test(common.Test):
 class ConnectionTest(Test):
 
   def setup(self):
+    gc.enable()
     self.c1, self.c2 = self.connection()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(ConnectionTest, self).cleanup()
+    self.c1 = None
+    self.c2 = None
+
   def teardown(self):
     self.cleanup()
+    gc.collect()
+    assert not gc.garbage
 
   def test_open_close(self):
     assert self.c1.state == Endpoint.LOCAL_UNINIT | Endpoint.REMOTE_UNINIT
@@ -197,16 +214,49 @@ class ConnectionTest(Test):
     assert self.c2.remote_properties == p1, (self.c2.remote_properties, p1)
     assert self.c1.remote_properties == p2, (self.c2.remote_properties, p2)
 
+  def test_channel_max(self, value=1234):
+    self.c1._transport.channel_max = value
+    self.c1.open()
+    self.pump()
+    assert self.c2._transport.remote_channel_max == value, (self.c2._transport.remote_channel_max, value)
+
+  def test_cleanup(self):
+    self.c1.open()
+    self.c2.open()
+    self.pump()
+    assert self.c1.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE
+    assert self.c2.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE
+    t1 = self.c1._transport
+    t2 = self.c2._transport
+    c2 = self.c2
+    self.c1.close()
+    # release all references to C1, except that held by the transport
+    self.cleanup()
+    gc.collect()
+    # transport should flush last state from C1:
+    pump(t1, t2)
+    assert c2.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_CLOSED
+
 class SessionTest(Test):
 
   def setup(self):
+    gc.enable()
     self.c1, self.c2 = self.connection()
     self.ssn = self.c1.session()
     self.c1.open()
     self.c2.open()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(SessionTest, self).cleanup()
+    self.c1 = None
+    self.c2 = None
+    self.ssn = None
+
   def teardown(self):
     self.cleanup()
+    gc.collect()
+    assert not gc.garbage
 
   def test_open_close(self):
     assert self.ssn.state == Endpoint.LOCAL_UNINIT | Endpoint.REMOTE_UNINIT
@@ -308,13 +358,38 @@ class SessionTest(Test):
     rcond = ssn.remote_condition
     assert rcond == cond, (rcond, cond)
 
+  def test_cleanup(self):
+    snd, rcv = self.link("test-link")
+    snd.open()
+    rcv.open()
+    self.pump()
+    snd_ssn = snd.session
+    rcv_ssn = rcv.session
+    assert rcv_ssn.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE
+    self.ssn = None
+    snd_ssn.close()
+    snd_ssn.free()
+    del snd_ssn
+    gc.collect()
+    self.pump()
+    assert rcv_ssn.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_CLOSED
+
 class LinkTest(Test):
 
   def setup(self):
+    gc.enable()
     self.snd, self.rcv = self.link("test-link")
 
+  def cleanup(self):
+    # release resources created by this class
+    super(LinkTest, self).cleanup()
+    self.snd = None
+    self.rcv = None
+
   def teardown(self):
     self.cleanup()
+    gc.collect()
+    assert not gc.garbage
 
   def test_open_close(self):
     assert self.snd.state == Endpoint.LOCAL_UNINIT | Endpoint.REMOTE_UNINIT
@@ -529,6 +604,18 @@ class LinkTest(Test):
     assert self.snd.remote_rcv_settle_mode == Link.RCV_SECOND
     assert self.rcv.remote_snd_settle_mode == Link.SND_UNSETTLED
 
+  def test_cleanup(self):
+    snd, rcv = self.link("test-link")
+    snd.open()
+    rcv.open()
+    self.pump()
+    assert rcv.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE
+    snd.close()
+    snd.free()
+    del snd
+    gc.collect()
+    self.pump()
+    assert rcv.state == Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_CLOSED
 
 class TerminusConfig:
 
@@ -555,7 +642,7 @@ class TerminusConfig:
       for c in self.capabilities:
         terminus.capabilities.put_symbol(c)
     if self.filter is not None:
-      terminus.filter.put_list()
+      terminus.filter.put_map()
       terminus.filter.enter()
       for (t, v) in self.filter:
         setter = getattr(terminus.filter, "put_%s" % t)
@@ -568,6 +655,7 @@ class TerminusConfig:
 class TransferTest(Test):
 
   def setup(self):
+    gc.enable()
     self.snd, self.rcv = self.link("test-link")
     self.c1 = self.snd.session.connection
     self.c2 = self.rcv.session.connection
@@ -575,8 +663,18 @@ class TransferTest(Test):
     self.rcv.open()
     self.pump()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(TransferTest, self).cleanup()
+    self.c1 = None
+    self.c2 = None
+    self.snd = None
+    self.rcv = None
+
   def teardown(self):
     self.cleanup()
+    gc.collect()
+    assert not gc.garbage
 
   def test_work_queue(self):
     assert self.c1.work_head is None
@@ -615,7 +713,7 @@ class TransferTest(Test):
     assert d.readable
 
     bytes = self.rcv.recv(1024)
-    assert bytes == msg
+    assert bytes == msg, (bytes, msg)
 
     bytes = self.rcv.recv(1024)
     assert bytes == ""
@@ -661,11 +759,11 @@ class TransferTest(Test):
     assert sd.updated
 
     sd.update(Delivery.ACCEPTED)
-    sd.settle()
 
     self.pump()
 
     assert sd.local_state == rd.remote_state == Delivery.ACCEPTED
+    sd.settle()
 
   def test_delivery_id_ordering(self):
     self.rcv.flow(1024)
@@ -704,10 +802,11 @@ class TransferTest(Test):
     #handle all disposition changes to sent messages
     d = self.c1.work_head
     while d:
+      next_d = d.work_next
       if d.updated:
         d.update(Delivery.ACCEPTED)
         d.settle()
-      d = d.work_next
+      d = next_d
 
     #submit some more deliveries
     for m in range(1450, 1500):
@@ -731,12 +830,47 @@ class TransferTest(Test):
       rd.update(Delivery.ACCEPTED)
       rd.settle()
 
+  def test_cleanup(self):
+    self.rcv.flow(10)
+    self.pump()
+
+    for x in range(10):
+        self.snd.delivery("tag%d" % x)
+        msg = "this is a test"
+        n = self.snd.send(msg)
+        assert n == len(msg)
+        assert self.snd.advance()
+    self.snd.close()
+    self.snd.free()
+    self.snd = None
+    gc.collect()
+
+    self.pump()
+
+    for x in range(10):
+        rd = self.rcv.current
+        assert rd is not None
+        assert rd.tag == "tag%d" % x
+        rmsg = self.rcv.recv(1024)
+        assert self.rcv.advance()
+        assert rmsg == msg
+        # close of snd should've settled:
+        assert rd.settled
+        rd.settle()
 
 class MaxFrameTransferTest(Test):
 
   def setup(self):
     pass
 
+  def cleanup(self):
+    # release resources created by this class
+    super(MaxFrameTransferTest, self).cleanup()
+    self.c1 = None
+    self.c2 = None
+    self.snd = None
+    self.rcv = None
+
   def teardown(self):
     self.cleanup()
 
@@ -854,6 +988,14 @@ class IdleTimeoutTest(Test):
   def setup(self):
     pass
 
+  def cleanup(self):
+    # release resources created by this class
+    super(IdleTimeoutTest, self).cleanup()
+    self.snd = None
+    self.rcv = None
+    self.c1 = None
+    self.c2 = None
+
   def teardown(self):
     self.cleanup()
 
@@ -874,10 +1016,11 @@ class IdleTimeoutTest(Test):
     self.snd.open()
     self.rcv.open()
     self.pump()
+    # proton advertises 1/2 the configured timeout to the peer:
     assert self.rcv.session.connection._transport.idle_timeout == 2.0
-    assert self.rcv.session.connection._transport.remote_idle_timeout == 1.0
+    assert self.rcv.session.connection._transport.remote_idle_timeout == 0.5
     assert self.snd.session.connection._transport.idle_timeout == 1.0
-    assert self.snd.session.connection._transport.remote_idle_timeout == 2.0
+    assert self.snd.session.connection._transport.remote_idle_timeout == 1.0
 
   def testTimeout(self):
     """
@@ -895,7 +1038,8 @@ class IdleTimeoutTest(Test):
     t_snd = self.snd.session.connection._transport
     t_rcv = self.rcv.session.connection._transport
     assert t_rcv.idle_timeout == 0.0
-    assert t_rcv.remote_idle_timeout == 1.0
+    # proton advertises 1/2 the timeout (see spec)
+    assert t_rcv.remote_idle_timeout == 0.5
     assert t_snd.idle_timeout == 1.0
     assert t_snd.remote_idle_timeout == 0.0
 
@@ -905,21 +1049,21 @@ class IdleTimeoutTest(Test):
     # at t+1msec, nothing should happen:
     clock = 0.001
     assert t_snd.tick(clock) == 1.001, "deadline for remote timeout"
-    assert t_rcv.tick(clock) == 0.501,  "deadline to send keepalive"
+    assert t_rcv.tick(clock) == 0.251,  "deadline to send keepalive"
     self.pump()
     assert sndr_frames_in == t_snd.frames_input, "unexpected received frame"
 
     # at one tick from expected idle frame send, nothing should happen:
-    clock = 0.500
+    clock = 0.250
     assert t_snd.tick(clock) == 1.001, "deadline for remote timeout"
-    assert t_rcv.tick(clock) == 0.501,  "deadline to send keepalive"
+    assert t_rcv.tick(clock) == 0.251,  "deadline to send keepalive"
     self.pump()
     assert sndr_frames_in == t_snd.frames_input, "unexpected received frame"
 
     # this should cause rcvr to expire and send a keepalive
-    clock = 0.502
+    clock = 0.251
     assert t_snd.tick(clock) == 1.001, "deadline for remote timeout"
-    assert t_rcv.tick(clock) == 1.002, "deadline to send keepalive"
+    assert t_rcv.tick(clock) == 0.501, "deadline to send keepalive"
     self.pump()
     sndr_frames_in += 1
     rcvr_frames_out += 1
@@ -928,14 +1072,14 @@ class IdleTimeoutTest(Test):
 
     # since a keepalive was received, sndr will rebase its clock against this tick:
     # and the receiver should not change its deadline
-    clock = 0.503
-    assert t_snd.tick(clock) == 1.503, "deadline for remote timeout"
-    assert t_rcv.tick(clock) == 1.002, "deadline to send keepalive"
+    clock = 0.498
+    assert t_snd.tick(clock) == 1.498, "deadline for remote timeout"
+    assert t_rcv.tick(clock) == 0.501, "deadline to send keepalive"
     self.pump()
     assert sndr_frames_in == t_snd.frames_input, "unexpected received frame"
 
     # now expire sndr
-    clock = 1.504
+    clock = 1.499
     t_snd.tick(clock)
     try:
       self.pump()
@@ -953,6 +1097,15 @@ class CreditTest(Test):
     self.rcv.open()
     self.pump()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(CreditTest, self).cleanup()
+    self.c1 = None
+    self.snd = None
+    self.c2 = None
+    self.rcv2 = None
+    self.snd2 = None
+
   def teardown(self):
     self.cleanup()
 
@@ -1467,6 +1620,15 @@ class SettlementTest(Test):
     self.rcv.open()
     self.pump()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(SettlementTest, self).cleanup()
+    self.c1 = None
+    self.snd = None
+    self.c2 = None
+    self.rcv2 = None
+    self.snd2 = None
+
   def teardown(self):
     self.cleanup()
 
@@ -1578,6 +1740,12 @@ class PipelineTest(Test):
   def setup(self):
     self.c1, self.c2 = self.connection()
 
+  def cleanup(self):
+    # release resources created by this class
+    super(PipelineTest, self).cleanup()
+    self.c1 = None
+    self.c2 = None
+
   def teardown(self):
     self.cleanup()
 
@@ -1634,11 +1802,16 @@ class PipelineTest(Test):
 
     assert rcv.queued == 0, rcv.queued
 
+import sys
+from common import Skipped
+
 class ServerTest(Test):
 
   def testKeepalive(self):
     """ Verify that idle frames are sent to keep a Connection alive
     """
+    if "java" in sys.platform:
+      raise Skipped()
     idle_timeout_secs = self.delay
     self.server = common.TestServerDrain()
     self.server.start()
@@ -1684,6 +1857,8 @@ class ServerTest(Test):
     """ Verify that a Connection is terminated properly when Idle frames do not
     arrive in a timely manner.
     """
+    if "java" in sys.platform:
+      raise Skipped()
     idle_timeout_secs = self.delay
     self.server = common.TestServerDrain(idle_timeout=idle_timeout_secs)
     self.server.start()
@@ -1893,3 +2068,96 @@ class DeliveryTest(Test):
 
   def testCustom(self):
     self.testDisposition(type=0x12345, value=CustomValue([1, 2, 3]))
+
+class EventTest(Test):
+
+  def teardown(self):
+    self.cleanup()
+
+  def list(self, collector):
+    result = []
+    while True:
+      e = collector.peek()
+      if e:
+        result.append(e)
+        collector.pop()
+      else:
+        break
+    return result
+
+  def expect(self, collector, *types):
+    events = self.list(collector)
+    assert types == tuple([e.type for e in events]), (types, events)
+    if len(events) == 1:
+      return events[0]
+    elif len(events) > 1:
+      return events
+
+  def testEndpointEvents(self):
+    c1, c2 = self.connection()
+    coll = Collector()
+    c1.collect(coll)
+    self.expect(coll)
+    self.pump()
+    self.expect(coll)
+    c2.open()
+    self.pump()
+    self.expect(coll, Event.CONNECTION_STATE)
+    self.pump()
+    self.expect(coll)
+
+    ssn = c2.session()
+    snd = ssn.sender("sender")
+    ssn.open()
+    snd.open()
+
+    self.expect(coll)
+    self.pump()
+    self.expect(coll, Event.SESSION_STATE, Event.LINK_STATE)
+
+  def testFlowEvents(self):
+    snd, rcv = self.link("test-link")
+    coll = Collector()
+    snd.session.connection.collect(coll)
+    rcv.open()
+    rcv.flow(10)
+    self.pump()
+    self.expect(coll, Event.LINK_STATE, Event.LINK_FLOW)
+    rcv.flow(10)
+    self.pump()
+    self.expect(coll, Event.LINK_FLOW)
+    return snd, rcv, coll
+
+  def testDeliveryEvents(self):
+    snd, rcv = self.link("test-link")
+    coll = Collector()
+    rcv.session.connection.collect(coll)
+    rcv.open()
+    rcv.flow(10)
+    self.pump()
+    self.expect(coll, Event.TRANSPORT, Event.TRANSPORT)
+    snd.delivery("delivery")
+    snd.send("Hello World!")
+    snd.advance()
+    self.pump()
+    self.expect(coll)
+    snd.open()
+    self.pump()
+    self.expect(coll, Event.LINK_STATE, Event.DELIVERY)
+
+  def testDeliveryEventsDisp(self):
+    snd, rcv, coll = self.testFlowEvents()
+    snd.open()
+    dlv = snd.delivery("delivery")
+    snd.send("Hello World!")
+    assert snd.advance()
+    self.expect(coll, Event.TRANSPORT, Event.TRANSPORT, Event.TRANSPORT)
+    self.pump()
+    self.expect(coll)
+    rdlv = rcv.current
+    assert rdlv != None
+    assert rdlv.tag == "delivery"
+    rdlv.update(Delivery.ACCEPTED)
+    self.pump()
+    event = self.expect(coll, Event.DELIVERY)
+    assert event.delivery == dlv

Propchange: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py
------------------------------------------------------------------------------
  Merged /qpid/proton/trunk/tests/python/proton_tests/engine.py:r1544559-1577485

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py Fri Mar 14 11:31:11 2014
@@ -355,7 +355,7 @@ class MessengerTest(Test):
     while self.client.outgoing:
         last = self.client.outgoing
         self.client.send()
-        print "sent ", last - self.client.outgoing
+        #print "sent ", last - self.client.outgoing
 
     assert self.server_received == count
 
@@ -723,7 +723,7 @@ class NBMessengerTest(common.Test):
     for i in range(count):
       if self.server.incoming == 0:
         self.pump()
-      assert self.server.incoming > 0
+      assert self.server.incoming > 0, self.server.incoming
       self.server.get(msg2)
       assert msg2.body == "Hello %s" % i, (msg2.body, i)
 
@@ -925,3 +925,95 @@ class NBMessengerTest(common.Test):
             break
     assert self.server.incoming == 50, self.server.incoming
     assert self.server.receiving == 0, self.server.receiving
+
+from select import select
+
+class Pump:
+
+  def __init__(self, *messengers):
+    self.messengers = messengers
+    self.selectables = []
+
+  def pump_once(self):
+    for m in self.messengers:
+      while True:
+        sel = m.selectable()
+        if sel:
+          self.selectables.append(sel)
+        else:
+          break
+
+    reading = []
+    writing = []
+
+    for sel in self.selectables[:]:
+      if sel.is_terminal:
+        sel.free()
+        self.selectables.remove(sel)
+      else:
+        if sel.capacity > 0:
+          reading.append(sel)
+        if sel.pending > 0:
+          writing.append(sel)
+
+    readable, writable, _ = select(reading, writing, [], 0)
+
+    count = 0
+    for s in readable:
+      s.readable()
+      count += 1
+    for s in writable:
+      s.writable()
+      count += 1
+    return count
+
+  def pump(self):
+    while self.pump_once(): pass
+
+
+class SelectableMessengerTest(common.Test):
+
+  def testSelectable(self, count = 1):
+    mrcv = Messenger()
+    mrcv.passive = True
+    mrcv.subscribe("amqp://~0.0.0.0:1234")
+
+    msnd = Messenger()
+    msnd.passive = True
+    m = Message()
+    m.address = "amqp://0.0.0.0:1234"
+
+    for i in range(count):
+      m.body = u"Hello World! %s" % i
+      msnd.put(m)
+
+    p = Pump(msnd, mrcv)
+    p.pump()
+
+    assert msnd.outgoing == count
+    assert mrcv.incoming == 0
+
+    mrcv.recv()
+
+    mc = Message()
+
+    for i in range(count):
+      if mrcv.incoming == 0:
+        p.pump()
+      assert mrcv.incoming > 0
+      mrcv.get(mc)
+      assert mc.body == u"Hello World! %s" % i, (i, mc.body)
+
+    mrcv.stop()
+    assert not mrcv.stopped
+    p.pump()
+    assert mrcv.stopped
+
+  def testSelectable16(self):
+    self.testSelectable(count=16)
+
+  def testSelectable1024(self):
+    self.testSelectable(count=1024)
+
+  def testSelectable4096(self):
+    self.testSelectable(count=4096)

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py Fri Mar 14 11:31:11 2014
@@ -111,18 +111,19 @@ class SaslTest(Test):
     self.s2.send(challenge)
     self.pump()
     ch = self.s1.recv()
-    assert ch == challenge, ch
+    assert ch == challenge, (ch, challenge)
 
     response = "It is I, Secundus!"
     self.s1.send(response)
     self.pump()
     re = self.s2.recv()
-    assert re == response, re
+    assert re == response, (re, response)
 
   def testInitialResponse(self):
     self.s1.plain("secundus", "trustno1")
     self.pump()
-    assert self.s2.recv() == "\x00secundus\x00trustno1"
+    re = self.s2.recv()
+    assert re == "\x00secundus\x00trustno1", repr(re)
 
   def testPipelined2(self):
     self.s1.mechanisms("ANONYMOUS")

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py Fri Mar 14 11:31:11 2014
@@ -817,6 +817,10 @@ class MessengerSSLTests(common.Test):
                                 key="server-private-key.pem",
                                 password="server-password",
                                 exception=None):
+        import sys
+        # java doesn't do validation in the same way (yet)
+        if exception and "java" in sys.platform:
+            raise Skipped()
         self.server.certificate = _testpath(cert)
         self.server.private_key = _testpath(key)
         self.server.password = password

Propchange: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py
------------------------------------------------------------------------------
  Merged /qpid/proton/trunk/tests/python/proton_tests/ssl.py:r1544559-1577485

Modified: qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/transport.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/transport.py?rev=1577487&r1=1577486&r2=1577487&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/transport.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/transport.py Fri Mar 14 11:31:11 2014
@@ -110,3 +110,23 @@ class TransportTest(Test):
       n = self.transport.input(out)
       assert n == len(out), (n, out)
     assert c.session_head(0) != None
+
+  def testCloseHead(self):
+    n = self.transport.pending()
+    assert n > 0, n
+    try:
+      self.transport.close_head()
+    except TransportException, e:
+      assert "aborted" in str(e), str(e)
+    n = self.transport.pending()
+    assert n < 0, n
+
+  def testCloseTail(self):
+    n = self.transport.capacity()
+    assert n > 0, n
+    try:
+      self.transport.close_tail()
+    except TransportException, e:
+      assert "aborted" in str(e), str(e)
+    n = self.transport.capacity()
+    assert n < 0, n



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org