tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r545742 - in /incubator/tuscany/java/sca/modules/binding-ejb: ./ src/main/java/org/apache/tuscany/sca/binding/ejb/util/ src/test/ src/test/java/ src/test/java/account/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/tu...
Date Sat, 09 Jun 2007 13:25:56 GMT
Author: antelder
Date: Sat Jun  9 06:25:55 2007
New Revision: 545742

URL: http://svn.apache.org/viewvc?view=rev&rev=545742
Log:
EJB binding: Add testcase, all works now to bank app in Geronimo. need to make a mock server
for testcase

Added:
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
  (with props)
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java   (with
props)
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
  (with props)
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
  (with props)
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/
    incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
Modified:
    incubator/tuscany/java/sca/modules/binding-ejb/pom.xml
    incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
    incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java

Modified: incubator/tuscany/java/sca/modules/binding-ejb/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/pom.xml?view=diff&rev=545742&r1=545741&r2=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/pom.xml Sat Jun  9 06:25:55 2007
@@ -47,6 +47,13 @@
         </dependency>
 
         <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-nodep</artifactId>
+            <version>2.1_3</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>                                      
             <artifactId>junit</artifactId>
             <version>3.8.1</version>

Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java?view=diff&rev=545742&r1=545741&r2=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
Sat Jun  9 06:25:55 2007
@@ -64,6 +64,8 @@
             this.ejbStub = EJBStubHelper.lookup(namingEndpoint);
             this.interfaceInfo = ejbInterface;
         } catch (Exception e) {
+            Throwable b = e.getCause();
+            b.printStackTrace();
             throw new ServiceRuntimeException(e);
         }
     }

Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java?view=diff&rev=545742&r1=545741&r2=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
Sat Jun  9 06:25:55 2007
@@ -478,7 +478,12 @@
         }
 
         public Object locate(String name) throws NamingException {
+            try {
             return context.lookup(name);
+            } catch (Exception e) {
+                e.printStackTrace();
+                return null;
+            }
         }
     }
 

Added: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java?view=auto&rev=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
(added)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
Sat Jun  9 06:25:55 2007
@@ -0,0 +1,20 @@
+/**
+ * 
+ * (C) Copyright IBM Corp. 2004, 2006  All Rights Reserved
+ * 
+ */
+package account;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * 
+ * Compatible EJB interface
+ *
+ */
+@Remotable
+public interface BankManagerFacade   
+{
+    public java.lang.Double getAccountBalance( java.lang.String accountNo );
+    public void changeAccountBalance( java.lang.String accountNo,java.lang.Double balance
);
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/BankManagerFacade.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java?view=auto&rev=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java Sat
Jun  9 06:25:55 2007
@@ -0,0 +1,24 @@
+/**
+ * 
+ * (C) Copyright IBM Corp. 2004, 2006  All Rights Reserved
+ * 
+ */
+package account;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Remotable
+@Service
+public interface Customer {
+
+    /**
+     * This method deposits the amount. method accesses external EJB to get the 
+     * current balance and add the amount to existing balance.
+     *
+     * @param String amount to be deposited
+     * @return total amount in customer accound after deposit
+     */
+    Double depositAmount(java.lang.String accountNo, Double amount);
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/Customer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java?view=auto&rev=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
(added)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
Sat Jun  9 06:25:55 2007
@@ -0,0 +1,42 @@
+/**
+ * 
+ * (C) Copyright IBM Corp. 2004, 2006  All Rights Reserved
+ * 
+ */
+package account;
+
+import org.osoa.sca.ServiceRuntimeException;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(Customer.class)
+public class CustomerImpl implements Customer {
+
+    private BankManagerFacade extEJBService = null;
+
+    public BankManagerFacade getExtEJBService() {
+        return extEJBService;
+    }
+
+    @Reference
+    public void setExtEJBService(BankManagerFacade extEJBService) {
+        this.extEJBService = extEJBService;
+    }
+
+    // this method invokes external EJB through EJB reference binding
+    public Double depositAmount(java.lang.String accountNo, Double amount) {
+         
+        Double total = null;
+
+        System.out.println("In component implementation. Invoking external EJB through EJB
reference binding  ");
+
+        try {
+            Double balance = extEJBService.getAccountBalance(accountNo); //invoke external
ejb through ejb reference binding 
+            total =  balance + amount; 
+        } catch (Exception e) {
+            throw new ServiceRuntimeException(e);
+        }
+        return total;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/account/CustomerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java?view=auto&rev=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
(added)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
Sat Jun  9 06:25:55 2007
@@ -0,0 +1,31 @@
+package org.apache.tuscany.sca.binding.ejb.tests;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import account.Customer;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class EJBReferenceTestCase extends TestCase {
+
+    private SCADomain scaDomain;
+
+    protected void setUp() throws Exception {
+        scaDomain = SCADomain.newInstance("account/account.composite");
+    }
+
+    protected void tearDown() throws Exception {
+        scaDomain.close();
+    }
+
+    public void testCalculator() throws Exception {
+        Customer customer = scaDomain.getService(Customer.class, "CustomerComponent");
+        String accountNo = "1234567890"; // This is one of the customer numbers in bank application
running on
+                                            // Geronimo
+        Double balance = customer.depositAmount(accountNo, new Double(100));
+        System.out.println("Balance amount for account " + accountNo + " is $" + balance);
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-ejb/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite?view=auto&rev=545742
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
(added)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/test/resources/account/account.composite
Sat Jun  9 06:25:55 2007
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           name="account">
+
+   	<!-- composite refrence with ejb binding. Modify host and port number in uri attribute
based on where you have installed target ResumeBank EJB -->
+
+    <component name="CustomerComponent">
+ 		<implementation.java class="account.CustomerImpl"/>
+        <reference name="extEJBService">
+           <binding.ejb uri="corbaname:iiop:1.2@localhost:4201#org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean"/>
+        </reference>
+    </component>
+
+</composite>



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


Mime
View raw message