You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2013/02/08 11:09:41 UTC

svn commit: r1443914 - in /qpid/proton/trunk: proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java proton-j/proton-api/src/main/resources/proton.py tests/python/proton-test

Author: kwall
Date: Fri Feb  8 10:09:41 2013
New Revision: 1443914

URL: http://svn.apache.org/r1443914
Log:
PROTON-224: Arrange for proton_test to treat ProtonUnsupportedOperationException (the exception used by the Java stacks to signal an unimplemented Proton feature) automatically as a skipped test

Modified:
    qpid/proton/trunk/proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java
    qpid/proton/trunk/proton-j/proton-api/src/main/resources/proton.py
    qpid/proton/trunk/tests/python/proton-test

Modified: qpid/proton/trunk/proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java?rev=1443914&r1=1443913&r2=1443914&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java (original)
+++ qpid/proton/trunk/proton-j/proton-api/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java Fri Feb  8 10:09:41 2013
@@ -25,6 +25,9 @@ package org.apache.qpid.proton;
  */
 public class ProtonUnsupportedOperationException extends UnsupportedOperationException
 {
+    /** Used by the Python test layer to detect an unsupported operation */
+    public static final boolean protonUnsupportedOperation = true;
+
     public ProtonUnsupportedOperationException()
     {
     }
@@ -43,5 +46,4 @@ public class ProtonUnsupportedOperationE
     {
         super(cause);
     }
-
 }

Modified: qpid/proton/trunk/proton-j/proton-api/src/main/resources/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton-api/src/main/resources/proton.py?rev=1443914&r1=1443913&r2=1443914&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/proton-api/src/main/resources/proton.py (original)
+++ qpid/proton/trunk/proton-j/proton-api/src/main/resources/proton.py Fri Feb  8 10:09:41 2013
@@ -53,7 +53,6 @@ class Constant(object):
   def __repr__(self):
     return self.name
 
-
 class Skipped(Exception):
   skipped = True
 
@@ -95,7 +94,7 @@ class Endpoint(object):
 
   @property
   def remote_condition(self):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   @property
   def state(self):
@@ -174,7 +173,7 @@ class Connection(Endpoint):
 
   @property
   def writable(self):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   def session(self):
     return wrap_session(self.impl.session())
@@ -296,7 +295,7 @@ class Link(Endpoint):
 
   @property
   def available(self):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   @property
   def queued(self):
@@ -311,7 +310,7 @@ class DataDummy:
     pass
 
   def put_array(self, *args, **kwargs):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
 class Terminus(object):
 
@@ -349,7 +348,7 @@ class Terminus(object):
 class Sender(Link):
 
   def offered(self, n):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   def send(self, bytes):
     return self.impl.send(bytes, 0, len(bytes))
@@ -478,11 +477,11 @@ class Transport(object):
 
   def _get_max_frame_size(self):
     #return pn_transport_get_max_frame(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   def _set_max_frame_size(self, value):
     #pn_transport_set_max_frame(self._trans, value)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   max_frame_size = property(_get_max_frame_size, _set_max_frame_size,
                             doc="""
@@ -492,16 +491,16 @@ Sets the maximum size for received frame
   @property
   def remote_max_frame_size(self):
     #return pn_transport_get_remote_max_frame(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   # AMQP 1.0 idle-time-out
   def _get_idle_timeout(self):
     #return pn_transport_get_idle_timeout(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   def _set_idle_timeout(self, value):
     #pn_transport_set_idle_timeout(self._trans, value)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   idle_timeout = property(_get_idle_timeout, _set_idle_timeout,
                           doc="""
@@ -511,17 +510,17 @@ The idle timeout of the connection (in m
   @property
   def remote_idle_timeout(self):
     #return pn_transport_get_remote_idle_timeout(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   @property
   def frames_output(self):
     #return pn_transport_get_frames_output(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
   @property
   def frames_input(self):
     #return pn_transport_get_frames_input(self._trans)
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
 class UnmappedType:
 
@@ -619,10 +618,7 @@ class Data(object):
   MAP = JData.DataType.MAP;
 
   def __init__(self, capacity=16):
-    try:
-      self._data = dataFactory.createData(capacity)
-    except ProtonUnsupportedOperationException:
-      raise Skipped()
+    self._data = dataFactory.createData(capacity)
 
   def __del__(self):
     if hasattr(self, "_data"):
@@ -974,11 +970,7 @@ class Data(object):
 class Messenger(object):
 
   def __init__(self, *args, **kwargs):
-    try:
-      self.impl = messengerFactory.createMessenger()
-    except ProtonUnsupportedOperationException:
-      raise Skipped()
-
+    self.impl = messengerFactory.createMessenger()
 
   def start(self):
     self.impl.start()
@@ -1313,10 +1305,7 @@ class SSLDomain(object):
     # that order otherwise tests fail with proton-jni.  It is not clear yet why.
     if trusted_CAs is not None:
       self._domain.setTrustedCaDb(trusted_CAs)
-    try:
-      self._domain.setPeerAuthentication(verify_mode)
-    except ProtonUnsupportedOperationException:
-      raise Skipped()
+    self._domain.setPeerAuthentication(verify_mode)
 
   def allow_unsecured_client(self, allow_unsecured = True):
     self._domain.allowUnsecuredClient(allow_unsecured)
@@ -1347,16 +1336,10 @@ class SSL(object):
     return self._ssl.getProtocolName()
 
   def _set_peer_hostname(self, hostname):
-    try:
-      self._ssl.setPeerHostname(hostname)
-    except ProtonUnsupportedOperationException:
-      raise Skipped()
+    self._ssl.setPeerHostname(hostname)
 
   def _get_peer_hostname(self):
-    try:
-      return self._ssl.getPeerHostname()
-    except ProtonUnsupportedOperationException:
-      raise Skipped()
+    return self._ssl.getPeerHostname()
 
   peer_hostname = property(_get_peer_hostname, _set_peer_hostname)
 
@@ -1364,15 +1347,15 @@ class SSL(object):
 class Driver(object):
   """ Proton-c platform abstraction - not needed."""
   def __init__(self, *args, **kwargs):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 class Connector(object):
   """ Proton-c platform abstraction - not needed."""
   def __init__(self, *args, **kwargs):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 class Listener(object):
   """ Proton-c platform abstraction - not needed."""
   def __init__(self, *args, **kwargs):
-    raise Skipped()
+    raise ProtonUnsupportedOperationException()
 
 __all__ = [
            "ACCEPTED",

Modified: qpid/proton/trunk/tests/python/proton-test
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton-test?rev=1443914&r1=1443913&r2=1443914&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton-test (original)
+++ qpid/proton/trunk/tests/python/proton-test Fri Feb  8 10:09:41 2013
@@ -315,33 +315,36 @@ FAIL = "fail"
 class Runner:
 
   def __init__(self):
-    self.exceptions = []
+    self.exception = None
+    self.exception_phase_name = None
     self.skip = False
-    self.exception_type = None
-    self.exception_message = None
 
   def passed(self):
-    return not self.exceptions
+    return not self.exception
 
   def skipped(self):
     return self.skip
 
   def failed(self):
-    return self.exceptions and not self.skip
+    return self.exception and not self.skip
 
   def halt(self):
-    return self.exceptions or self.skip
+    """determines if the overall test execution should be allowed to continue to the next phase"""
+    return self.exception or self.skip
 
-  def run(self, name, phase):
+  def run(self, phase_name, phase):
+    """invokes a test-phase method (which can be the test method itself or a setup/teardown
+       method).  If the method raises an exception the exception is examined to see if the
+       exception should be classified as a 'skipped' test"""
     try:
       phase()
     except KeyboardInterrupt:
       raise
     except:
-      exi = sys.exc_info()
-      self.exception_type, self.exception_message = exi[0:2]
-      self.skip = getattr(exi[0], "skipped", False)
-      self.exceptions.append((name, exi))
+      self.exception_phase_name = phase_name
+      self.exception = sys.exc_info()
+      exception_type = self.exception[0]
+      self.skip = getattr(exception_type, "skipped", False) or getattr(exception_type, "protonUnsupportedOperation", False)
 
   def status(self):
     if self.passed():
@@ -354,19 +357,20 @@ class Runner:
       return None
 
   def get_formatted_exception_trace(self):
-    for name, info in self.exceptions:
-      if getattr(info[0], "skipped", False):
-        output = indent("".join(traceback.format_exception_only(*info[:2]))).rstrip()
+    if self.exception:
+      if self.skip:
+        # format skipped tests without a traceback
+        output = indent("".join(traceback.format_exception_only(*self.exception[:2]))).rstrip()
       else:
-        output = "Error during %s:" % name
-        output += indent("".join(traceback.format_exception(*info))).rstrip()
+        output = "Error during %s:" % self.exception_phase_name
+        output += indent("".join(traceback.format_exception(*self.exception))).rstrip()
       return output
 
   def get_exception_type(self):
-    return self.exception_type
+    return self.exception[0] if self.exception else None
 
   def get_exception_message(self):
-    return self.exception_message
+    return self.exception[1] if self.exception else None
 
 ST_WIDTH = 8
 



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