You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2012/09/16 16:43:18 UTC

svn commit: r1385271 - in /qpid/proton/trunk: ./ proton-j/ proton-j/src/main/scripts/ proton-j/src/test/ proton-j/src/test/java/ proton-j/src/test/java/org/ proton-j/src/test/java/org/apache/ proton-j/src/test/java/org/apache/qpid/ proton-j/src/test/ja...

Author: rgodfrey
Date: Sun Sep 16 14:43:17 2012
New Revision: 1385271

URL: http://svn.apache.org/viewvc?rev=1385271&view=rev
Log:
PROTON-13 : Apply patch from Hiram Chirino with minor changes

Added:
    qpid/proton/trunk/proton-j/src/main/scripts/
    qpid/proton/trunk/proton-j/src/main/scripts/jproton.py
    qpid/proton/trunk/proton-j/src/main/scripts/xproton.py
    qpid/proton/trunk/proton-j/src/test/
    qpid/proton/trunk/proton-j/src/test/java/
    qpid/proton/trunk/proton-j/src/test/java/org/
    qpid/proton/trunk/proton-j/src/test/java/org/apache/
    qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/
    qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/
    qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/
    qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/JythonTest.java
Removed:
    qpid/proton/trunk/proton-j/jproton.py
    qpid/proton/trunk/proton-j/xproton.py
Modified:
    qpid/proton/trunk/config.sh
    qpid/proton/trunk/proton-j/pom.xml

Modified: qpid/proton/trunk/config.sh
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/config.sh?rev=1385271&r1=1385270&r2=1385271&view=diff
==============================================================================
--- qpid/proton/trunk/config.sh (original)
+++ qpid/proton/trunk/config.sh Sun Sep 16 14:43:17 2012
@@ -34,7 +34,7 @@ fi
 export PYTHON_BINDINGS=$PROTON_BINDINGS/python
 export COMMON_PYPATH=$PROTON_HOME/tests:$PROTON_HOME/proton-c/bindings/python
 export PYTHONPATH=$COMMON_PYPATH:$PROTON_HOME/proton-c:$PYTHON_BINDINGS
-export JYTHONPATH=$COMMON_PYPATH:$PROTON_HOME/proton-j:$PROTON_HOME/proton-j/dist/lib/qpidproton.jar
+export JYTHONPATH=$COMMON_PYPATH:$PROTON_HOME/proton-j/src/main/scripts:$PROTON_HOME/proton-j/target/qpid-proton-1.0-SNAPSHOT.jar
 
 # PHP
 export PHP_BINDINGS=$PROTON_BINDINGS/php

Modified: qpid/proton/trunk/proton-j/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/pom.xml?rev=1385271&r1=1385270&r2=1385271&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/pom.xml (original)
+++ qpid/proton/trunk/proton-j/pom.xml Sun Sep 16 14:43:17 2012
@@ -28,7 +28,7 @@
   <version>1.0-SNAPSHOT</version>
 
   <properties>
-    <junit-version>4.7</junit-version>
+    <junit-version>4.10</junit-version>
   </properties>
 
   <prerequisites>
@@ -42,9 +42,25 @@
       <version>${junit-version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+        <groupId>org.python</groupId>
+        <artifactId>jython-standalone</artifactId>
+        <version>2.5.3</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
-  <build>    
+  <build> 
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+      </resource>
+      <resource>
+        <directory>${basedir}/src/main/scripts</directory>
+      </resource>
+    </resources>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -59,6 +75,7 @@
         </configuration>
       </plugin>
     </plugins>
+
   </build>
 
 </project>

Added: qpid/proton/trunk/proton-j/src/main/scripts/jproton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/scripts/jproton.py?rev=1385271&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/scripts/jproton.py (added)
+++ qpid/proton/trunk/proton-j/src/main/scripts/jproton.py Sun Sep 16 14:43:17 2012
@@ -0,0 +1,427 @@
+#
+# 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.
+#
+
+from org.apache.qpid.proton.engine import *
+from org.apache.qpid.proton.message import *
+from jarray import zeros
+from java.util import EnumSet
+
+PN_SESSION_WINDOW = impl.TransportImpl.SESSION_WINDOW
+PN_EOS = Transport.END_OF_STREAM
+
+PN_LOCAL_UNINIT = 1
+PN_LOCAL_ACTIVE = 2
+PN_LOCAL_CLOSED = 4
+PN_REMOTE_UNINIT = 8
+PN_REMOTE_ACTIVE = 16
+PN_REMOTE_CLOSED = 32
+
+PN_RECEIVED = 1
+PN_ACCEPTED = 2
+PN_REJECTED = 3
+PN_RELEASED = 4
+PN_MODIFIED = 5
+
+PN_DEFAULT_PRIORITY = Message.DEFAULT_PRIORITY
+
+PN_AMQP = MessageFormat.AMQP
+PN_TEXT = MessageFormat.TEXT
+PN_DATA = MessageFormat.DATA
+
+def enums(mask):
+  local = []
+  if (PN_LOCAL_UNINIT | mask):
+    local.append(EndpointState.UNINITIALIZED)
+  if (PN_LOCAL_ACTIVE | mask):
+    local.append(EndpointState.ACTIVE)
+  if (PN_LOCAL_CLOSED | mask):
+    local.append(EndpointState.CLOSED)
+
+  remote = []
+  if (PN_REMOTE_UNINIT | mask):
+    remote.append(EndpointState.UNINITIALIZED)
+  if (PN_REMOTE_ACTIVE | mask):
+    remote.append(EndpointState.ACTIVE)
+  if (PN_REMOTE_CLOSED | mask):
+    remote.append(EndpointState.CLOSED)
+
+  return EnumSet.of(*local), EnumSet.of(*remote)
+
+def state(endpoint):
+  local = endpoint.getLocalState()
+  remote = endpoint.getRemoteState()
+
+  result = 0
+
+  if (local == EndpointState.UNINITIALIZED):
+    result = result | PN_LOCAL_UNINIT
+  elif (local == EndpointState.ACTIVE):
+    result = result | PN_LOCAL_ACTIVE
+  elif (local == EndpointState.CLOSED):
+    result = result | PN_LOCAL_CLOSED
+
+  if (remote == EndpointState.UNINITIALIZED):
+    result = result | PN_REMOTE_UNINIT
+  elif (remote == EndpointState.ACTIVE):
+    result = result | PN_REMOTE_ACTIVE
+  elif (remote == EndpointState.CLOSED):
+    result = result | PN_REMOTE_CLOSED
+
+  return result
+
+
+def pn_connection():
+  return impl.ConnectionImpl()
+
+def pn_connection_free(c):
+  pass
+
+def pn_transport_free(c):
+  pass
+
+def pn_connection_state(c):
+  return state(c)
+
+def pn_connection_open(c):
+  return c.open()
+
+def pn_connection_close(c):
+  return c.close()
+
+def pn_session(c):
+  return c.session()
+
+def pn_session_free(s):
+  pass
+
+def pn_session_state(s):
+  return state(s)
+
+def pn_session_open(s):
+  return s.open()
+
+def pn_session_close(s):
+  return s.close()
+
+def pn_transport():
+  return impl.TransportImpl()
+
+def pn_transport_bind(t,c):
+  return t.bind(c)
+
+def pn_trace(t, lvl):
+  t.setLogLevel(lvl)
+  pass
+
+def pn_output(t, size):
+  output = zeros(size, "b")
+  n = t.output(output, 0, size)
+  result = ""
+  if n > 0:
+    result = output.tostring()[:n]
+  return [n, result]
+
+def pn_input(t, inp):
+  return t.input(inp, 0, len(inp))
+
+def pn_session_head(c, mask):
+  local, remote = enums(mask)
+  return c.sessionHead(local, remote)
+
+def pn_sender(ssn, name):
+  return ssn.sender(name)
+
+def pn_receiver(ssn, name):
+  return ssn.receiver(name)
+
+def pn_link_free(lnk):
+  pass
+
+def pn_link_state(lnk):
+  return state(lnk)
+
+def pn_link_open(lnk):
+  return lnk.open()
+
+def pn_link_close(lnk):
+  return lnk.close()
+
+def pn_work_head(c):
+  return c.getWorkHead()
+
+def pn_work_next(d):
+  return d.getWorkNext()
+
+def pn_flow(rcv, n):
+  return rcv.flow(n)
+
+def pn_send(snd, msg):
+  return snd.send(msg, 0, len(msg))
+
+def pn_delivery(lnk, tag):
+  return lnk.delivery(tag, 0, len(tag))
+
+def pn_delivery_tag(d):
+  return d.getTag().tostring()
+
+def pn_writable(d):
+  return d.isWritable()
+
+def pn_readable(d):
+  return d.isReadable()
+
+def pn_updated(d):
+  return d.isUpdated()
+
+def pn_advance(l):
+  return l.advance()
+
+def pn_current(l):
+  return l.current()
+
+def pn_recv(l, size):
+  output = zeros(size, "b")
+  n = l.recv(output, 0, size)
+  result = ""
+  if n > 0:
+    result = output.tostring()[:n]
+  return [n, result]
+
+def pn_disposition(d, p):
+  if p == PN_ACCEPTED:
+    d.disposition(Accepted.getInstance())
+
+
+def pn_remote_settled(d):
+  return d.remotelySettled()
+
+def pn_remote_disp(d):
+  if(d.getRemoteState() == Accepted.getInstance()):
+    return PN_ACCEPTED
+
+def pn_remote_disposition(d):
+  if(d.getRemoteState() == Accepted.getInstance()):
+    return PN_ACCEPTED
+
+def pn_local_disp(d):
+  if(d.getLocalState() == Accepted.getInstance()):
+    return PN_ACCEPTED
+
+
+def pn_local_disposition(d):
+  if(d.getLocalState() == Accepted.getInstance()):
+    return PN_ACCEPTED
+
+def pn_settle(d):
+  d.settle()
+
+
+def pn_get_connection(s):
+  return s.getConnection()
+
+def pn_get_session(l):
+  return l.getSession()
+
+def pn_credit(l):
+  return l.getCredit()
+
+def pn_queued(l):
+  return l.getQueued()
+
+def pn_unsettled(l):
+  return l.getUnsettled()
+
+def pn_drain(l, c):
+  l.drain(c)
+
+def pn_drained(l):
+  l.drained()
+
+def pn_message():
+  return Message()
+
+def pn_message_is_durable(m):
+  return m.isDurable()
+
+def pn_message_set_durable(m,d):
+  m.setDurable(d)
+  return 0
+
+def pn_message_get_priority(m):
+  return m.getPriority()
+
+def pn_message_set_priority(m,p):
+  m.setPriority(p)
+  return 0
+
+def pn_message_get_ttl(m):
+  return m.getTtl()
+
+def pn_message_set_ttl(m, t):
+  m.setTtl(t)
+  return 0
+
+def pn_message_is_first_acquirer(m):
+  return m.isFirstAcquirer()
+
+def pn_message_set_first_acquirer(m, b):
+  m.setFirstAcquirer(b)
+  return 0
+
+def pn_message_get_delivery_count(m):
+  return m.getDeliveryCount()
+
+def pn_message_set_delivery_count(m,c):
+  m.setDeliveryCount(c)
+  return 0
+
+def pn_message_get_id(m):
+  return m.getId()
+
+def pn_message_set_id(m, i):
+  m.setId(i)
+  return 0
+
+def pn_message_get_user_id(m):
+  u = m.getUserId()
+  if u is None:
+      return ""
+  else:
+      return u.tostring()
+
+def pn_message_set_user_id(m, u):
+  m.setUserId(u)
+  return 0
+
+def pn_message_load(m, d):
+  m.load(d)
+  return 0
+
+def pn_message_save(m, s):
+  saved = m.save()
+  if saved is None:
+    saved = ""
+  elif not isinstance(saved, unicode):
+    saved = saved.tostring()
+  return 0, saved
+
+
+def pn_message_get_address(m):
+  return m.getAddress()
+
+def pn_message_set_address(m, a):
+  m.setAddress(a)
+  return 0
+
+def pn_message_get_subject(m):
+  return m.getSubject()
+
+def pn_message_set_subject(m,d):
+  m.setSubject(d)
+  return 0
+
+def pn_message_get_reply_to(m):
+  return m.getReplyTo()
+
+def pn_message_set_reply_to(m,d):
+  m.setReplyTo(d)
+  return 0
+
+def pn_message_get_correlation_id(m):
+  return m.getCorrelationId()
+
+def pn_message_set_correlation_id(m,d):
+  m.setCorrelationId(d)
+  return 0
+
+def pn_message_get_content_type(m):
+  return m.getContentType()
+
+def pn_message_set_content_type(m,d):
+  m.setContentType(d)
+  return 0
+
+def pn_message_get_content_encoding(m):
+  return m.getContentEncoding()
+
+def pn_message_set_content_encoding(m,d):
+  m.setContentEncoding(d)
+  return 0
+
+def pn_message_get_expiry_time(m):
+  return m.getExpiryTime()
+
+def pn_message_set_expiry_time(m,d):
+  m.setExpiryTime(d)
+  return 0
+
+def pn_message_get_creation_time(m):
+  return m.getCreationTime()
+
+def pn_message_set_creation_time(m,d):
+  m.setCreationTime(d)
+  return 0
+
+def pn_message_get_group_id(m):
+  return m.getGroupId()
+
+def pn_message_set_group_id(m,d):
+  m.setGroupId(d)
+  return 0
+
+def pn_message_get_group_sequence(m):
+  return m.getGroupSequence()
+
+def pn_message_set_group_sequence(m,d):
+  m.setGroupSequence(d)
+  return 0
+
+def pn_message_get_reply_to_group_id(m):
+  return m.getReplyToGroupId()
+
+def pn_message_set_reply_to_group_id(m,d):
+  m.setReplyToGroupId(d)
+  return 0
+
+def pn_message_free(m):
+  return
+
+def pn_message_encode(m,size):
+    output = zeros(size, "b")
+    n = m.encode(output, 0, size)
+    result = ""
+    if n > 0:
+      result = output.tostring()[:n]
+    return [0, result]
+
+def pn_message_decode(m,data,size):
+    m.decode(data,0,size)
+    return 0
+
+def pn_message_set_format(m, f):
+    m.setMessageFormat(f)
+
+def pn_message_get_format(m):
+    return m.getMessageFormat()
+
+def pn_message_clear(m):
+    m.clear()
+
+def pn_message_error(m):
+    return m.getError().ordinal()

Added: qpid/proton/trunk/proton-j/src/main/scripts/xproton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/scripts/xproton.py?rev=1385271&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/scripts/xproton.py (added)
+++ qpid/proton/trunk/proton-j/src/main/scripts/xproton.py Sun Sep 16 14:43:17 2012
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+from jproton import *

Added: qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/JythonTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/JythonTest.java?rev=1385271&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/JythonTest.java (added)
+++ qpid/proton/trunk/proton-j/src/test/java/org/apache/qpid/proton/test/JythonTest.java Sun Sep 16 14:43:17 2012
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.proton.test;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.python.util.PythonInterpreter;
+import java.io.File;
+
+/**
+ * Runs all the python tests.
+ */
+public class JythonTest
+{
+
+    static final private String PROTON_TESTS = "PROTON_TESTS";
+
+    @Test
+    public void test() throws Exception
+    {
+
+        File basedir = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getFile(), "../..").getCanonicalFile();
+        File testDir;
+        String protonTestsVar = System.getenv(PROTON_TESTS);
+        if( protonTestsVar != null && protonTestsVar.trim().length()>0 )
+        {
+            testDir = new File(protonTestsVar).getCanonicalFile();
+            assertTrue(PROTON_TESTS + " env variable set incorrectly: " + protonTestsVar, testDir.isDirectory());
+        }
+        else
+        {
+            testDir = new File(basedir, "../tests");
+            if( !testDir.isDirectory() )
+            {
+                // The tests might not be there if the proton-j module is released independently
+                // from the main proton project.
+                return;
+            }
+        }
+
+        File classesDir = new File(basedir, "target/classes");
+        PythonInterpreter interp = new PythonInterpreter();
+
+        interp.exec(
+        "import sys\n"+
+        "sys.path.insert(0,\""+classesDir.getCanonicalPath()+"\")\n"+
+        "sys.path.insert(0,\""+testDir.getCanonicalPath()+"\")\n"
+        );
+        interp.execfile(new File(testDir, "proton-test").getCanonicalPath());
+
+    }
+
+}



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