openejb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r453677 - in /incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful: BasicStatefulBusinessLocal.java StatefulLocalBusinessIntfcTests.java
Date Fri, 06 Oct 2006 17:07:17 GMT
Author: dblevins
Date: Fri Oct  6 10:07:16 2006
New Revision: 453677

URL: http://svn.apache.org/viewvc?view=rev&rev=453677
Log:
OPENEJB-183 iTest: StatefulLocalBusinessIntfcTests
(missed two files in last checkin)

Added:
    incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulBusinessLocal.java
    incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalBusinessIntfcTests.java

Added: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulBusinessLocal.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulBusinessLocal.java?view=auto&rev=453677
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulBusinessLocal.java
(added)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/BasicStatefulBusinessLocal.java
Fri Oct  6 10:07:16 2006
@@ -0,0 +1,69 @@
+/**
+ * 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.openejb.test.stateful;
+
+import org.apache.openejb.test.ApplicationException;
+import org.apache.openejb.test.object.OperationsPolicy;
+
+import java.util.Properties;
+
+/**
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public interface BasicStatefulBusinessLocal {
+
+    /**
+     * Reverses the string passed in then returns it
+     *
+     * @return string
+     */
+    public String businessMethod(String text);
+
+    /**
+     * Throws an ApplicationException when invoked
+     *
+     */
+    public void throwApplicationException() throws ApplicationException;
+
+    /**
+     * Throws a java.lang.NullPointerException when invoked
+     * This is a system exception and should result in the
+     * destruction of the instance and invalidation of the
+     * remote reference.
+     *
+     */
+    public void throwSystemException_NullPointer();
+
+    /**
+     * Returns a report of the bean's
+     * runtime permissions
+     *
+     * @return properties
+     */
+    public Properties getPermissionsReport();
+
+    /**
+     * Returns a report of the allowed opperations
+     * for one of the bean's methods.
+     *
+     * @param methodName The method for which to get the allowed opperations report
+     * @return operations policy
+     */
+    public OperationsPolicy getAllowedOperationsReport(String methodName);
+}

Added: incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalBusinessIntfcTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalBusinessIntfcTests.java?view=auto&rev=453677
==============================================================================
--- incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalBusinessIntfcTests.java
(added)
+++ incubator/openejb/trunk/openejb3/openejb-itests/src/main/java/org/apache/openejb/test/stateful/StatefulLocalBusinessIntfcTests.java
Fri Oct  6 10:07:16 2006
@@ -0,0 +1,125 @@
+/**
+ * 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.openejb.test.stateful;
+
+/**
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class StatefulLocalBusinessIntfcTests extends StatefulTestClient {
+    private BasicStatefulBusinessLocal businessLocal;
+
+    public StatefulLocalBusinessIntfcTests(){
+        super("LocalBusinessIntfc.");
+    }
+
+    protected void setUp() throws Exception{
+        super.setUp();
+    }
+
+    //=================================
+    // Test remote interface methods
+    //
+    public void test00_lookupBusinessInterface() throws Exception {
+        Object obj = initialContext.lookup("client/tests/stateful/BasicStatefulPojoHomeBusinessLocal");
+        assertNotNull(obj);
+        assertTrue("instance of BasicStatefulBusinessLocal", obj instanceof BasicStatefulBusinessLocal);
+        businessLocal = (BasicStatefulBusinessLocal) obj;
+    }
+
+    public void test01_businessMethod(){
+        try{
+            String expected = "Success";
+            String actual = businessLocal.businessMethod("sseccuS");
+            assertEquals(expected, actual);
+        } catch (Exception e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    /**
+     * Throw an application exception and make sure the exception
+     * reaches the bean nicely.
+     */
+    public void test02_throwApplicationException(){
+        try{
+            businessLocal.throwApplicationException();
+        } catch (org.apache.openejb.test.ApplicationException e){
+            //Good.  This is the correct behaviour
+            return;
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+        fail("An ApplicationException should have been thrown.");
+    }
+
+    /**
+     * After an application exception we should still be able to
+     * use our bean
+     */
+    public void test03_invokeAfterApplicationException(){
+        try{
+            String expected = "Success";
+            String actual   = businessLocal.businessMethod("sseccuS");
+            assertEquals(expected, actual);
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    // TODO: check which exception should be thrown
+    public void _test04_throwSystemException(){
+        try{
+            businessLocal.throwSystemException_NullPointer();
+        } catch (Exception e){
+            //Good, so far.
+            Throwable n = e.getCause();
+            assertNotNull("Nested exception should not be is null", n );
+            assertTrue("Nested exception should be an instance of NullPointerException, but
exception is "+n.getClass().getName(), (n instanceof NullPointerException));
+            return;
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+        fail("A NullPointerException should have been thrown.");
+    }
+
+    /**
+     * After a system exception the intance should be garbage collected
+     * and the remote reference should be invalidated.
+     *
+     * This one seems to fail. we should double-check the spec on this.
+     */
+    //TODO: implement
+    public void TODO_test05_invokeAfterSystemException(){
+//        try{
+//        businessLocal.businessMethod("This refernce is invalid");
+//        fail("A java.rmi.NoSuchObjectException should have been thrown.");
+//        } catch (java.rmi.NoSuchObjectException e){
+//            // Good.
+//        } catch (Throwable e){
+//            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+//        }
+    }
+    //
+    // Test remote interface methods
+    //=================================
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}



Mime
View raw message