You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2009/08/27 05:42:11 UTC
svn commit: r808273 [2/5] - in /openejb/trunk/openejb3:
container/openejb-core/src/main/java/org/apache/openejb/config/
container/openejb-core/src/main/java/org/apache/openejb/config/rules/
container/openejb-core/src/main/java/org/apache/openejb/core/e...
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java Thu Aug 27 03:42:06 2009
@@ -1,170 +1,170 @@
-/**
- * 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.config;
-
-import junit.framework.TestCase;
-import org.apache.openejb.assembler.classic.EjbJarInfo;
-import org.apache.openejb.assembler.classic.PortInfo;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.oejb2.*;
-import org.apache.openejb.jee.oejb3.OpenejbJar;
-
-import java.util.List;
-import java.util.Properties;
-
-public class AppInfoBuilderTest extends TestCase {
- public void testShouldAddSecurityDetailsToPortInfo() throws Exception {
- EjbJar ejbJar = new EjbJar();
- SessionBean sessionBean = new SessionBean();
- sessionBean.setEjbName("MySessionBean");
- sessionBean.setEjbClass("org.superbiz.MySessionBean");
- sessionBean.setRemote("org.superbiz.MySession");
- ejbJar.addEnterpriseBean(sessionBean);
-
- OpenejbJarType openejbJarType = new OpenejbJarType();
- SessionBeanType openejbSessionBean = new SessionBeanType();
- openejbSessionBean.setEjbName("MySessionBean");
-
- WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
- serviceSecurityType.setAuthMethod(AuthMethodType.BASIC);
- serviceSecurityType.setRealmName("MyRealm");
- serviceSecurityType.setSecurityRealmName("MySecurityRealm");
- serviceSecurityType.setTransportGuarantee(TransportGuaranteeType.NONE);
-
- Properties props = new Properties();
- props.put("wss4j.in.action", "Timestamp");
- props.put("wss4j.out.action", "Timestamp");
- serviceSecurityType.setProperties(props);
-
- openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
- openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
-
- EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
- ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
-
- EjbJarInfo ejbJarInfo = new EjbJarInfo();
- PortInfo portInfo = new PortInfo();
- portInfo.serviceLink = "MySessionBean";
- ejbJarInfo.portInfos.add(portInfo);
-
- new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
-
- List<PortInfo> portInfoList = ejbJarInfo.portInfos;
- assertEquals(1, portInfoList.size());
- PortInfo info = portInfoList.get(0);
- assertEquals("MyRealm", info.realmName);
- assertEquals("MySecurityRealm", info.securityRealmName);
- assertEquals("BASIC", info.authMethod);
- assertEquals("NONE", info.transportGuarantee);
- assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
- assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
- }
-
- public void testShouldUseDefaultsIfSettingIsNull() throws Exception {
- EjbJar ejbJar = new EjbJar();
- SessionBean sessionBean = new SessionBean();
- sessionBean.setEjbName("MySessionBean");
- sessionBean.setEjbClass("org.superbiz.MySessionBean");
- sessionBean.setRemote("org.superbiz.MySession");
- ejbJar.addEnterpriseBean(sessionBean);
-
- OpenejbJarType openejbJarType = new OpenejbJarType();
- SessionBeanType openejbSessionBean = new SessionBeanType();
- openejbSessionBean.setEjbName("MySessionBean");
-
- WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
- serviceSecurityType.setAuthMethod(null);
- serviceSecurityType.setRealmName(null);
- serviceSecurityType.setSecurityRealmName(null);
- serviceSecurityType.setTransportGuarantee(null);
- serviceSecurityType.setProperties(null);
-
- openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
- openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
-
- EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
- ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
-
- EjbJarInfo ejbJarInfo = new EjbJarInfo();
- PortInfo portInfo = new PortInfo();
- portInfo.serviceLink = "MySessionBean";
- ejbJarInfo.portInfos.add(portInfo);
-
- new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
-
- List<PortInfo> portInfoList = ejbJarInfo.portInfos;
- assertEquals(1, portInfoList.size());
- PortInfo info = portInfoList.get(0);
- assertEquals(null, info.realmName);
- assertEquals(null, info.securityRealmName);
- assertEquals("NONE", info.authMethod);
- assertEquals("NONE", info.transportGuarantee);
- assertTrue(portInfo.properties.isEmpty());
- }
-
- public void testShouldIgnorePortInfoThatDontMatchTheEjb() throws Exception {
- EjbJar ejbJar = new EjbJar();
- SessionBean sessionBean = new SessionBean();
- sessionBean.setEjbName("MySessionBean");
- sessionBean.setEjbClass("org.superbiz.MySessionBean");
- sessionBean.setRemote("org.superbiz.MySession");
- ejbJar.addEnterpriseBean(sessionBean);
-
- OpenejbJarType openejbJarType = new OpenejbJarType();
- SessionBeanType openejbSessionBean = new SessionBeanType();
- openejbSessionBean.setEjbName("MySessionBean");
-
- WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
- serviceSecurityType.setAuthMethod(null);
- serviceSecurityType.setRealmName(null);
- serviceSecurityType.setSecurityRealmName(null);
- serviceSecurityType.setTransportGuarantee(null);
- serviceSecurityType.setProperties(null);
-
- openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
- openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
-
- EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
- ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
-
- EjbJarInfo ejbJarInfo = new EjbJarInfo();
- PortInfo portInfo = new PortInfo();
- portInfo.authMethod = "DIGEST";
- portInfo.realmName = "";
- portInfo.securityRealmName = "";
- portInfo.transportGuarantee = "CONFIDENTIAL";
- portInfo.serviceLink = "DifferentInfo";
- Properties props = new Properties();
- props.put("wss4j.in.action", "Timestamp");
- props.put("wss4j.out.action", "Timestamp");
- portInfo.properties = props;
- ejbJarInfo.portInfos.add(portInfo);
-
- new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
-
- List<PortInfo> portInfoList = ejbJarInfo.portInfos;
- assertEquals(1, portInfoList.size());
- PortInfo info = portInfoList.get(0);
- assertEquals("", info.realmName);
- assertEquals("", info.securityRealmName);
- assertEquals("DIGEST", info.authMethod);
- assertEquals("CONFIDENTIAL", info.transportGuarantee);
- assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
- assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
- }
-}
+/**
+ * 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.config;
+
+import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.PortInfo;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SessionBean;
+import org.apache.openejb.jee.oejb2.*;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+
+import java.util.List;
+import java.util.Properties;
+
+public class AppInfoBuilderTest extends TestCase {
+ public void testShouldAddSecurityDetailsToPortInfo() throws Exception {
+ EjbJar ejbJar = new EjbJar();
+ SessionBean sessionBean = new SessionBean();
+ sessionBean.setEjbName("MySessionBean");
+ sessionBean.setEjbClass("org.superbiz.MySessionBean");
+ sessionBean.setRemote("org.superbiz.MySession");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ OpenejbJarType openejbJarType = new OpenejbJarType();
+ SessionBeanType openejbSessionBean = new SessionBeanType();
+ openejbSessionBean.setEjbName("MySessionBean");
+
+ WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+ serviceSecurityType.setAuthMethod(AuthMethodType.BASIC);
+ serviceSecurityType.setRealmName("MyRealm");
+ serviceSecurityType.setSecurityRealmName("MySecurityRealm");
+ serviceSecurityType.setTransportGuarantee(TransportGuaranteeType.NONE);
+
+ Properties props = new Properties();
+ props.put("wss4j.in.action", "Timestamp");
+ props.put("wss4j.out.action", "Timestamp");
+ serviceSecurityType.setProperties(props);
+
+ openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+ openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+ EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
+ ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+ EjbJarInfo ejbJarInfo = new EjbJarInfo();
+ PortInfo portInfo = new PortInfo();
+ portInfo.serviceLink = "MySessionBean";
+ ejbJarInfo.portInfos.add(portInfo);
+
+ new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+ List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+ assertEquals(1, portInfoList.size());
+ PortInfo info = portInfoList.get(0);
+ assertEquals("MyRealm", info.realmName);
+ assertEquals("MySecurityRealm", info.securityRealmName);
+ assertEquals("BASIC", info.authMethod);
+ assertEquals("NONE", info.transportGuarantee);
+ assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
+ assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
+ }
+
+ public void testShouldUseDefaultsIfSettingIsNull() throws Exception {
+ EjbJar ejbJar = new EjbJar();
+ SessionBean sessionBean = new SessionBean();
+ sessionBean.setEjbName("MySessionBean");
+ sessionBean.setEjbClass("org.superbiz.MySessionBean");
+ sessionBean.setRemote("org.superbiz.MySession");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ OpenejbJarType openejbJarType = new OpenejbJarType();
+ SessionBeanType openejbSessionBean = new SessionBeanType();
+ openejbSessionBean.setEjbName("MySessionBean");
+
+ WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+ serviceSecurityType.setAuthMethod(null);
+ serviceSecurityType.setRealmName(null);
+ serviceSecurityType.setSecurityRealmName(null);
+ serviceSecurityType.setTransportGuarantee(null);
+ serviceSecurityType.setProperties(null);
+
+ openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+ openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+ EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
+ ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+ EjbJarInfo ejbJarInfo = new EjbJarInfo();
+ PortInfo portInfo = new PortInfo();
+ portInfo.serviceLink = "MySessionBean";
+ ejbJarInfo.portInfos.add(portInfo);
+
+ new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+ List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+ assertEquals(1, portInfoList.size());
+ PortInfo info = portInfoList.get(0);
+ assertEquals(null, info.realmName);
+ assertEquals(null, info.securityRealmName);
+ assertEquals("NONE", info.authMethod);
+ assertEquals("NONE", info.transportGuarantee);
+ assertTrue(portInfo.properties.isEmpty());
+ }
+
+ public void testShouldIgnorePortInfoThatDontMatchTheEjb() throws Exception {
+ EjbJar ejbJar = new EjbJar();
+ SessionBean sessionBean = new SessionBean();
+ sessionBean.setEjbName("MySessionBean");
+ sessionBean.setEjbClass("org.superbiz.MySessionBean");
+ sessionBean.setRemote("org.superbiz.MySession");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ OpenejbJarType openejbJarType = new OpenejbJarType();
+ SessionBeanType openejbSessionBean = new SessionBeanType();
+ openejbSessionBean.setEjbName("MySessionBean");
+
+ WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+ serviceSecurityType.setAuthMethod(null);
+ serviceSecurityType.setRealmName(null);
+ serviceSecurityType.setSecurityRealmName(null);
+ serviceSecurityType.setTransportGuarantee(null);
+ serviceSecurityType.setProperties(null);
+
+ openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+ openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+ EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
+ ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+ EjbJarInfo ejbJarInfo = new EjbJarInfo();
+ PortInfo portInfo = new PortInfo();
+ portInfo.authMethod = "DIGEST";
+ portInfo.realmName = "";
+ portInfo.securityRealmName = "";
+ portInfo.transportGuarantee = "CONFIDENTIAL";
+ portInfo.serviceLink = "DifferentInfo";
+ Properties props = new Properties();
+ props.put("wss4j.in.action", "Timestamp");
+ props.put("wss4j.out.action", "Timestamp");
+ portInfo.properties = props;
+ ejbJarInfo.portInfos.add(portInfo);
+
+ new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+ List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+ assertEquals(1, portInfoList.size());
+ PortInfo info = portInfoList.get(0);
+ assertEquals("", info.realmName);
+ assertEquals("", info.securityRealmName);
+ assertEquals("DIGEST", info.authMethod);
+ assertEquals("CONFIDENTIAL", info.transportGuarantee);
+ assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
+ assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/MappedNameBuilderTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/MappedNameBuilderTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/MappedNameBuilderTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/MappedNameBuilderTest.java Thu Aug 27 03:42:06 2009
@@ -1,92 +1,92 @@
-/**
- *
- * 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.config;
-
-import junit.framework.TestCase;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.SessionType;
-import org.apache.openejb.jee.oejb3.OpenejbJar;
-import org.apache.openejb.jee.oejb3.EjbDeployment;
-import org.apache.openejb.jee.oejb3.Jndi;
-
-import java.util.List;
-
-public class MappedNameBuilderTest extends TestCase {
- public void testShouldCreateJndiEntryForBeanWithMappedName() throws Exception {
- AppModule appModule = new AppModule(new FakeClassLoader(), "");
- EjbJar ejbJar = new EjbJar();
- OpenejbJar openejbJar = new OpenejbJar();
-
- SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
- sessionBean.setMappedName("MappedName");
- ejbJar.addEnterpriseBean(sessionBean);
-
- EjbDeployment ejbDeployment = new EjbDeployment("containerId","deploymentId", "SessionBean");
- openejbJar.addEjbDeployment(ejbDeployment);
- appModule.getEjbModules().add(new EjbModule(ejbJar, openejbJar));
-
- appModule = new MappedNameBuilder().deploy(appModule);
-
- EjbDeployment retrievedDeployment = appModule.getEjbModules().get(0).getOpenejbJar().getDeploymentsByEjbName().get("SessionBean");
- List<Jndi> jndiList = retrievedDeployment.getJndi();
-
- assertNotNull(jndiList);
- assertEquals(1, jndiList.size());
- assertEquals("MappedName", jndiList.get(0).getName());
- assertEquals("Remote", jndiList.get(0).getInterface());
- }
-
- public void testIgnoreMappedNameIfOpenejbJarModuleDoesntExist() throws Exception {
- AppModule appModule = new AppModule(new FakeClassLoader(), "");
- EjbJar ejbJar = new EjbJar();
-
- SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
- sessionBean.setMappedName("MappedName");
- ejbJar.addEnterpriseBean(sessionBean);
-
- appModule.getEjbModules().add(new EjbModule(ejbJar, null));
- appModule = new MappedNameBuilder().deploy(appModule);
-
- OpenejbJar openejbJar = appModule.getEjbModules().get(0).getOpenejbJar();
- assertNull(openejbJar);
- }
-
- public void testShouldIgnoreMappedNameIfDeploymentDoesntExist() throws Exception {
- AppModule appModule = new AppModule(new FakeClassLoader(), "");
- EjbJar ejbJar = new EjbJar();
- OpenejbJar openejbJar = new OpenejbJar();
-
- SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
- sessionBean.setMappedName("MappedName");
- ejbJar.addEnterpriseBean(sessionBean);
-
- appModule.getEjbModules().add(new EjbModule(ejbJar, openejbJar));
- appModule = new MappedNameBuilder().deploy(appModule);
-
- EjbDeployment deployment = appModule.getEjbModules().get(0).getOpenejbJar().getDeploymentsByEjbName().get("SessionBean");
- assertNull(deployment);
- }
-
- private class FakeClassLoader extends ClassLoader {
- protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- return Object.class;
- }
- }
-}
+/**
+ *
+ * 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.config;
+
+import junit.framework.TestCase;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SessionBean;
+import org.apache.openejb.jee.SessionType;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.jee.oejb3.EjbDeployment;
+import org.apache.openejb.jee.oejb3.Jndi;
+
+import java.util.List;
+
+public class MappedNameBuilderTest extends TestCase {
+ public void testShouldCreateJndiEntryForBeanWithMappedName() throws Exception {
+ AppModule appModule = new AppModule(new FakeClassLoader(), "");
+ EjbJar ejbJar = new EjbJar();
+ OpenejbJar openejbJar = new OpenejbJar();
+
+ SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
+ sessionBean.setMappedName("MappedName");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ EjbDeployment ejbDeployment = new EjbDeployment("containerId","deploymentId", "SessionBean");
+ openejbJar.addEjbDeployment(ejbDeployment);
+ appModule.getEjbModules().add(new EjbModule(ejbJar, openejbJar));
+
+ appModule = new MappedNameBuilder().deploy(appModule);
+
+ EjbDeployment retrievedDeployment = appModule.getEjbModules().get(0).getOpenejbJar().getDeploymentsByEjbName().get("SessionBean");
+ List<Jndi> jndiList = retrievedDeployment.getJndi();
+
+ assertNotNull(jndiList);
+ assertEquals(1, jndiList.size());
+ assertEquals("MappedName", jndiList.get(0).getName());
+ assertEquals("Remote", jndiList.get(0).getInterface());
+ }
+
+ public void testIgnoreMappedNameIfOpenejbJarModuleDoesntExist() throws Exception {
+ AppModule appModule = new AppModule(new FakeClassLoader(), "");
+ EjbJar ejbJar = new EjbJar();
+
+ SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
+ sessionBean.setMappedName("MappedName");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ appModule.getEjbModules().add(new EjbModule(ejbJar, null));
+ appModule = new MappedNameBuilder().deploy(appModule);
+
+ OpenejbJar openejbJar = appModule.getEjbModules().get(0).getOpenejbJar();
+ assertNull(openejbJar);
+ }
+
+ public void testShouldIgnoreMappedNameIfDeploymentDoesntExist() throws Exception {
+ AppModule appModule = new AppModule(new FakeClassLoader(), "");
+ EjbJar ejbJar = new EjbJar();
+ OpenejbJar openejbJar = new OpenejbJar();
+
+ SessionBean sessionBean = new SessionBean("SessionBean", "org.superbiz.SessionBean", SessionType.STATELESS);
+ sessionBean.setMappedName("MappedName");
+ ejbJar.addEnterpriseBean(sessionBean);
+
+ appModule.getEjbModules().add(new EjbModule(ejbJar, openejbJar));
+ appModule = new MappedNameBuilder().deploy(appModule);
+
+ EjbDeployment deployment = appModule.getEjbModules().get(0).getOpenejbJar().getDeploymentsByEjbName().get("SessionBean");
+ assertNull(deployment);
+ }
+
+ private class FakeClassLoader extends ClassLoader {
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ return Object.class;
+ }
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckUserTransactionRefsTest.java Thu Aug 27 03:42:06 2009
@@ -1,74 +1,74 @@
-/**
- * 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.config.rules;
-
-import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.InjectionTarget;
-import org.apache.openejb.jee.ResourceRef;
-import org.apache.openejb.jee.StatelessBean;
-import static org.apache.openejb.jee.TransactionType.CONTAINER;
-import static org.hamcrest.CoreMatchers.is;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @version $Rev$ $Date$
- */
-public class CheckUserTransactionRefsTest {
-
- private EjbModule module;
- private StatelessBean bean;
-
- private CheckUserTransactionRefs rule;
-
- @Before
- public void initialize() {
- bean = new StatelessBean("CheeseEjb", "org.acme.CheeseEjb");
- bean.setTransactionType(CONTAINER);
-
- module = new EjbModule(new EjbJar());
- module.getEjbJar().addEnterpriseBean(bean);
-
- rule = new CheckUserTransactionRefs();
- rule.module = module;
- }
-
- @Test
- public void testSLSBwithUserTransaction() {
-
- // "@Resource UserTransaction tx" declaration
- ResourceRef resourceRef = new ResourceRef();
- resourceRef.setResRefName("org.acme.CheeseEjb/tx");
- resourceRef.setResType("javax.transaction.UserTransaction");
- resourceRef.getInjectionTarget().add(new InjectionTarget("org.acme.CheeseEjb", "org.acme.CheeseEjb/tx"));
- bean.getResourceRef().add(resourceRef);
-
- rule.validate(module);
-
- Assert.assertThat(module.getValidation().getErrors().length, is(1));
- Assert.assertThat(module.getValidation().getWarnings().length, is(0));
- Assert.assertThat(module.getValidation().getFailures().length, is(0));
- }
-
- @After
- public void cleanUp() {
- module = null;
- }
-}
+/**
+ * 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.config.rules;
+
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.InjectionTarget;
+import org.apache.openejb.jee.ResourceRef;
+import org.apache.openejb.jee.StatelessBean;
+import static org.apache.openejb.jee.TransactionType.CONTAINER;
+import static org.hamcrest.CoreMatchers.is;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckUserTransactionRefsTest {
+
+ private EjbModule module;
+ private StatelessBean bean;
+
+ private CheckUserTransactionRefs rule;
+
+ @Before
+ public void initialize() {
+ bean = new StatelessBean("CheeseEjb", "org.acme.CheeseEjb");
+ bean.setTransactionType(CONTAINER);
+
+ module = new EjbModule(new EjbJar());
+ module.getEjbJar().addEnterpriseBean(bean);
+
+ rule = new CheckUserTransactionRefs();
+ rule.module = module;
+ }
+
+ @Test
+ public void testSLSBwithUserTransaction() {
+
+ // "@Resource UserTransaction tx" declaration
+ ResourceRef resourceRef = new ResourceRef();
+ resourceRef.setResRefName("org.acme.CheeseEjb/tx");
+ resourceRef.setResType("javax.transaction.UserTransaction");
+ resourceRef.getInjectionTarget().add(new InjectionTarget("org.acme.CheeseEjb", "org.acme.CheeseEjb/tx"));
+ bean.getResourceRef().add(resourceRef);
+
+ rule.validate(module);
+
+ Assert.assertThat(module.getValidation().getErrors().length, is(1));
+ Assert.assertThat(module.getValidation().getWarnings().length, is(0));
+ Assert.assertThat(module.getValidation().getFailures().length, is(0));
+ }
+
+ @After
+ public void cleanUp() {
+ module = null;
+ }
+}
Modified: openejb/trunk/openejb3/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonImpl.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonImpl.java (original)
+++ openejb/trunk/openejb3/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonImpl.java Thu Aug 27 03:42:06 2009
@@ -1,125 +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.superbiz;
-
-import javax.ejb.Init;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.ejb.Remote;
-import javax.ejb.Local;
-import javax.ejb.RemoteHome;
-import javax.ejb.LocalHome;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Properties;
-
-/**
- * This is an EJB 3 style pojo stateful session bean
- * it does not need to implement javax.ejb.SessionBean
- *
- * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
- */
-//START SNIPPET: code
-// EJB 3.0 Style business interfaces
-// Each of these interfaces are already annotated in the classes
-// themselves with @Remote and @Local, so annotating them here
-// in the bean class again is not really required.
-@Remote({FriendlyPersonRemote.class})
-@Local({FriendlyPersonLocal.class})
-
-// EJB 2.1 Style component interfaces
-// These interfaces, however, must be annotated here in the bean class.
-// Use of @RemoteHome in the FriendlyPersonEjbHome class itself is not allowed.
-// Use of @LocalHome in the FriendlyPersonEjbLocalHome class itself is also not allowed.
-@RemoteHome(FriendlyPersonEjbHome.class)
-@LocalHome(FriendlyPersonEjbLocalHome.class)
-
-@Stateful(name="FriendlyPerson")
-public class FriendlyPersonImpl implements FriendlyPersonLocal, FriendlyPersonRemote {
-
- private final HashMap<String, MessageFormat> greetings;
- private final Properties languagePreferences;
-
- private String defaultLanguage;
-
- public FriendlyPersonImpl() {
- greetings = new HashMap();
- languagePreferences = new Properties();
- defaultLanguage = Locale.getDefault().getLanguage();
-
- addGreeting("en", "Hello {0}!");
- addGreeting("es", "Hola {0}!");
- addGreeting("fr", "Bonjour {0}!");
- addGreeting("pl", "Witaj {0}!");
- }
-
- /**
- * This method corresponds to the FriendlyPersonEjbHome.create() method
- * and the FriendlyPersonEjbLocalHome.create()
- *
- * If you do not have an EJBHome or EJBLocalHome interface, this method
- * can be deleted.
- */
- @Init
- public void create(){}
-
- /**
- * This method corresponds to the following methods:
- * - EJBObject.remove()
- * - EJBHome.remove(ejbObject)
- * - EJBLocalObject.remove()
- * - EJBLocalHome.remove(ejbObject)
- *
- * If you do not have an EJBHome or EJBLocalHome interface, this method
- * can be deleted.
- */
- @Remove
- public void remove(){}
-
- public String greet(String friend) {
- String language = languagePreferences.getProperty(friend, defaultLanguage);
- return greet(language, friend);
- }
-
- public String greet(String language, String friend) {
- MessageFormat greeting = greetings.get(language);
- if (greeting == null) {
- Locale locale = new Locale(language);
- return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
- }
-
- return greeting.format(new Object[]{friend});
- }
-
- public void addGreeting(String language, String message) {
- greetings.put(language, new MessageFormat(message));
- }
-
- public void setLanguagePreferences(String friend, String language) {
- languagePreferences.put(friend, language);
- }
-
- public String getDefaultLanguage() {
- return defaultLanguage;
- }
-
- public void setDefaultLanguage(String defaultLanguage) {
- this.defaultLanguage = defaultLanguage;
- }
-}
-//END SNIPPET: code
+/**
+ * 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.superbiz;
+
+import javax.ejb.Init;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.Remote;
+import javax.ejb.Local;
+import javax.ejb.RemoteHome;
+import javax.ejb.LocalHome;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * it does not need to implement javax.ejb.SessionBean
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ */
+//START SNIPPET: code
+// EJB 3.0 Style business interfaces
+// Each of these interfaces are already annotated in the classes
+// themselves with @Remote and @Local, so annotating them here
+// in the bean class again is not really required.
+@Remote({FriendlyPersonRemote.class})
+@Local({FriendlyPersonLocal.class})
+
+// EJB 2.1 Style component interfaces
+// These interfaces, however, must be annotated here in the bean class.
+// Use of @RemoteHome in the FriendlyPersonEjbHome class itself is not allowed.
+// Use of @LocalHome in the FriendlyPersonEjbLocalHome class itself is also not allowed.
+@RemoteHome(FriendlyPersonEjbHome.class)
+@LocalHome(FriendlyPersonEjbLocalHome.class)
+
+@Stateful(name="FriendlyPerson")
+public class FriendlyPersonImpl implements FriendlyPersonLocal, FriendlyPersonRemote {
+
+ private final HashMap<String, MessageFormat> greetings;
+ private final Properties languagePreferences;
+
+ private String defaultLanguage;
+
+ public FriendlyPersonImpl() {
+ greetings = new HashMap();
+ languagePreferences = new Properties();
+ defaultLanguage = Locale.getDefault().getLanguage();
+
+ addGreeting("en", "Hello {0}!");
+ addGreeting("es", "Hola {0}!");
+ addGreeting("fr", "Bonjour {0}!");
+ addGreeting("pl", "Witaj {0}!");
+ }
+
+ /**
+ * This method corresponds to the FriendlyPersonEjbHome.create() method
+ * and the FriendlyPersonEjbLocalHome.create()
+ *
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Init
+ public void create(){}
+
+ /**
+ * This method corresponds to the following methods:
+ * - EJBObject.remove()
+ * - EJBHome.remove(ejbObject)
+ * - EJBLocalObject.remove()
+ * - EJBLocalHome.remove(ejbObject)
+ *
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Remove
+ public void remove(){}
+
+ public String greet(String friend) {
+ String language = languagePreferences.getProperty(friend, defaultLanguage);
+ return greet(language, friend);
+ }
+
+ public String greet(String language, String friend) {
+ MessageFormat greeting = greetings.get(language);
+ if (greeting == null) {
+ Locale locale = new Locale(language);
+ return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
+ }
+
+ return greeting.format(new Object[]{friend});
+ }
+
+ public void addGreeting(String language, String message) {
+ greetings.put(language, new MessageFormat(message));
+ }
+
+ public void setLanguagePreferences(String friend, String language) {
+ languagePreferences.put(friend, language);
+ }
+
+ public String getDefaultLanguage() {
+ return defaultLanguage;
+ }
+
+ public void setDefaultLanguage(String defaultLanguage) {
+ this.defaultLanguage = defaultLanguage;
+ }
+}
+//END SNIPPET: code
Modified: openejb/trunk/openejb3/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java (original)
+++ openejb/trunk/openejb3/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java Thu Aug 27 03:42:06 2009
@@ -1,186 +1,186 @@
-/**
- * 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.superbiz;
-
-import junit.framework.TestCase;
-
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import java.util.Locale;
-import java.util.Properties;
-
-/**
- * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
- *
- * @version $Rev$ $Date$
- */
-public class FriendlyPersonTest extends TestCase {
- private InitialContext initialContext;
-
- protected void setUp() throws Exception {
- Properties properties = new Properties();
- properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
- initialContext = new InitialContext(properties);
- }
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
- *
- * @throws Exception
- */
- //START SNIPPET: remotehome
- public void testEjbHomeAndEjbObject() throws Exception {
- Object object = initialContext.lookup("FriendlyPersonRemoteHome");
- FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
- FriendlyPersonEjbObject friendlyPerson = home.create();
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
- //END SNIPPET: remotehome
-
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
- *
- * @throws Exception
- */
- public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
- Object object = initialContext.lookup("FriendlyPersonLocalHome");
- FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
- FriendlyPersonEjbLocalObject friendlyPerson = home.create();
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
- *
- * @throws Exception
- */
- //START SNIPPET: remote
- public void testBusinessRemote() throws Exception {
- Object object = initialContext.lookup("FriendlyPersonRemote");
-
- FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
- //START SNIPPET: remote
-
- /**
- * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
- *
- * @throws Exception
- */
- public void testBusinessLocal() throws Exception {
- Object object = initialContext.lookup("FriendlyPersonLocal");
-
- FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
-
- friendlyPerson.setDefaultLanguage("en");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
-
- friendlyPerson.setLanguagePreferences("Amelia", "es");
-
- assertEquals("Hello David!", friendlyPerson.greet("David"));
- assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
-
- // Amelia took some French, let's see if she remembers
- assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
-
- // Dave should take some Polish and if he had, he could say Hi in Polish
- assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
-
- // Let's see if I speak Portuguese
- assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
-
- // Ok, well I've been meaning to learn, so...
- friendlyPerson.addGreeting("pt", "Ola {0}!");
-
- assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
- }
-
-
-}
+/**
+ * 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.superbiz;
+
+import junit.framework.TestCase;
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ *
+ * @version $Rev$ $Date$
+ */
+public class FriendlyPersonTest extends TestCase {
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
+ initialContext = new InitialContext(properties);
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotehome
+ public void testEjbHomeAndEjbObject() throws Exception {
+ Object object = initialContext.lookup("FriendlyPersonRemoteHome");
+ FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
+ FriendlyPersonEjbObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //END SNIPPET: remotehome
+
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
+ *
+ * @throws Exception
+ */
+ public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
+ Object object = initialContext.lookup("FriendlyPersonLocalHome");
+ FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
+ FriendlyPersonEjbLocalObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testBusinessRemote() throws Exception {
+ Object object = initialContext.lookup("FriendlyPersonRemote");
+
+ FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //START SNIPPET: remote
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
+ *
+ * @throws Exception
+ */
+ public void testBusinessLocal() throws Exception {
+ Object object = initialContext.lookup("FriendlyPersonLocal");
+
+ FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+
+}
Modified: openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java (original)
+++ openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java Thu Aug 27 03:42:06 2009
@@ -1,45 +1,45 @@
-/**
- * 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.superbiz.interceptors;
-
-import javax.ejb.Stateless;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptors;
-import javax.interceptor.InvocationContext;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @version $Rev$ $Date$
- */
-@Stateless
-@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
-public class SecondStatelessInterceptedBean implements SecondStatelessInterceptedLocal {
-
- @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
- public List<String> methodWithDefaultInterceptorsExcluded() {
- List<String> list = new ArrayList<String>();
- list.add("methodWithDefaultInterceptorsExcluded");
- return list;
-
- }
-
- @AroundInvoke
- protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
- return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
- }
-}
+/**
+ * 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.superbiz.interceptors;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Stateless
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+public class SecondStatelessInterceptedBean implements SecondStatelessInterceptedLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
Modified: openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java (original)
+++ openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java Thu Aug 27 03:42:06 2009
@@ -1,26 +1,26 @@
-/**
- * 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.superbiz.interceptors;
-
-import java.util.List;
-
-/**
- * @version $Rev$ $Date$
- */
-public interface SecondStatelessInterceptedLocal {
- List<String> methodWithDefaultInterceptorsExcluded();
-}
+/**
+ * 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.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface SecondStatelessInterceptedLocal {
+ List<String> methodWithDefaultInterceptorsExcluded();
+}
Modified: openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java (original)
+++ openejb/trunk/openejb3/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java Thu Aug 27 03:42:06 2009
@@ -1,38 +1,38 @@
-/**
- * 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.superbiz.interceptors;
-
-import javax.interceptor.InvocationContext;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @version $Rev$ $Date$
- */
-public class Utils {
-
- public static List<String> addClassSimpleName(InvocationContext ic, String classSimpleName) throws Exception {
- List<String> list = new ArrayList<String>();
- list.add(classSimpleName);
- List<String> listOfStrings = (List<String>) ic.proceed();
- if (listOfStrings != null) {
- list.addAll(listOfStrings);
- }
- return list;
- }
-
-}
+/**
+ * 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.superbiz.interceptors;
+
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Utils {
+
+ public static List<String> addClassSimpleName(InvocationContext ic, String classSimpleName) throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add(classSimpleName);
+ List<String> listOfStrings = (List<String>) ic.proceed();
+ if (listOfStrings != null) {
+ list.addAll(listOfStrings);
+ }
+ return list;
+ }
+
+}
Modified: openejb/trunk/openejb3/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java (original)
+++ openejb/trunk/openejb3/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java Thu Aug 27 03:42:06 2009
@@ -1,64 +1,64 @@
-/**
- * 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.superbiz.interceptors;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SecondStatelessInterceptedTest extends TestCase {
-
- private InitialContext initCtx;
-
- @Before
- public void setUp() throws Exception {
- Properties properties = new Properties();
- properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
- properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
-
- initCtx = new InitialContext(properties);
- }
-
- @Test
- public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
- SecondStatelessInterceptedLocal bean =
- (SecondStatelessInterceptedLocal) initCtx.lookup("SecondStatelessInterceptedBeanLocal");
-
- assert bean != null;
-
- List<String> expected = new ArrayList<String>();
- expected.add("ClassLevelInterceptorOne");
- expected.add("ClassLevelInterceptorTwo");
- expected.add("MethodLevelInterceptorOne");
- expected.add("MethodLevelInterceptorTwo");
- expected.add("SecondStatelessInterceptedBean");
- expected.add("methodWithDefaultInterceptorsExcluded");
-
- List<String> actual = bean.methodWithDefaultInterceptorsExcluded();
- assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
- }
-}
+/**
+ * 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.superbiz.interceptors;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecondStatelessInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ SecondStatelessInterceptedLocal bean =
+ (SecondStatelessInterceptedLocal) initCtx.lookup("SecondStatelessInterceptedBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("SecondStatelessInterceptedBean");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = bean.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}
Modified: openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/ChatBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/ChatBean.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/ChatBean.java (original)
+++ openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/ChatBean.java Thu Aug 27 03:42:06 2009
@@ -1,77 +1,77 @@
-/**
- * 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.
- */
-//START SNIPPET: code
-package org.superbiz.mdb;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-public class ChatBean implements MessageListener {
-
-
- public void onMessage(Message message) {
- try {
- TextMessage textMessage = (TextMessage) message;
- String question = textMessage.getText();
-
- if (question.equals("Hello World!")){
- respond("Hello, Test Case!");
- } else if (question.equals("How are you?")){
- respond("I'm doing well.");
- } else if (question.equals("Still spinning?")){
- respond("Once every day, as usual.");
- }
- } catch (JMSException e) {
- e.printStackTrace();
- }
- }
-
- private void respond(String text) throws JMSException {
-
- Connection connection = null;
- Session session = null;
-
- try {
- InitialContext context = new InitialContext();
- ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
- connection = connectionFactory.createConnection();
- connection.start();
-
- // Create a Session
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Create a MessageProducer from the Session to the Topic or Queue
- Queue answerQueue = (Queue) context.lookup("java:comp/env/AnswerQueue");
- MessageProducer producer = session.createProducer(answerQueue);
- producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- // Create a message
- TextMessage message = session.createTextMessage(text);
-
- // Tell the producer to send the message
- producer.send(message);
- } catch (NamingException e) {
- e.printStackTrace();
- } finally {
- // Clean up
- if (session != null) session.close();
- if (connection != null) connection.close();
- }
- }
-}
-//END SNIPPET: code
+/**
+ * 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.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class ChatBean implements MessageListener {
+
+
+ public void onMessage(Message message) {
+ try {
+ TextMessage textMessage = (TextMessage) message;
+ String question = textMessage.getText();
+
+ if (question.equals("Hello World!")){
+ respond("Hello, Test Case!");
+ } else if (question.equals("How are you?")){
+ respond("I'm doing well.");
+ } else if (question.equals("Still spinning?")){
+ respond("Once every day, as usual.");
+ }
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ InitialContext context = new InitialContext();
+ ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ Queue answerQueue = (Queue) context.lookup("java:comp/env/AnswerQueue");
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } catch (NamingException e) {
+ e.printStackTrace();
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+}
+//END SNIPPET: code
Modified: openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientBean.java?rev=808273&r1=808272&r2=808273&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientBean.java (original)
+++ openejb/trunk/openejb3/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdb/MessagingClientBean.java Thu Aug 27 03:42:06 2009
@@ -1,89 +1,89 @@
-/**
- * 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.
- */
-//START SNIPPET: code
-package org.superbiz.mdb;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-public class MessagingClientBean implements MessagingClientLocal {
- public void sendMessage(String text) throws JMSException {
-
- Connection connection = null;
- Session session = null;
-
- try {
- InitialContext context = new InitialContext();
- ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
-
- connection = connectionFactory.createConnection();
- connection.start();
-
- // Create a Session
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Create a MessageProducer from the Session to the Topic or Queue
- Queue questionQueue = (Queue) context.lookup("java:comp/env/ChatBean");
- MessageProducer producer = session.createProducer(questionQueue);
- producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- // Create a message
- TextMessage message = session.createTextMessage(text);
-
- // Tell the producer to send the message
- producer.send(message);
- } catch (NamingException e) {
- e.printStackTrace();
- } finally {
- // Clean up
- if (session != null) session.close();
- if (connection != null) connection.close();
- }
- }
-
- public String receiveMessage() throws JMSException, NamingException {
-
- Connection connection = null;
- Session session = null;
- MessageConsumer consumer = null;
- try {
- InitialContext context = new InitialContext();
- ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
- connection = connectionFactory.createConnection();
- connection.start();
-
- // Create a Session
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Create a MessageConsumer from the Session to the Topic or Queue
- Queue answerQueue = (Queue) context.lookup("java:comp/env/AnswerQueue");
- consumer = session.createConsumer(answerQueue);
-
- // Wait for a message
- TextMessage message = (TextMessage) consumer.receive(1000);
-
- return message.getText();
- } finally {
- if (consumer != null) consumer.close();
- if (session != null) session.close();
- if (connection != null) connection.close();
- }
-
- }
-}
-//END SNIPPET: code
+/**
+ * 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.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class MessagingClientBean implements MessagingClientLocal {
+ public void sendMessage(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ InitialContext context = new InitialContext();
+ ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
+
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ Queue questionQueue = (Queue) context.lookup("java:comp/env/ChatBean");
+ MessageProducer producer = session.createProducer(questionQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } catch (NamingException e) {
+ e.printStackTrace();
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+
+ public String receiveMessage() throws JMSException, NamingException {
+
+ Connection connection = null;
+ Session session = null;
+ MessageConsumer consumer = null;
+ try {
+ InitialContext context = new InitialContext();
+ ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:comp/env/ConnectionFactory");
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageConsumer from the Session to the Topic or Queue
+ Queue answerQueue = (Queue) context.lookup("java:comp/env/AnswerQueue");
+ consumer = session.createConsumer(answerQueue);
+
+ // Wait for a message
+ TextMessage message = (TextMessage) consumer.receive(1000);
+
+ return message.getText();
+ } finally {
+ if (consumer != null) consumer.close();
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+
+ }
+}
+//END SNIPPET: code