You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2008/03/21 12:26:19 UTC
svn commit: r639599 [1/3] - in
/openejb/trunk/sandbox/openejb-eclipse-plugin: eclipse/
features/org.apache.openejb.feature/
features/org.apache.openejb.feature/.externalToolBuilders/
openejb-eclipse-plugin/assembly/ plugins/org.apache.openejb.helper.an...
Author: jlaskowski
Date: Fri Mar 21 04:25:51 2008
New Revision: 639599
URL: http://svn.apache.org/viewvc?rev=639599&view=rev
Log:
OPENEJB-674 Eclipse plugin for OpenEJB
Contributed by: Jonathan Gallimore
Patch: patch-19032008.diff
Added:
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EntityBeanConverter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EntityBeanPojoConverter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/IJDTFacade.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/JDTFacade.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/MessageDrivenBeanConverter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/SessionBeanConverter.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/SessionBeanInterfaceModifier.java (with props)
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/SessionBeanRemoteAnnotationAdder.java (with props)
Modified:
openejb/trunk/sandbox/openejb-eclipse-plugin/eclipse/build.xml
openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/.externalToolBuilders/Maven_Ant_Builder.launch
openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/maven-eclipse.xml
openejb/trunk/sandbox/openejb-eclipse-plugin/openejb-eclipse-plugin/assembly/test.xml
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/AddAnnotationTest.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/OpenEjbXmlConverterTest.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/META-INF/MANIFEST.MF
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/maven-eclipse.xml
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/IJavaProjectAnnotationFacade.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/JavaProjectAnnotationFacade.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/OpenEjbXmlConverter.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/ProjectSelectionPage.java
openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.eclipse.jst.server.generic.openejb/maven-eclipse.xml
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/eclipse/build.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/eclipse/build.xml?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/eclipse/build.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/eclipse/build.xml Fri Mar 21 04:25:51 2008
@@ -26,7 +26,7 @@
<property name="dtp_drop" value="1.5"/>
<property name="emf_drop" value="2.3.1/R200709252135"/>
<property name="gef_drop" value="R-3.3.1-200709241000"/>
- <property name="wtp_drop" value="R-2.0.1-20070926042742"/>
+ <property name="wtp_drop" value="R-2.0.2-20080223205547"/>
<property name="base_url" value="http://www.eclipse.org/downloads/download.php?file="/>
<property name="europa_win32_url" value="${base_url}/eclipse/downloads/drops/${europa_drop}/"/>
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/.externalToolBuilders/Maven_Ant_Builder.launch
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/.externalToolBuilders/Maven_Ant_Builder.launch?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/.externalToolBuilders/Maven_Ant_Builder.launch (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/.externalToolBuilders/Maven_Ant_Builder.launch Fri Mar 21 04:25:51 2008
@@ -1,24 +0,0 @@
-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
- <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
- <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/>
- <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
- <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
- <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.apache.openejb.feature"/>
- <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
- <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/maven-eclipse.xml"/>
- <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
- <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
- <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
- <stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version='1.0'?><launchConfigurationWorkingSet editPageId='org.eclipse.ui.resourceWorkingSetPage' factoryID='org.eclipse.ui.internal.WorkingSetFactory' label='workingSet' name='workingSet'><item factoryID='org.eclipse.ui.internal.model.ResourceFactory' path='org.apache.openejb.feature' type='4'/></launchConfigurationWorkingSet>}"/>
- <stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
- <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
- <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
- <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
- <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
- <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
- <listEntry value="1"/>
- </listAttribute>
- <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
- <listEntry value="/org.apache.openejb.feature/maven-eclipse.xml"/>
- </listAttribute>
-</launchConfiguration>
\ No newline at end of file
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/maven-eclipse.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/maven-eclipse.xml?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/maven-eclipse.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/features/org.apache.openejb.feature/maven-eclipse.xml Fri Mar 21 04:25:51 2008
@@ -1,8 +0,0 @@
-<project default="copy-resources">
- <target name="init"/>
- <target name="copy-resources" depends="init">
- <copy todir="target/classes/META-INF" filtering="false">
- <fileset dir="F:/Jonno/OpenEJB/src/sandbox/openejb-eclipse-plugin/features" includes="LICENSE|NOTICE"/>
- </copy>
- </target>
-</project>
\ No newline at end of file
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/openejb-eclipse-plugin/assembly/test.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/openejb-eclipse-plugin/assembly/test.xml?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/openejb-eclipse-plugin/assembly/test.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/openejb-eclipse-plugin/assembly/test.xml Fri Mar 21 04:25:51 2008
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${LOCAL_M2_REPO}/eclipse/eclipse"/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.apache.openejb.helper.annotation.test"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test_3.2.0/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="test-folder"
- value="${eclipse-home}/test_folder"/>
- <delete dir="${test-folder}" quiet="true"/>
- <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${test-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.apache.openejb.helper.annotation.tests.AllOpenEJBAnnotationHelperTests"/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <echo message="Running tests..."/>
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
- </project>
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/AddAnnotationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/AddAnnotationTest.java?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/AddAnnotationTest.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/AddAnnotationTest.java Fri Mar 21 04:25:51 2008
@@ -33,7 +33,7 @@
import junit.framework.TestCase;
-import org.apache.openejb.helper.annotation.JavaProjectAnnotationFacade;
+import org.apache.openejb.helper.annotation.JDTFacade;
import org.apache.openejb.helper.annotation.fixtures.ProjectFixture;
import org.apache.openejb.helper.annotation.fixtures.StreamFixture;
import org.eclipse.core.runtime.CoreException;
@@ -96,7 +96,7 @@
public void testShouldAddAnAnnotationToAJavaSourceFile() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean1", getStreamContents(getClass().getResourceAsStream("Test1.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addClassAnnotation("org.apache.openejb.test.TestBean1", Stateless.class, null);
Change change = facade.getChange();
@@ -109,7 +109,7 @@
public void testShouldAddAnAnnotationToAJavaSourceFileAndNotAddAnImportIfTheImportAlreadyExists() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean2", getStreamContents(getClass().getResourceAsStream("Test2.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addClassAnnotation("org.apache.openejb.test.TestBean2", Stateless.class, null);
Change change = facade.getChange();
@@ -121,7 +121,7 @@
public void testShouldAddAnAnnotationToAJavaSourceFileAndNotAddAnImportIfThePackageIsAlreadyImported() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean3", getStreamContents(getClass().getResourceAsStream("Test3.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addClassAnnotation("org.apache.openejb.test.TestBean3", Stateless.class, null);
Change change = facade.getChange();
@@ -136,7 +136,7 @@
Map<String,Object> properties = new HashMap<String,Object>();
properties.put("name", "Test");
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addClassAnnotation("org.apache.openejb.test.TestBean4", Entity.class, properties);
Change change = facade.getChange();
@@ -151,7 +151,7 @@
Map<String,Object> properties = new HashMap<String,Object>();
properties.put("value", TransactionManagementType.BEAN);
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addClassAnnotation("org.apache.openejb.test.TestBean5", TransactionManagement.class, properties);
Change change = facade.getChange();
@@ -164,7 +164,7 @@
public void testShouldAddMethodAnnotationWithEnumProperty() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean6", getStreamContents(getClass().getResourceAsStream("Test6.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
facade.addMethodAnnotation("org.apache.openejb.test.TestBean6", "echoHelloWorld", new String[] {"java.lang.String"}, ManyToMany.class, null);
Change change = facade.getChange();
@@ -177,7 +177,7 @@
public void testShouldAddAnnotationWithClassAttributeWithStringPassedIn() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean7", getStreamContents(getClass().getResourceAsStream("Test7.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
Map<String, Object> properties = new HashMap<String,Object>();
properties.put("value", new String[] { "org.apache.openejb.test.Test7" });
facade.addClassAnnotation("org.apache.openejb.test.TestBean7", Remote.class, properties);
@@ -192,7 +192,7 @@
public void testShouldAddAnnotationWithNestedAttributes() throws Exception {
addNewClassToProject("org.apache.openejb.test.TestBean8", getStreamContents(getClass().getResourceAsStream("Test8.txt")));
- JavaProjectAnnotationFacade facade = new JavaProjectAnnotationFacade(fixture.getProject());
+ JDTFacade facade = new JDTFacade(fixture.getProject());
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> activationConfigProperty = new HashMap<String, Object>();
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/OpenEjbXmlConverterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/OpenEjbXmlConverterTest.java?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/OpenEjbXmlConverterTest.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/OpenEjbXmlConverterTest.java Fri Mar 21 04:25:51 2008
@@ -1,653 +0,0 @@
-/*
- * 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.helper.annotation.tests;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.security.DeclareRoles;
-import javax.annotation.security.DenyAll;
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.annotation.security.RunAs;
-import javax.ejb.MessageDriven;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.ejb.Stateful;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.interceptor.ExcludeClassInterceptors;
-import javax.interceptor.ExcludeDefaultInterceptors;
-import javax.interceptor.Interceptors;
-
-import junit.framework.TestCase;
-
-import org.apache.openejb.helper.annotation.IJavaProjectAnnotationFacade;
-import org.apache.openejb.helper.annotation.OpenEjbXmlConverter;
-import org.apache.openejb.jee.ActivationConfig;
-import org.apache.openejb.jee.AssemblyDescriptor;
-import org.apache.openejb.jee.ContainerTransaction;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.EnterpriseBean;
-import org.apache.openejb.jee.Interceptor;
-import org.apache.openejb.jee.InterceptorBinding;
-import org.apache.openejb.jee.MessageDrivenBean;
-import org.apache.openejb.jee.Method;
-import org.apache.openejb.jee.MethodParams;
-import org.apache.openejb.jee.MethodPermission;
-import org.apache.openejb.jee.NamedMethod;
-import org.apache.openejb.jee.RemoteBean;
-import org.apache.openejb.jee.SecurityIdentity;
-import org.apache.openejb.jee.SecurityRoleRef;
-import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.StatefulBean;
-import org.apache.openejb.jee.TransAttribute;
-import org.apache.openejb.jee.TransactionType;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.xml.sax.InputSource;
-
-
-/**
- * Test case to ensure that the xml converter calls the correct methods
- * on the annotation facade
- */
-public class OpenEjbXmlConverterTest extends TestCase {
-
- protected Mockery context = new Mockery();
-
- public void testShouldAddTwoStatelessAnnotationsToSampleBeans() throws Exception {
- // setup
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.Test1Bean", Stateless.class, null);
- one(facade).addClassAnnotation("test.Test2Bean", Stateless.class, null);
- one(facade).addClassAnnotation("test.Test1", Remote.class, null);
- one(facade).addClassAnnotation("test.Test1Bean", RemoteHome.class, createNameValuePair("value", "test.Test1Home"));
- one(facade).addClassAnnotation("test.Test2", Remote.class, null);
- one(facade).addClassAnnotation("test.Test2Bean", RemoteHome.class, createNameValuePair("value", "test.Test2Home"));
- }});
-
- // execute
- converter.convert(new InputSource(getClass().getResourceAsStream("sample-openejb-jar-two-statelessessionbeans.xml")));
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldAddTransactionManagementAttributes() throws Exception {
- // setup
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", TransactionManagement.class, createNameValuePair("value", TransactionManagementType.BEAN));
- one(facade).addClassAnnotation("test.TestBean", TransactionAttribute.class, createNameValuePair("value", TransactionAttributeType.MANDATORY));
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[] { "java.lang.String" }, TransactionAttribute.class, createNameValuePair("value", TransactionAttributeType.MANDATORY));
- }});
-
-
- EnterpriseBean enterpriseBean = new StatefulBean();
- enterpriseBean.setEjbName("TestBean");
- enterpriseBean.setEjbClass("test.TestBean");
- enterpriseBean.setTransactionType(TransactionType.BEAN);
-
- AssemblyDescriptor descriptor = new AssemblyDescriptor();
-
- addMethodTransactionToDescriptor(descriptor, "TestBean", "*", new String[0]);
- addMethodTransactionToDescriptor(descriptor, "TestBean", "test", new String[] { "java.lang.String" });
-
- // execute
- converter.processTransactionManagement(enterpriseBean, descriptor);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateMethodPermissionAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], RolesAllowed.class, createNameValuePair("value", new String[] { "Admin" }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, false, false);
-
- // execute
- converter.processMethodPermissions(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- private void addMethodToEjbJarDescriptor(EjbJar ejbJar, String beanName,
- String methodName, String[] rolesAllowed, boolean unchecked, boolean deny) {
- AssemblyDescriptor descriptor = ejbJar.getAssemblyDescriptor();
- List<MethodPermission> methodPermissions = descriptor.getMethodPermission();
- MethodPermission methodPermission = new MethodPermission();
- List<Method> methods = methodPermission.getMethod();
- methodPermission.getRoleName().addAll(Arrays.asList(rolesAllowed));
- methodPermission.setUnchecked(unchecked);
- methodPermissions.add(methodPermission);
- Method method = new Method();
- method.setEjbName(beanName);
- method.setMethodName(methodName);
- method.setMethodParams(new MethodParams());
- methods.add(method);
-
- if (deny) {
- descriptor.getExcludeList().addMethod(method);
- }
- }
-
- private EnterpriseBean addStatefulBeanToEjbJar(EjbJar ejbJar, String beanName,
- String beanClass) {
- EnterpriseBean enterpriseBean = new StatefulBean();
- enterpriseBean.setEjbName(beanName);
- enterpriseBean.setEjbClass(beanClass);
- ejbJar.addEnterpriseBean(enterpriseBean);
-
- return enterpriseBean;
- }
-
- public void testShouldAddRolesAllowedAnnotationToClass() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", RolesAllowed.class, createNameValuePair("value", new String[] { "Admin" }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- addMethodToEjbJarDescriptor(ejbJar, "TestBean", "*", new String[] { "Admin" }, false, false);
-
- // execute
- converter.processMethodPermissions(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldAddPermitAllToMethod() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], PermitAll.class, null);
- }});
-
- EjbJar ejbJar = new EjbJar();
- addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, true, false);
-
- // execute
- converter.processMethodPermissions(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldAddPermitAllToClass() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", PermitAll.class, null);
- }});
-
- EjbJar ejbJar = new EjbJar();
- addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- addMethodToEjbJarDescriptor(ejbJar, "TestBean", "*", new String[] { "Admin" }, true, false);
-
- // execute
- converter.processMethodPermissions(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldAddDenyAllToMethod() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], DenyAll.class, null);
- }});
-
- EjbJar ejbJar = new EjbJar();
- addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, true, true);
-
- // execute
- converter.processMethodPermissions(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateRunAsAnnotation() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", RunAs.class, createNameValuePair("value", "Administrator"));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- SecurityIdentity securityIdentity = new SecurityIdentity();
- securityIdentity.setRunAs("Administrator");
- bean.setSecurityIdentity(securityIdentity);
-
- // execute
- converter.processBeanSecurityIdentity(bean);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateDeclaredRolesAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", DeclareRoles.class, createNameValuePair("value", new String[] { "Admin" }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- RemoteBean remoteBean = (RemoteBean) bean;
- remoteBean.getSecurityRoleRef().add(new SecurityRoleRef("Admin"));
-
- // execute
- converter.processDeclaredRoles(bean);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateMethodInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- NamedMethod method = new NamedMethod();
- method.setMethodName("test");
- method.setMethodParams(new MethodParams());
- binding.setMethod(method);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateExcludeDefaultInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- one(facade).addClassAnnotation("test.TestBean", ExcludeDefaultInterceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- binding.setExcludeDefaultInterceptors(true);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateDefaultExcludeMethodInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], ExcludeDefaultInterceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- binding.setExcludeDefaultInterceptors(true);
- NamedMethod method = new NamedMethod();
- method.setMethodName("test");
- method.setMethodParams(new MethodParams());
- binding.setMethod(method);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateExcludeClassInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- one(facade).addClassAnnotation("test.TestBean", ExcludeClassInterceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- binding.setExcludeClassInterceptors(true);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateClassExcludeMethodInterceptorAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], ExcludeClassInterceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { OpenEjbXmlConverterTest.class.getCanonicalName() }));
- }});
-
- EjbJar ejbJar = new EjbJar();
- EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
-
- Interceptor interceptor = new Interceptor(OpenEjbXmlConverterTest.class);
- ejbJar.addInterceptor(interceptor);
- List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
-
- InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
- binding.setExcludeClassInterceptors(true);
- NamedMethod method = new NamedMethod();
- method.setMethodName("test");
- method.setMethodParams(new MethodParams());
- binding.setMethod(method);
- interceptorBindings.add(binding);
-
- // execute
- converter.processInterceptors(ejbJar);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldGenerateRemoteAnnotations() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.TestBean", Stateful.class, null);
- one(facade).addClassAnnotation("test.TestBean", RemoteHome.class, createNameValuePair("value", "test.TestHome"));
- one(facade).addClassAnnotation("test.Test", Remote.class, null);
- }});
-
- EjbJar ejbJar = new EjbJar();
- StatefulBean bean = (StatefulBean) addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
- bean.setHome("test.TestHome");
- bean.setRemote("test.Test");
-
- // execute
- converter.processSessionBean((SessionBean) bean);
-
- // verify
- context.assertIsSatisfied();
- }
-
- public void testShouldProcessMessageDrivenBean() throws Exception {
- // setup
-
- final IJavaProjectAnnotationFacade facade = context.mock(IJavaProjectAnnotationFacade.class);
- OpenEjbXmlConverter converter = new OpenEjbXmlConverter(facade);
-
- final Map<String,Object> expectedMap = new HashMap<String, Object>();
- expectedMap.put("destination", "TestQueue");
- expectedMap.put("destinationType", "javax.jms.Queue");
-
- // expectations
- context.checking(new Expectations(){{
- one(facade).addClassAnnotation("test.MessageDrivenBean1", MessageDriven.class, createActivationConfig(expectedMap, "Test"));
- }
-
- private Map<String, Object> createActivationConfig(Map<String,Object> inMap, String name) {
- List<Map<String, Object>> configProperties = new ArrayList<Map<String, Object>>();
-
- Iterator<String> iterator = inMap.keySet().iterator();
- while (iterator.hasNext()) {
- String propertyName = (String) iterator.next();
- String propertyValue = inMap.get(propertyName).toString();
-
- Map<String, Object> activationConfigProperty = createNameValuePair("propertyName", propertyName);
- activationConfigProperty.put("propertyValue", propertyValue);
- configProperties.add(activationConfigProperty);
- }
-
- Map<String, Object> props = createNameValuePair("activationConfig", configProperties.toArray(new Object[0]));
- props.put("name", name);
- return props;
- }});
-
- EjbJar ejbJar = new EjbJar();
- MessageDrivenBean bean = new MessageDrivenBean();
- bean.setEjbName("Test");
- bean.setEjbClass("test.MessageDrivenBean1");
-
- bean.setActivationConfig(new ActivationConfig());
- bean.getActivationConfig().addProperty("destinationType", "javax.jms.Queue");
- bean.setMessageDestinationType("javax.jms.Queue");
- bean.setMessageDestinationLink("TestQueue");
-
- ejbJar.addEnterpriseBean(bean);
-
-
- // execute
- converter.processMessageDrivenBean(bean);
-
- // verify
- context.assertIsSatisfied();
- }
-
- private void addMethodTransactionToDescriptor(AssemblyDescriptor descriptor, String ejbName, String methodName, String[] params) {
- List<ContainerTransaction> containerTransactions = descriptor.getContainerTransaction();
- ContainerTransaction containerTransaction = new ContainerTransaction();
-
- containerTransaction.getMethod().add(createMethod(ejbName, methodName, params));
- containerTransaction.setTransAttribute(TransAttribute.MANDATORY);
- containerTransactions.add(containerTransaction);
- }
-
- private Method createMethod(String ejbName, String methodName, String[] params) {
- Method method = new Method(ejbName, methodName);
- MethodParams methodParams = new MethodParams();
-
- for (int i = 0; i < params.length; i++) {
- methodParams.getMethodParam().add(params[i]);
- }
-
- method.setMethodParams(methodParams);
- return method;
- }
-
- private Map<String, Object> createNameValuePair(String key,
- Object value) {
-
- Map<String, Object> result = new HashMap<String, Object>() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean equals(Object otherObj) {
-
- if (!( otherObj instanceof Map)) {
- return false;
- }
-
- if (otherObj == null) {
- return false;
- }
-
- Map<?,?> otherMap = (Map<?,?>) otherObj;
-
- Iterator<String> iterator = this.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- Object value = this.get(key);
-
- if (value.getClass().isArray()) {
- if (! Arrays.deepEquals((Object[])value, (Object[])otherMap.get(key))) {
- return false;
- }
- } else {
- if (! value.equals(otherMap.get(key))) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- };
-
- result.put(key, value);
- return result;
- }
-}
Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java?rev=639599&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java Fri Mar 21 04:25:51 2008
@@ -0,0 +1,630 @@
+/*
+ * 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.helper.annotation.tests;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.annotation.security.RunAs;
+import javax.ejb.MessageDriven;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+
+import junit.framework.TestCase;
+
+import org.apache.openejb.helper.annotation.Converter;
+import org.apache.openejb.helper.annotation.IJDTFacade;
+import org.apache.openejb.helper.annotation.OpenEjbXmlConverter;
+import org.apache.openejb.helper.annotation.SessionBeanConverter;
+import org.apache.openejb.jee.ActivationConfig;
+import org.apache.openejb.jee.AssemblyDescriptor;
+import org.apache.openejb.jee.ContainerTransaction;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.Interceptor;
+import org.apache.openejb.jee.InterceptorBinding;
+import org.apache.openejb.jee.MessageDrivenBean;
+import org.apache.openejb.jee.Method;
+import org.apache.openejb.jee.MethodParams;
+import org.apache.openejb.jee.MethodPermission;
+import org.apache.openejb.jee.NamedMethod;
+import org.apache.openejb.jee.RemoteBean;
+import org.apache.openejb.jee.SecurityIdentity;
+import org.apache.openejb.jee.SecurityRoleRef;
+import org.apache.openejb.jee.SessionBean;
+import org.apache.openejb.jee.StatefulBean;
+import org.apache.openejb.jee.TransAttribute;
+import org.apache.openejb.jee.TransactionType;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.xml.sax.InputSource;
+
+
+/**
+ * Test case to ensure that the xml converter calls the correct methods
+ * on the annotation facade
+ */
+public class SessionBeanConverterTest extends TestCase {
+
+ protected Mockery context = new Mockery();
+
+ public void testShouldAddTwoStatelessAnnotationsToSampleBeans() throws Exception {
+ // setup
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ Converter[] converters = {
+ new SessionBeanConverter(facade)
+ };
+
+ OpenEjbXmlConverter converter = new OpenEjbXmlConverter(converters);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.Test1Bean", Stateless.class, null);
+ one(facade).addClassAnnotation("test.Test2Bean", Stateless.class, null);
+ }});
+
+ // execute
+ converter.convert(new InputSource(getClass().getResourceAsStream("sample-openejb-jar-two-statelessessionbeans.xml")));
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldAddTransactionManagementAttributes() throws Exception {
+ // setup
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", TransactionManagement.class, createNameValuePair("value", TransactionManagementType.BEAN));
+ one(facade).addClassAnnotation("test.TestBean", TransactionAttribute.class, createNameValuePair("value", TransactionAttributeType.MANDATORY));
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[] { "java.lang.String" }, TransactionAttribute.class, createNameValuePair("value", TransactionAttributeType.MANDATORY));
+ }});
+
+
+ EnterpriseBean enterpriseBean = new StatefulBean();
+ enterpriseBean.setEjbName("TestBean");
+ enterpriseBean.setEjbClass("test.TestBean");
+ enterpriseBean.setTransactionType(TransactionType.BEAN);
+
+ AssemblyDescriptor descriptor = new AssemblyDescriptor();
+
+ addMethodTransactionToDescriptor(descriptor, "TestBean", "*", new String[0]);
+ addMethodTransactionToDescriptor(descriptor, "TestBean", "test", new String[] { "java.lang.String" });
+
+ // execute
+ converter.processTransactionManagement(enterpriseBean, descriptor);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateMethodPermissionAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], RolesAllowed.class, createNameValuePair("value", new String[] { "Admin" }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, false, false);
+
+ // execute
+ converter.processMethodPermissions(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ private void addMethodToEjbJarDescriptor(EjbJar ejbJar, String beanName,
+ String methodName, String[] rolesAllowed, boolean unchecked, boolean deny) {
+ AssemblyDescriptor descriptor = ejbJar.getAssemblyDescriptor();
+ List<MethodPermission> methodPermissions = descriptor.getMethodPermission();
+ MethodPermission methodPermission = new MethodPermission();
+ List<Method> methods = methodPermission.getMethod();
+ methodPermission.getRoleName().addAll(Arrays.asList(rolesAllowed));
+ methodPermission.setUnchecked(unchecked);
+ methodPermissions.add(methodPermission);
+ Method method = new Method();
+ method.setEjbName(beanName);
+ method.setMethodName(methodName);
+ method.setMethodParams(new MethodParams());
+ methods.add(method);
+
+ if (deny) {
+ descriptor.getExcludeList().addMethod(method);
+ }
+ }
+
+ private EnterpriseBean addStatefulBeanToEjbJar(EjbJar ejbJar, String beanName,
+ String beanClass) {
+ EnterpriseBean enterpriseBean = new StatefulBean();
+ enterpriseBean.setEjbName(beanName);
+ enterpriseBean.setEjbClass(beanClass);
+ ejbJar.addEnterpriseBean(enterpriseBean);
+
+ return enterpriseBean;
+ }
+
+ public void testShouldAddRolesAllowedAnnotationToClass() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", RolesAllowed.class, createNameValuePair("value", new String[] { "Admin" }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ addMethodToEjbJarDescriptor(ejbJar, "TestBean", "*", new String[] { "Admin" }, false, false);
+
+ // execute
+ converter.processMethodPermissions(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldAddPermitAllToMethod() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], PermitAll.class, null);
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, true, false);
+
+ // execute
+ converter.processMethodPermissions(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldAddPermitAllToClass() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", PermitAll.class, null);
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ addMethodToEjbJarDescriptor(ejbJar, "TestBean", "*", new String[] { "Admin" }, true, false);
+
+ // execute
+ converter.processMethodPermissions(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldAddDenyAllToMethod() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], DenyAll.class, null);
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ addMethodToEjbJarDescriptor(ejbJar, "TestBean", "test", new String[] { "Admin" }, true, true);
+
+ // execute
+ converter.processMethodPermissions(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateRunAsAnnotation() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", RunAs.class, createNameValuePair("value", "Administrator"));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ SecurityIdentity securityIdentity = new SecurityIdentity();
+ securityIdentity.setRunAs("Administrator");
+ bean.setSecurityIdentity(securityIdentity);
+
+ // execute
+ converter.processBeanSecurityIdentity(bean);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateDeclaredRolesAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", DeclareRoles.class, createNameValuePair("value", new String[] { "Admin" }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ RemoteBean remoteBean = (RemoteBean) bean;
+ remoteBean.getSecurityRoleRef().add(new SecurityRoleRef("Admin"));
+
+ // execute
+ converter.processDeclaredRoles(bean);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateMethodInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ NamedMethod method = new NamedMethod();
+ method.setMethodName("test");
+ method.setMethodParams(new MethodParams());
+ binding.setMethod(method);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateExcludeDefaultInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ one(facade).addClassAnnotation("test.TestBean", ExcludeDefaultInterceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ binding.setExcludeDefaultInterceptors(true);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateDefaultExcludeMethodInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], ExcludeDefaultInterceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ binding.setExcludeDefaultInterceptors(true);
+ NamedMethod method = new NamedMethod();
+ method.setMethodName("test");
+ method.setMethodParams(new MethodParams());
+ binding.setMethod(method);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateExcludeClassInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ one(facade).addClassAnnotation("test.TestBean", ExcludeClassInterceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ binding.setExcludeClassInterceptors(true);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateClassExcludeMethodInterceptorAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], ExcludeClassInterceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ one(facade).addMethodAnnotation("test.TestBean", "test", new String[0], Interceptors.class, createNameValuePair("value", new String[] { SessionBeanConverterTest.class.getCanonicalName() }));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ EnterpriseBean bean = addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+
+ Interceptor interceptor = new Interceptor(SessionBeanConverterTest.class);
+ ejbJar.addInterceptor(interceptor);
+ List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
+
+ InterceptorBinding binding = new InterceptorBinding(bean, interceptor);
+ binding.setExcludeClassInterceptors(true);
+ NamedMethod method = new NamedMethod();
+ method.setMethodName("test");
+ method.setMethodParams(new MethodParams());
+ binding.setMethod(method);
+ interceptorBindings.add(binding);
+
+ // execute
+ converter.processInterceptors(ejbJar);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldGenerateRemoteAnnotations() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.TestBean", Stateful.class, null);
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ StatefulBean bean = (StatefulBean) addStatefulBeanToEjbJar(ejbJar, "TestBean", "test.TestBean");
+ bean.setHome("test.TestHome");
+ bean.setRemote("test.Test");
+
+ // execute
+ converter.processSessionBean((SessionBean) bean);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ public void testShouldProcessMessageDrivenBean() throws Exception {
+ // setup
+
+ final IJDTFacade facade = context.mock(IJDTFacade.class);
+ SessionBeanConverter converter = new SessionBeanConverter(facade);
+
+ final Map<String,Object> expectedMap = new HashMap<String, Object>();
+ expectedMap.put("destination", "TestQueue");
+ expectedMap.put("destinationType", "javax.jms.Queue");
+
+ // expectations
+ context.checking(new Expectations(){{
+ one(facade).addClassAnnotation("test.MessageDrivenBean1", MessageDriven.class, createNameValuePair("name", "Test"));
+ }});
+
+ EjbJar ejbJar = new EjbJar();
+ MessageDrivenBean bean = new MessageDrivenBean();
+ bean.setEjbName("Test");
+ bean.setEjbClass("test.MessageDrivenBean1");
+
+ ejbJar.addEnterpriseBean(bean);
+
+
+ // execute
+ converter.processMessageDrivenBean(bean);
+
+ // verify
+ context.assertIsSatisfied();
+ }
+
+ private void addMethodTransactionToDescriptor(AssemblyDescriptor descriptor, String ejbName, String methodName, String[] params) {
+ List<ContainerTransaction> containerTransactions = descriptor.getContainerTransaction();
+ ContainerTransaction containerTransaction = new ContainerTransaction();
+
+ containerTransaction.getMethod().add(createMethod(ejbName, methodName, params));
+ containerTransaction.setTransAttribute(TransAttribute.MANDATORY);
+ containerTransactions.add(containerTransaction);
+ }
+
+ private Method createMethod(String ejbName, String methodName, String[] params) {
+ Method method = new Method(ejbName, methodName);
+ MethodParams methodParams = new MethodParams();
+
+ for (int i = 0; i < params.length; i++) {
+ methodParams.getMethodParam().add(params[i]);
+ }
+
+ method.setMethodParams(methodParams);
+ return method;
+ }
+
+ private Map<String, Object> createNameValuePair(String key,
+ Object value) {
+
+ Map<String, Object> result = new HashMap<String, Object>() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean equals(Object otherObj) {
+
+ if (!( otherObj instanceof Map)) {
+ return false;
+ }
+
+ if (otherObj == null) {
+ return false;
+ }
+
+ Map<?,?> otherMap = (Map<?,?>) otherObj;
+
+ Iterator<String> iterator = this.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ Object value = this.get(key);
+
+ if (value.getClass().isArray()) {
+ if (! Arrays.deepEquals((Object[])value, (Object[])otherMap.get(key))) {
+ return false;
+ }
+ } else {
+ if (! value.equals(otherMap.get(key))) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ };
+
+ result.put(key, value);
+ return result;
+ }
+}
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation.test/src/main/java/org/apache/openejb/helper/annotation/tests/SessionBeanConverterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/META-INF/MANIFEST.MF?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/META-INF/MANIFEST.MF (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/META-INF/MANIFEST.MF Fri Mar 21 04:25:51 2008
@@ -15,7 +15,9 @@
org.eclipse.ui.ide,
org.eclipse.ltk.ui.refactoring,
org.eclipse.ltk.core.refactoring,
- org.junit
+ org.junit,
+ org.eclipse.jdt.ui,
+ org.eclipse.search
Eclipse-LazyStart: true
Bundle-ClassPath: .,
lib/jaxb-impl-2.0.3.jar,
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/maven-eclipse.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/maven-eclipse.xml?rev=639599&r1=639598&r2=639599&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/maven-eclipse.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/maven-eclipse.xml Fri Mar 21 04:25:51 2008
@@ -1,11 +0,0 @@
-<project default="copy-resources">
- <target name="init"/>
- <target name="copy-resources" depends="init">
- <copy todir="target/classes/META-INF" filtering="false">
- <fileset dir="META-INF" includes="MANIFEST.MF"/>
- </copy>
- <copy todir="target/classes/lib" filtering="false">
- <fileset dir="lib" includes="*.jar"/>
- </copy>
- </target>
-</project>
\ No newline at end of file
Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java?rev=639599&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java Fri Mar 21 04:25:51 2008
@@ -0,0 +1,23 @@
+/*
+ * 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.helper.annotation;
+
+import org.apache.openejb.config.AppModule;
+
+public interface Converter {
+ public void convert(AppModule module);
+}
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/Converter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java?rev=639599&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java Fri Mar 21 04:25:51 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.helper.annotation;
+
+import java.util.List;
+
+import javax.ejb.EJB;
+
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.helper.annotation.Converter;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.SessionBean;
+
+public class EjbReferencesConverter implements Converter {
+
+ private IJDTFacade facade;
+
+ public EjbReferencesConverter(IJDTFacade facade) {
+ super();
+ this.facade = facade;
+ }
+
+ public void convert(AppModule module) {
+ List<EjbModule> ejbModules = module.getEjbModules();
+ for (EjbModule ejbModule : ejbModules) {
+ EjbJar ejbJar = ejbModule.getEjbJar();
+
+ EnterpriseBean[] enterpriseBeans = ejbJar.getEnterpriseBeans();
+ for (EnterpriseBean enterpriseBean : enterpriseBeans) {
+ if (! (enterpriseBean instanceof SessionBean)) {
+ continue;
+ }
+
+ SessionBean sessionBean = (SessionBean) enterpriseBean;
+ String remoteClass = sessionBean.getRemote();
+ String localClass = sessionBean.getLocal();
+
+ if (remoteClass != null && remoteClass.length() > 0) {
+ facade.addAnnotationToFieldsOfType(remoteClass, EJB.class, null);
+ }
+
+ if (localClass != null && localClass.length() > 0) {
+ facade.addAnnotationToFieldsOfType(localClass, EJB.class, null);
+ }
+ }
+ }
+ }
+
+
+}
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/EjbReferencesConverter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain