Author: rr
Date: Mon Sep  7 18:59:09 2009
New Revision: 812256

URL: http://svn.apache.org/viewvc?rev=812256&view=rev
Log:
ODE-614: ClassCastException: org.apache.ode.jbi.JbiEndpointReference fix + 
tests update

Added:
    ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/
    ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties   (with 
props)
Modified:
    ode/branches/APACHE_ODE_1.X/Rakefile
    
ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/EndpointReferenceContextImpl.java
    
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/CommunicationJbiTest.java
    
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/JbiTestBase.java
    ode/branches/APACHE_ODE_1.X/jbi/src/test/resources/log4j.properties

Modified: ode/branches/APACHE_ODE_1.X/Rakefile
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/Rakefile?rev=812256&r1=812255&r2=812256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/Rakefile (original)
+++ ode/branches/APACHE_ODE_1.X/Rakefile Mon Sep  7 18:59:09 2009
@@ -524,12 +524,14 @@
       GERONIMO.transaction, JAVAX.connector, JAVAX.ejb, JAVAX.persistence, 
JAVAX.stream,
       JAVAX.transaction, JAXEN, JBI, OPENJPA, SAXON, SERVICEMIX, SPRING, 
TRANQL,
       XALAN, XBEAN, XMLBEANS, XSTREAM,
-      LOG4J
+      LOG4J,
+      DOM4J,
+      HIBERNATE
 
       test.setup 
unzip(_("target/test/smx/ode")=>project("dao-jpa-ojpa-derby").package(:zip))
       test.setup 
unzip(_("target/test/smx/ode")=>project("dao-hibernate-db").package(:zip))
       test.setup task(:prepare_jbi_tests) do |task|
-      cp _("src/main/jbi/ode-jbi.properties"), _("target/test/smx/ode")
+      cp _("src/test/jbi/ode-jbi.properties"), _("target/test/smx/ode")
       cp _("src/main/jbi/hibernate.properties"), _("target/test/smx/ode")
       rm_rf Dir["target/test/resources"]
       cp_r _("src/test/resources"), _("target/test/resources")

Modified: 
ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/EndpointReferenceContextImpl.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/EndpointReferenceContextImpl.java?rev=812256&r1=812255&r2=812256&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/EndpointReferenceContextImpl.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/EndpointReferenceContextImpl.java
 Mon Sep  7 18:59:09 2009
@@ -34,6 +34,7 @@
 import org.w3c.dom.NodeList;
 
 import java.util.Map;
+import java.util.HashMap;
 
 /**
  * Implementation of the ODE {...@link 
org.apache.ode.bpel.iapi.EndpointReferenceContext}
@@ -117,6 +118,8 @@
   }
 
     public Map getConfigLookup(EndpointReference epr) {
-        return ((MutableEndpoint)epr).toMap();
+        Map m = new HashMap();
+        m.put("service", 
((JbiEndpointReference)epr).getServiceEndpoint().getServiceName());
+        return m;
     }
 }

Modified: 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/CommunicationJbiTest.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/CommunicationJbiTest.java?rev=812256&r1=812255&r2=812256&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/CommunicationJbiTest.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/CommunicationJbiTest.java
 Mon Sep  7 18:59:09 2009
@@ -15,9 +15,7 @@
  * limitations under the License.
  */
 package org.apache.ode.jbi;
-import org.junit.Ignore;
 
-...@ignore
 public class CommunicationJbiTest extends JbiTestBase {
     public void testCommunication() throws Exception {
         go();

Modified: 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/JbiTestBase.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/JbiTestBase.java?rev=812256&r1=812255&r2=812256&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/JbiTestBase.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/jbi/src/test/java/org/apache/ode/jbi/JbiTestBase.java
 Mon Sep  7 18:59:09 2009
@@ -19,6 +19,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
@@ -103,45 +104,57 @@
     protected void go() throws Exception {
         enableProcess(getTestName(), true);
 
-        String request = testProperties.getProperty("request");
-        String expectedResponse = testProperties.getProperty("response");
-        {
-               String httpUrl = testProperties.getProperty("http.url");
-               if (httpUrl != null) {
-                   log.debug(getTestName() + " sending http request to " + 
httpUrl + " request: " + request);
-                   URLConnection connection = new 
URL(httpUrl).openConnection();
-                   connection.setDoOutput(true);
-                   connection.setDoInput(true);
-                   //Send request
-                   OutputStream os = connection.getOutputStream();
-                   PrintWriter wt = new PrintWriter(os);
-                   wt.print(request);
-                   wt.flush();
-                   wt.close();
-                   // Read the response.
-                   InputStream is = connection.getInputStream();
-                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                   FileUtil.copyInputStream(is, baos);
-                   String result = baos.toString();
-                   log.debug(getTestName() + " have result: " + result);
-                   matchResponse(expectedResponse, result);
-               }
+        int i = 0;
+        while (true) {
+            String prefix = i == 0 ? "" : "" + i;
+            
+            String request = testProperties.getProperty(prefix + "request");
+            if (request == null) {
+                if (i == 0) continue;
+                else break;
+            }
+            if (request.startsWith("@")) {
+                request = 
inputStreamToString(getClass().getResourceAsStream("/" + getTestName() + "/" + 
request.substring(1)));
+            }
+            String expectedResponse = testProperties.getProperty(prefix + 
"response");
+            {
+               String httpUrl = testProperties.getProperty(prefix + 
"http.url");
+               if (httpUrl != null) {
+                   log.debug(getTestName() + " sending http request to " + 
httpUrl + " request: " + request);
+                   URLConnection connection = new 
URL(httpUrl).openConnection();
+                   connection.setDoOutput(true);
+                   connection.setDoInput(true);
+                   //Send request
+                   OutputStream os = connection.getOutputStream();
+                   PrintWriter wt = new PrintWriter(os);
+                   wt.print(request);
+                   wt.flush();
+                   wt.close();
+                   // Read the response.
+                   String result = 
inputStreamToString(connection.getInputStream());
+                   
+                   log.debug(getTestName() + " have result: " + result);
+                   matchResponse(expectedResponse, result);
+               }
+            }
+            {
+               if (testProperties.getProperty(prefix + "nmr.service") != null) 
{
+                   DefaultServiceMixClient client = new 
DefaultServiceMixClient(jbiContainer);
+                   InOut io = client.createInOutExchange();
+                   
io.setService(QName.valueOf(testProperties.getProperty(prefix + 
"nmr.service")));
+                   
io.setOperation(QName.valueOf(testProperties.getProperty(prefix + 
"nmr.operation")));
+                   io.getInMessage().setContent(new StreamSource(new 
ByteArrayInputStream(request.getBytes())));
+                   client.sendSync(io,20000);
+                   assertEquals(ExchangeStatus.ACTIVE,io.getStatus());
+                   assertNotNull(io.getOutMessage());
+                   String result = new 
SourceTransformer().contentToString(io.getOutMessage());
+                   matchResponse(expectedResponse, result);
+                   client.done(io);
+               }
+            }
+            
+            i++;
         }
-        {
-               if (testProperties.getProperty("nmr.service") != null) {
-                   DefaultServiceMixClient client = new 
DefaultServiceMixClient(jbiContainer);
-                   InOut io = client.createInOutExchange();
-                   
io.setService(QName.valueOf(testProperties.getProperty("nmr.service")));
-                   
io.setOperation(QName.valueOf(testProperties.getProperty("nmr.operation")));
-                   io.getInMessage().setContent(new StreamSource(new 
ByteArrayInputStream(request.getBytes())));
-                   client.sendSync(io,20000);
-                   assertEquals(ExchangeStatus.ACTIVE,io.getStatus());
-                   assertNotNull(io.getOutMessage());
-                   String result = new 
SourceTransformer().contentToString(io.getOutMessage());
-                   matchResponse(expectedResponse, result);
-                   client.done(io);
-               }
-        }      
         
         enableProcess(getTestName(), false);
     }
@@ -149,4 +162,10 @@
     protected void matchResponse(String expectedResponse, String result) {
         assertTrue("Response doesn't match expected regex.\nExpected: " + 
expectedResponse + "\nReceived: " + result, Pattern.compile(expectedResponse, 
Pattern.DOTALL).matcher(result).matches());
     }
+    
+    private String inputStreamToString(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        FileUtil.copyInputStream(is, baos);
+        return baos.toString();
+    }
 }

Added: ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties?rev=812256&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties (added)
+++ ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties Mon Sep  7 
18:59:09 2009
@@ -0,0 +1,78 @@
+#
+# 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.
+#
+
+# ODE-JBI Configuraiton Properties
+
+# Process Identifier Namespace [QNAME]
+# Namespace for processes created using the JBI integration.
+# This will be the namespace of the process identifiers (PIDs)
+ode-jbi.pidNamespace=urn:ode-jbi
+
+# Allow Incomplete Deployment ("true","false")
+# Should incomplete deployments be allowed? An incomplete deployment
+# arises when a service unit contains multiple processes and not all
+# of the processes can be deployed. If incomplete deployments are
+# allowed (true), the service unit will report success if any of the
+# processes can be deployed. If not allowed (false), a failure in
+# one process will prevent all processes from being deployed.
+ode-jbi.allowIncompleteDeployment=false
+
+# Database Mode ("INTERNAL", "EXTERNAL", "EMBEDDED")
+# What kind of database should ODE use?
+#   * "EMBEDDED" - ODE will create its own embbeded database (Derby)
+#              and connection pool (Minerva).
+#   * "EXTERNAL" - ODE will use an app-server provided database and pool.
+#                  The "ode-jbi.db.ext.dataSource" property will need to
+#                  be set.
+#   * "INTERNAL" - ODE will create its own connection pool for a user-
+#                  specified JDBC URL and driver.
+ode-jbi.db.mode=EMBEDDED
+
+# External Database [JNDI Name]
+# JNDI Name of the DataSource for the ODE database. This is only
+# used if the "ode-jbi.db.mode" property is set to "EXTERNAL"
+ode-jbi.db.ext.dataSource=java:comp/env/jdbc/ode
+
+# Embedded Database Name [String]
+# Name of the embedded Derby database. This is only used if the
+# "ode-jbi.db.mode" property is set to "EMBEDDED".
+ode-jbi.db.emb.name=hibdb
+#ode-jbi.db.emb.name=jpadb
+
+# Internal Database Configuration
+#ode-jbi.db.int.jdbcurl=jdbc:mysql://localhost/ode?user=sa
+#ode-jbi.db.int.driver=com.mysql.jdbc.Driver
+
+
+# DAO Connection Factory class.
+# uncomment the following for hibernate.
+ode-jbi.dao.factory=org.apache.ode.daohib.bpel.BpelDAOConnectionFactoryImpl
+
+# Class name of the message mapper that should be used to convert message
+# between ODE / NMS.
+# org.apache.ode.jbi.msgmap.JbiWsdl11WrapperMapper - use JBI WSDL 1.1 "wrapped"
+# org.apache.ode.jbi.msgmap.ServiceMixMapper
+# org.apache.ode.jbi.msgmap.DocLitMapper
+ode-jbi.messageMapper=org.apache.ode.jbi.msgmap.ServiceMixMapper
+
+# BPEL Event Listener
+# Uncomment the following for a debug output of BPEL navigation events.
+#ode-jbi.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener
+#debugeventlistener.dumpToStdOut=on/off
+

Propchange: ode/branches/APACHE_ODE_1.X/jbi/src/test/jbi/ode-jbi.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ode/branches/APACHE_ODE_1.X/jbi/src/test/resources/log4j.properties
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/test/resources/log4j.properties?rev=812256&r1=812255&r2=812256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/jbi/src/test/resources/log4j.properties 
(original)
+++ ode/branches/APACHE_ODE_1.X/jbi/src/test/resources/log4j.properties Mon Sep 
 7 18:59:09 2009
@@ -21,8 +21,8 @@
 #
 # The logging properties used during tests..
 #
-log4j.rootLogger=DEBUG, file
-#log4j.rootLogger=INFO, file
+#log4j.rootLogger=DEBUG, file
+log4j.rootLogger=INFO, file
 
 log4j.appender.file=org.apache.log4j.FileAppender
 log4j.appender.file.File=target/test/test.log
@@ -33,3 +33,5 @@
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.conversionpattern=%d{mm...@hh:mm:ss} %-5p 
(%13F:%L) %3x - %m%n 
 
+log4j.category.org.apache.servicemix.jbi.nmr.flow.seda=DEBUG
+


Reply via email to