You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/12/19 22:10:54 UTC
[10/30] tomee git commit: TOMEE-2295 add arquillian test using custom
ORM file
TOMEE-2295 add arquillian test using custom ORM file
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/35140a28
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/35140a28
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/35140a28
Branch: refs/heads/tomee-7.1.x
Commit: 35140a28148b6c43e2f9003260b086807033087d
Parents: 8a43a55
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Thu Nov 29 21:43:40 2018 +0000
Committer: Otavio Santana <ot...@gmail.com>
Committed: Mon Dec 17 13:56:46 2018 -0200
----------------------------------------------------------------------
.../tests/cmp/sample/CustomOrmXmlTest.java | 65 +++++++++++
.../arquillian/tests/cmp/sample/Movie.java | 39 +++++++
.../arquillian/tests/cmp/sample/MovieBean.java | 49 ++++++++
.../tests/cmp/sample/MovieException.java | 35 ++++++
.../tests/cmp/sample/MovieLocalHome.java | 35 ++++++
.../tests/cmp/sample/MovieServlet.java | 79 +++++++++++++
.../arquillian/tests/cmp/sample/MovieVO.java | 79 +++++++++++++
.../tests/cmp/sample/MoviesBusinessBean.java | 115 +++++++++++++++++++
.../tests/cmp/sample/MoviesBusinessLocal.java | 28 +++++
.../cmp/sample/MoviesBusinessLocalHome.java | 26 +++++
.../arquillian/tests/cmp/sample/custom-orm.xml | 23 ++++
.../arquillian/tests/cmp/sample/ejb-jar.xml | 103 +++++++++++++++++
.../arquillian/tests/cmp/sample/openejb-jar.xml | 11 ++
.../arquillian/tests/cmp/sample/persistence.xml | 14 +++
.../openejb/arquillian/tests/cmp/sample/web.xml | 42 +++++++
15 files changed, 743 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java
new file mode 100644
index 0000000..e069536
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/CustomOrmXmlTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.arquillian.tests.cmp.sample;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(Arquillian.class)
+public class CustomOrmXmlTest {
+
+ @ArquillianResource
+ private URL url;
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ WebArchive archive = ShrinkWrap.create(WebArchive.class, CustomOrmXmlTest.class.getSimpleName() + ".war")
+ .addClasses(MovieServlet.class, Movie.class, MovieBean.class, MovieException.class, MovieLocalHome.class, MoviesBusinessBean.class, MoviesBusinessLocal.class, MoviesBusinessLocalHome.class, MovieVO.class)
+ .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml"), "META-INF/custom-orm.xml")
+ .addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml"), "META-INF/persistence.xml")
+ .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml"), "openejb-jar.xml")
+ .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml"), "ejb-jar.xml")
+ .addAsWebInfResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/cmp/sample/web.xml"), "web.xml");
+
+ System.out.println(archive.toString(true));
+ return archive;
+ }
+
+ @Test
+ @RunAsClient
+ public void checkCmpJpaEntityORMMappings() throws Exception {
+ final String output = IO.slurp(new URL(url.toExternalForm()));
+ System.out.println(output);
+ Assert.assertTrue(output.contains("Movie added successfully"));
+ Assert.assertTrue(output.contains("Movie removed successfully"));
+ Assert.assertTrue(output.contains("title='Bad Boys', director='Michael Bay', year=1995"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java
new file mode 100644
index 0000000..405280c
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/Movie.java
@@ -0,0 +1,39 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface Movie extends javax.ejb.EJBLocalObject {
+
+ java.lang.Integer getId();
+
+ void setId(java.lang.Integer id);
+
+ String getDirector();
+
+ void setDirector(String director);
+
+ String getTitle();
+
+ void setTitle(String title);
+
+ int getYear();
+
+ void setYear(int year);
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java
new file mode 100644
index 0000000..6f83ef8
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieBean.java
@@ -0,0 +1,49 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import javax.ejb.EntityBean;
+
+public abstract class MovieBean implements EntityBean {
+
+ public MovieBean() {
+ }
+
+ public Integer ejbCreate(final String director, String title, final int year) {
+ this.setDirector(director);
+ this.setTitle(title);
+ this.setYear(year);
+ return null;
+ }
+
+ public abstract java.lang.Integer getId();
+
+ public abstract void setId(java.lang.Integer id);
+
+ public abstract String getDirector();
+
+ public abstract void setDirector(String director);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String title);
+
+ public abstract int getYear();
+
+ public abstract void setYear(int year);
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java
new file mode 100644
index 0000000..cdf476c
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieException.java
@@ -0,0 +1,35 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+public class MovieException extends Exception {
+
+ public MovieException() {
+ }
+
+ public MovieException(String message) {
+ super(message);
+ }
+
+ public MovieException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MovieException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java
new file mode 100644
index 0000000..dfcf910
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieLocalHome.java
@@ -0,0 +1,35 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import javax.ejb.CreateException;
+import javax.ejb.FinderException;
+import java.util.Collection;
+
+/**
+ * @version $Revision$ $Date$
+ */
+interface MovieLocalHome extends javax.ejb.EJBLocalHome {
+
+ Movie create(String director, String title, int year) throws CreateException;
+
+ Movie findByPrimaryKey(Integer primarykey) throws FinderException;
+
+ Collection<Movie> findAll() throws FinderException;
+
+ Collection<Movie> findByDirector(String director) throws FinderException;
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java
new file mode 100644
index 0000000..0670ee5
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieServlet.java
@@ -0,0 +1,79 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import javax.ejb.CreateException;
+import javax.ejb.RemoveException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class MovieServlet extends HttpServlet {
+
+
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ process(req, resp);
+ }
+
+ @Override
+ protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ process(req, resp);
+ }
+
+ private void process(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+
+ final PrintWriter pw = resp.getWriter();
+
+ try {
+ final InitialContext context = new InitialContext();
+ final MoviesBusinessLocalHome home = (MoviesBusinessLocalHome)
+ PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MoviesBusiness"), MoviesBusinessLocalHome.class);
+
+ final MoviesBusinessLocal bean = home.create();
+
+ bean.addMovie("Bad Boys", "Michael Bay", 1995);
+
+ pw.println("Movie added successfully");
+
+ final Collection allMovies = bean.findAll();
+
+ final Iterator iterator = allMovies.iterator();
+ while (iterator.hasNext()) {
+ final MovieVO movie = (MovieVO) iterator.next();
+ pw.println(movie.toString());
+
+ bean.delete(movie.getId());
+ pw.println("Movie removed successfully");
+ }
+
+ bean.remove();
+ pw.flush();
+
+ } catch (NamingException | CreateException | RemoveException | MovieException e) {
+ throw new ServletException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java
new file mode 100644
index 0000000..ee59bf6
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MovieVO.java
@@ -0,0 +1,79 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import java.io.Serializable;
+
+public class MovieVO implements Serializable {
+
+ private Integer id;
+ private String title;
+ private String director;
+ private int year;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public static MovieVO from (final Movie movie) {
+ final MovieVO movieVO = new MovieVO();
+ movieVO.setId(movie.getId());
+ movieVO.setTitle(movie.getTitle());
+ movieVO.setDirector(movie.getDirector());
+ movieVO.setYear(movie.getYear());
+
+ return movieVO;
+ }
+
+ @Override
+ public String toString() {
+ return "MovieVO{" +
+ "id=" + id +
+ ", title='" + title + '\'' +
+ ", director='" + director + '\'' +
+ ", year=" + year +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java
new file mode 100644
index 0000000..b431826
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessBean.java
@@ -0,0 +1,115 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class MoviesBusinessBean implements SessionBean {
+
+ private SessionContext ctx;
+
+ @Override
+ public void ejbActivate() throws EJBException, RemoteException {
+ }
+
+ @Override
+ public void ejbPassivate() throws EJBException, RemoteException {
+ }
+
+ @Override
+ public void ejbRemove() throws EJBException, RemoteException {
+ }
+
+ @Override
+ public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException {
+
+ this.ctx = ctx;
+ }
+
+
+ public void addMovie(final String title, final String director, int year) throws MovieException {
+ try {
+ final InitialContext context = new InitialContext();
+ final MovieLocalHome home = (MovieLocalHome)
+ PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class);
+
+
+ home.create(director, title, year);
+
+ } catch (NamingException | CreateException e) {
+ throw new MovieException(e);
+ }
+ }
+
+ public MovieVO findByPrimaryKey(final int id) throws MovieException {
+ try {
+ final InitialContext context = new InitialContext();
+ final MovieLocalHome home = (MovieLocalHome)
+ PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class);
+
+
+ return MovieVO.from(home.findByPrimaryKey(id));
+ } catch (NamingException | FinderException e) {
+ throw new MovieException(e);
+ }
+ }
+
+ public Collection findAll() throws MovieException {
+ try {
+ final InitialContext context = new InitialContext();
+ final MovieLocalHome home = (MovieLocalHome)
+ PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class);
+
+ final Collection movies = home.findAll();
+
+ final Collection result = new ArrayList();
+ final Iterator iterator = movies.iterator();
+ while (iterator.hasNext()) {
+ Movie movie = (Movie) iterator.next();
+ result.add(MovieVO.from(movie));
+ }
+
+ return result;
+ } catch (NamingException | FinderException e) {
+ throw new MovieException(e);
+ }
+ }
+
+ public void delete(Integer id) throws MovieException {
+ try {
+ final InitialContext context = new InitialContext();
+ final MovieLocalHome home = (MovieLocalHome)
+ PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/MovieBean"), MovieLocalHome.class);
+
+ home.remove(id);
+ } catch (NamingException | RemoveException e) {
+ throw new MovieException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java
new file mode 100644
index 0000000..f961fc3
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocal.java
@@ -0,0 +1,28 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+public interface MoviesBusinessLocal extends javax.ejb.EJBLocalObject {
+
+ void addMovie(final String title, final String director, int year) throws RemoteException, MovieException;
+ Movie findByPrimaryKey(final int id) throws RemoteException, MovieException;
+ Collection findAll() throws RemoteException, MovieException;
+ void delete(Integer id) throws RemoteException, MovieException;
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java
new file mode 100644
index 0000000..a7181b9
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/cmp/sample/MoviesBusinessLocalHome.java
@@ -0,0 +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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.arquillian.tests.cmp.sample;
+
+import javax.ejb.CreateException;
+import java.rmi.RemoteException;
+
+public interface MoviesBusinessLocalHome extends javax.ejb.EJBLocalHome {
+
+ MoviesBusinessLocal create() throws RemoteException, CreateException;
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml
new file mode 100644
index 0000000..2e60735
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/custom-orm.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
+ <entity class="openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean" name="MovieBean">
+ <description>#MovieBean</description>
+ <table/>
+ <named-query name="MovieBean.findByDirector(java.lang.String)">
+ <query>SELECT m FROM MovieBean m WHERE m.director = ?1</query>
+ </named-query>
+ <named-query name="MovieBean.findAll">
+ <query>SELECT m FROM MovieBean as m</query>
+ </named-query>
+ <attributes>
+ <id name="id">
+ <generated-value strategy="IDENTITY"/>
+ </id>
+ <basic name="director"/>
+ <basic name="year"/>
+ <basic name="title">
+ <column name="movie_title" length="250" />
+ </basic>
+ </attributes>
+ </entity>
+</entity-mappings>
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml
new file mode 100644
index 0000000..3de83ad
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/ejb-jar.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="3.1"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
+
+ <enterprise-beans>
+ <session>
+ <description>
+ A service that handles monetary payments.
+ </description>
+ <ejb-name>MovieBusinessBean</ejb-name>
+ <local-home>org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome</local-home>
+ <local>org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal</local>
+ <ejb-class>org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>ejb/MovieBean</ejb-ref-name>
+ <ejb-ref-type>Entity</ejb-ref-type>
+ <local-home>org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome</local-home>
+ <local>org.apache.openejb.arquillian.tests.cmp.sample.Movie</local>
+ <ejb-link>MovieBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <local-home>org.apache.openejb.arquillian.tests.cmp.sample.MovieLocalHome</local-home>
+ <local>org.apache.openejb.arquillian.tests.cmp.sample.Movie</local>
+ <ejb-class>org.apache.openejb.arquillian.tests.cmp.sample.MovieBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>MovieBean</abstract-schema-name>
+ <cmp-field>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>director</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>year</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>title</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ <query>
+ <query-method>
+ <method-name>findByDirector</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean m WHERE m.director = ?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean as m</ejb-ql>
+ </query>
+ </entity>
+ </enterprise-beans>
+
+
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>MovieBusinessBean</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+
+ <container-transaction>
+ <method>
+ <ejb-name>MovieBean</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Supports</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml
new file mode 100644
index 0000000..f86990c
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/openejb-jar.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <key-generator xmlns="http://www.openejb.org/xml/ns/pkgen-2.1">
+ <uuid/>
+ </key-generator>
+ </entity>
+ </enterprise-beans>
+</openejb-jar>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml
new file mode 100644
index 0000000..97f2cc1
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/persistence.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="cmp" transaction-type="JTA">
+ <jta-data-source>Default JDBC Database</jta-data-source>
+ <non-jta-data-source>Default Unmanaged JDBC Database</non-jta-data-source>
+ <mapping-file>META-INF/custom-orm.xml</mapping-file>
+ <class>openejb.org.apache.openejb.arquillian.tests.cmp.sample.MovieBean</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true, Indexes=false, IgnoreErrors=true)"/>
+ <property name="openjpa.Log" value="DefaultLevel=INFO"/>
+ <property name="eclipselink.ddl-generation" value="create-tables"/>
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/tomee/blob/35140a28/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml
new file mode 100644
index 0000000..6d55e75
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/org/apache/openejb/arquillian/tests/cmp/sample/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+
+ <servlet>
+ <servlet-name>MovieServlet</servlet-name>
+ <servlet-class>org.apache.openejb.arquillian.tests.cmp.sample.MovieServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>MovieServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <ejb-local-ref>
+ <ejb-ref-name>ejb/MoviesBusiness</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local-home>org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocalHome</local-home>
+ <local>org.apache.openejb.arquillian.tests.cmp.sample.MoviesBusinessLocal</local>
+ </ejb-local-ref>
+</web-app>
\ No newline at end of file