http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckMissingClassTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckMissingClassTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckMissingClassTest.java index f591370..5393bb9 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckMissingClassTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckMissingClassTest.java @@ -1,184 +1,184 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.EntityBean; -import org.apache.openejb.jee.PersistenceType; -import org.apache.openejb.jee.StatefulBean; -import org.apache.openejb.jee.StatelessBean; -import org.junit.runner.RunWith; - -import javax.ejb.EJBException; -import javax.ejb.EntityContext; -import javax.ejb.RemoveException; -import javax.ejb.SessionBean; -import javax.ejb.SessionContext; -import java.rmi.RemoteException; - -@RunWith(ValidationRunner.class) -public class CheckMissingClassTest { - @Keys(@Key(value = "missing.class", count = 16)) - public EjbJar wrongClassType() throws OpenEJBException { - System.setProperty("openejb.validation.output.level", "VERBOSE"); - final EjbJar ejbJar = new EjbJar(); - final StatelessBean stateless = new StatelessBean(FooStateless.class); - stateless.setHomeAndRemote("WrongHome", "WrongRemote"); - stateless.setLocal("WrongLocal"); - stateless.setLocalHome("WrongLocalHome"); - ejbJar.addEnterpriseBean(stateless); - final StatefulBean stateful = new StatefulBean(FooStateful.class); - stateful.setHomeAndRemote("WrongHome", "WrongRemote"); - stateful.setLocal("WrongLocal"); - stateful.setLocalHome("WrongLocalHome"); - ejbJar.addEnterpriseBean(stateful); - final EntityBean bmpEntityBean = new EntityBean(FooEntityBMP.class, PersistenceType.BEAN); - bmpEntityBean.setHome("WrongHome"); - bmpEntityBean.setLocalHome("WrongLocalHome"); - bmpEntityBean.setRemote("WrongRemote"); - bmpEntityBean.setLocal("WrongLocal"); - ejbJar.addEnterpriseBean(bmpEntityBean); - final EntityBean cmpEntityBean = new EntityBean(FooEntityCMP.class, PersistenceType.CONTAINER); - cmpEntityBean.setHome("WrongHome"); - cmpEntityBean.setLocalHome("WrongLocalHome"); - cmpEntityBean.setRemote("WrongRemote"); - cmpEntityBean.setLocal("WrongLocal"); - ejbJar.addEnterpriseBean(cmpEntityBean); - return ejbJar; - } - - private static class FooStateless implements SessionBean { - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static class FooStateful implements SessionBean { - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static class FooEntityBMP implements javax.ejb.EntityBean { - public String ejbCreate(final String id) { - return null; - } - - public void ejbPostCreate(final String id) { - } - - ; - - @Override - public void ejbActivate() throws EJBException, RemoteException { - } - - @Override - public void ejbLoad() throws EJBException, RemoteException { - } - - @Override - public void ejbPassivate() throws EJBException, RemoteException { - } - - @Override - public void ejbRemove() throws RemoveException, EJBException, RemoteException { - } - - @Override - public void ejbStore() throws EJBException, RemoteException { - } - - @Override - public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { - } - - @Override - public void unsetEntityContext() throws EJBException, RemoteException { - } - } - - private static class FooEntityCMP implements javax.ejb.EntityBean { - public String ejbCreate(final String id) { - return null; - } - - public void ejbPostCreate(final String id) { - } - - ; - - @Override - public void ejbActivate() throws EJBException, RemoteException { - } - - @Override - public void ejbLoad() throws EJBException, RemoteException { - } - - @Override - public void ejbPassivate() throws EJBException, RemoteException { - } - - @Override - public void ejbRemove() throws RemoveException, EJBException, RemoteException { - } - - @Override - public void ejbStore() throws EJBException, RemoteException { - } - - @Override - public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { - } - - @Override - public void unsetEntityContext() throws EJBException, RemoteException { - } - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.EntityBean; +import org.apache.openejb.jee.PersistenceType; +import org.apache.openejb.jee.StatefulBean; +import org.apache.openejb.jee.StatelessBean; +import org.junit.runner.RunWith; + +import javax.ejb.EJBException; +import javax.ejb.EntityContext; +import javax.ejb.RemoveException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import java.rmi.RemoteException; + +@RunWith(ValidationRunner.class) +public class CheckMissingClassTest { + @Keys(@Key(value = "missing.class", count = 16)) + public EjbJar wrongClassType() throws OpenEJBException { + System.setProperty("openejb.validation.output.level", "VERBOSE"); + final EjbJar ejbJar = new EjbJar(); + final StatelessBean stateless = new StatelessBean(FooStateless.class); + stateless.setHomeAndRemote("WrongHome", "WrongRemote"); + stateless.setLocal("WrongLocal"); + stateless.setLocalHome("WrongLocalHome"); + ejbJar.addEnterpriseBean(stateless); + final StatefulBean stateful = new StatefulBean(FooStateful.class); + stateful.setHomeAndRemote("WrongHome", "WrongRemote"); + stateful.setLocal("WrongLocal"); + stateful.setLocalHome("WrongLocalHome"); + ejbJar.addEnterpriseBean(stateful); + final EntityBean bmpEntityBean = new EntityBean(FooEntityBMP.class, PersistenceType.BEAN); + bmpEntityBean.setHome("WrongHome"); + bmpEntityBean.setLocalHome("WrongLocalHome"); + bmpEntityBean.setRemote("WrongRemote"); + bmpEntityBean.setLocal("WrongLocal"); + ejbJar.addEnterpriseBean(bmpEntityBean); + final EntityBean cmpEntityBean = new EntityBean(FooEntityCMP.class, PersistenceType.CONTAINER); + cmpEntityBean.setHome("WrongHome"); + cmpEntityBean.setLocalHome("WrongLocalHome"); + cmpEntityBean.setRemote("WrongRemote"); + cmpEntityBean.setLocal("WrongLocal"); + ejbJar.addEnterpriseBean(cmpEntityBean); + return ejbJar; + } + + private static class FooStateless implements SessionBean { + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static class FooStateful implements SessionBean { + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static class FooEntityBMP implements javax.ejb.EntityBean { + public String ejbCreate(final String id) { + return null; + } + + public void ejbPostCreate(final String id) { + } + + ; + + @Override + public void ejbActivate() throws EJBException, RemoteException { + } + + @Override + public void ejbLoad() throws EJBException, RemoteException { + } + + @Override + public void ejbPassivate() throws EJBException, RemoteException { + } + + @Override + public void ejbRemove() throws RemoveException, EJBException, RemoteException { + } + + @Override + public void ejbStore() throws EJBException, RemoteException { + } + + @Override + public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { + } + + @Override + public void unsetEntityContext() throws EJBException, RemoteException { + } + } + + private static class FooEntityCMP implements javax.ejb.EntityBean { + public String ejbCreate(final String id) { + return null; + } + + public void ejbPostCreate(final String id) { + } + + ; + + @Override + public void ejbActivate() throws EJBException, RemoteException { + } + + @Override + public void ejbLoad() throws EJBException, RemoteException { + } + + @Override + public void ejbPassivate() throws EJBException, RemoteException { + } + + @Override + public void ejbRemove() throws RemoveException, EJBException, RemoteException { + } + + @Override + public void ejbStore() throws EJBException, RemoteException { + } + + @Override + public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { + } + + @Override + public void unsetEntityContext() throws EJBException, RemoteException { + } + } +}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoBusinessMethodTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoBusinessMethodTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoBusinessMethodTest.java index 180c6e1..f591735 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoBusinessMethodTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoBusinessMethodTest.java @@ -1,198 +1,198 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.StatefulBean; -import org.apache.openejb.jee.StatelessBean; -import org.junit.runner.RunWith; - -import javax.ejb.CreateException; -import javax.ejb.EJBException; -import javax.ejb.EJBHome; -import javax.ejb.EJBLocalHome; -import javax.ejb.EJBLocalObject; -import javax.ejb.EJBObject; -import javax.ejb.SessionBean; -import javax.ejb.SessionContext; -import java.rmi.RemoteException; - -@RunWith(ValidationRunner.class) -public class CheckNoBusinessMethodTest { - @Keys({@Key(value = "no.busines.method.case", count = 4), @Key(value = "no.busines.method.args", count = 4), @Key(value = "no.busines.method", count = 4)}) - public EjbJar noBusinessMethod() throws OpenEJBException { - // System.setProperty("openejb.validation.output.level", "VERBOSE"); - final EjbJar ejbJar = new EjbJar(); - final StatelessBean stateLessLocal = new StatelessBean(FooStatelessSession.class); - stateLessLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome"); - stateLessLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal"); - final StatefulBean statefulLocal = new StatefulBean(FooStatefulSession.class); - statefulLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome"); - statefulLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal"); - final StatelessBean stateLessRemote = new StatelessBean(FooRemoteStatelessSession.class); - stateLessRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome"); - stateLessRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote"); - final StatefulBean statefulRemote = new StatefulBean(FooRemoteStatefulSession.class); - statefulRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome"); - statefulRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote"); - ejbJar.addEnterpriseBean(stateLessLocal); - ejbJar.addEnterpriseBean(statefulLocal); - ejbJar.addEnterpriseBean(stateLessRemote); - ejbJar.addEnterpriseBean(statefulRemote); - return ejbJar; - } - - private static interface FooLocalHome extends EJBLocalHome { - FooLocal create() throws CreateException; - } - - private static interface FooLocal extends EJBLocalObject { - void foo(String x, String y); - - // this method is not implemented by the bean class - void foo1(); - } - - private static class FooStatelessSession implements SessionBean { - // method name is same as in the Local interface, except arguments are different - public void foo(final int x, final String y) { - } - - // method name has a different case - public void Foo(final String x, final String y) { - } - - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static class FooStatefulSession implements SessionBean { - // method name is same as in the Local interface, except arguments are different - public void foo(final int x, final String y) { - } - - // method name has a different case - public void Foo(final String x, final String y) { - } - - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - // ================= - private static interface FooRemoteHome extends EJBHome { - FooRemote create() throws RemoteException, CreateException; - } - - private static interface FooRemote extends EJBObject { - void foo(String x, String y) throws RemoteException; - - // This method is not implemented by the bean class - void foo1() throws RemoteException; - } - - private static class FooRemoteStatelessSession implements SessionBean { - // method name is same as in the Remote interface, except arguments are different - public void foo(final int x, final String y) { - } - - // method name has a different case - public void Foo(final String x, final String y) { - } - - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static class FooRemoteStatefulSession implements SessionBean { - // method name is same as in the Remote interface, except arguments are different - public void foo(final int x, final String y) { - } - - // method name has a different case - public void Foo(final String x, final String y) { - } - - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.StatefulBean; +import org.apache.openejb.jee.StatelessBean; +import org.junit.runner.RunWith; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.EJBHome; +import javax.ejb.EJBLocalHome; +import javax.ejb.EJBLocalObject; +import javax.ejb.EJBObject; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import java.rmi.RemoteException; + +@RunWith(ValidationRunner.class) +public class CheckNoBusinessMethodTest { + @Keys({@Key(value = "no.busines.method.case", count = 4), @Key(value = "no.busines.method.args", count = 4), @Key(value = "no.busines.method", count = 4)}) + public EjbJar noBusinessMethod() throws OpenEJBException { + // System.setProperty("openejb.validation.output.level", "VERBOSE"); + final EjbJar ejbJar = new EjbJar(); + final StatelessBean stateLessLocal = new StatelessBean(FooStatelessSession.class); + stateLessLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome"); + stateLessLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal"); + final StatefulBean statefulLocal = new StatefulBean(FooStatefulSession.class); + statefulLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome"); + statefulLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal"); + final StatelessBean stateLessRemote = new StatelessBean(FooRemoteStatelessSession.class); + stateLessRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome"); + stateLessRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote"); + final StatefulBean statefulRemote = new StatefulBean(FooRemoteStatefulSession.class); + statefulRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome"); + statefulRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote"); + ejbJar.addEnterpriseBean(stateLessLocal); + ejbJar.addEnterpriseBean(statefulLocal); + ejbJar.addEnterpriseBean(stateLessRemote); + ejbJar.addEnterpriseBean(statefulRemote); + return ejbJar; + } + + private static interface FooLocalHome extends EJBLocalHome { + FooLocal create() throws CreateException; + } + + private static interface FooLocal extends EJBLocalObject { + void foo(String x, String y); + + // this method is not implemented by the bean class + void foo1(); + } + + private static class FooStatelessSession implements SessionBean { + // method name is same as in the Local interface, except arguments are different + public void foo(final int x, final String y) { + } + + // method name has a different case + public void Foo(final String x, final String y) { + } + + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static class FooStatefulSession implements SessionBean { + // method name is same as in the Local interface, except arguments are different + public void foo(final int x, final String y) { + } + + // method name has a different case + public void Foo(final String x, final String y) { + } + + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + // ================= + private static interface FooRemoteHome extends EJBHome { + FooRemote create() throws RemoteException, CreateException; + } + + private static interface FooRemote extends EJBObject { + void foo(String x, String y) throws RemoteException; + + // This method is not implemented by the bean class + void foo1() throws RemoteException; + } + + private static class FooRemoteStatelessSession implements SessionBean { + // method name is same as in the Remote interface, except arguments are different + public void foo(final int x, final String y) { + } + + // method name has a different case + public void Foo(final String x, final String y) { + } + + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static class FooRemoteStatefulSession implements SessionBean { + // method name is same as in the Remote interface, except arguments are different + public void foo(final int x, final String y) { + } + + // method name has a different case + public void Foo(final String x, final String y) { + } + + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoCreateMethodsTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoCreateMethodsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoCreateMethodsTest.java index d5f3144..554ce09 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoCreateMethodsTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckNoCreateMethodsTest.java @@ -1,280 +1,280 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.PersistenceType; -import org.apache.openejb.jee.StatefulBean; -import org.apache.openejb.jee.StatelessBean; -import org.junit.runner.RunWith; - -import javax.ejb.CreateException; -import javax.ejb.EJBException; -import javax.ejb.EJBLocalHome; -import javax.ejb.EJBLocalObject; -import javax.ejb.EntityBean; -import javax.ejb.EntityContext; -import javax.ejb.FinderException; -import javax.ejb.LocalHome; -import javax.ejb.RemoteHome; -import javax.ejb.RemoveException; -import javax.ejb.SessionBean; -import javax.ejb.SessionContext; -import java.rmi.RemoteException; - -@RunWith(ValidationRunner.class) -public class CheckNoCreateMethodsTest { - @Keys({@Key(value = "no.home.create", count = 4), @Key(value = "unused.ejb.create", count = 2, type = KeyType.WARNING), - @Key(value = "unused.ejbPostCreate", type = KeyType.WARNING), @Key("entity.no.ejb.create"), @Key(value = "session.no.ejb.create", count = 2)}) - public EjbJar noCreateMethod() throws OpenEJBException { - System.setProperty("openejb.validation.output.level", "VERBOSE"); - final EjbJar ejbJar = new EjbJar(); - final StatelessBean stateless = new StatelessBean(FooStateless.class); - stateless.setHomeAndRemote(FooStatelessHome.class, FooStatelessRemote.class); - stateless.setHomeAndLocal(FooStatelessLocalHome.class, FooStatelessLocal.class); - ejbJar.addEnterpriseBean(stateless); - final StatefulBean stateful = new StatefulBean(FooStateful.class); - stateful.setHomeAndRemote(FooStatefulHome.class, FooStatefulRemote.class); - stateful.setHomeAndLocal(FooStatefulLocalHome.class, FooStatefulLocal.class); - ejbJar.addEnterpriseBean(stateful); - final org.apache.openejb.jee.EntityBean bean = new org.apache.openejb.jee.EntityBean(MyEntity.class, PersistenceType.BEAN); - bean.setLocalHome(MyLocalHome.class.getName()); - bean.setLocal(MyLocal.class.getName()); - ejbJar.addEnterpriseBean(bean); - final org.apache.openejb.jee.EntityBean bean1 = new org.apache.openejb.jee.EntityBean(YourEntity.class, PersistenceType.BEAN); - bean1.setLocalHome(MyLocalHome.class.getName()); - bean1.setLocal(MyLocal.class.getName()); - ejbJar.addEnterpriseBean(bean1); - final StatelessBean bar = new StatelessBean(BarStateless.class); - bar.setHomeAndRemote(BarStatelessHome.class, BarStatelessRemote.class); - ejbJar.addEnterpriseBean(bar); - final StatefulBean bazStateful = new StatefulBean(BazStateful.class); - ejbJar.addEnterpriseBean(bazStateful); - return ejbJar; - } - - private static interface FooStatelessHome extends javax.ejb.EJBHome { - } - - private static interface FooStatelessRemote extends javax.ejb.EJBObject { - } - - private static interface FooStatelessLocalHome extends javax.ejb.EJBLocalHome { - } - - private static interface FooStatelessLocal extends javax.ejb.EJBLocalObject { - } - - private static class FooStateless implements SessionBean { - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static interface FooStatefulHome extends javax.ejb.EJBHome { - } - - private static interface FooStatefulRemote extends javax.ejb.EJBObject { - } - - private static interface FooStatefulLocalHome extends javax.ejb.EJBLocalHome { - } - - private static interface FooStatefulLocal extends javax.ejb.EJBLocalObject { - } - - private static class FooStateful implements SessionBean { - public void ejbCreate() { - } - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static interface MyLocalHome extends EJBLocalHome { - public MyLocal create(Integer pk) throws CreateException; - - public MyLocal findByPrimaryKey(Integer pk) throws FinderException; - } - - private static interface MyLocal extends EJBLocalObject { - } - - private static class MyEntity implements EntityBean { - public Integer ejbCreate(final Integer pk) throws CreateException { - return null; - } - - public void ejbPostCreate(final String str) { - } - - @Override - public void ejbActivate() throws EJBException, RemoteException { - } - - @Override - public void ejbLoad() throws EJBException, RemoteException { - } - - @Override - public void ejbPassivate() throws EJBException, RemoteException { - } - - @Override - public void ejbRemove() throws RemoveException, EJBException, RemoteException { - } - - @Override - public void ejbStore() throws EJBException, RemoteException { - } - - @Override - public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { - } - - @Override - public void unsetEntityContext() throws EJBException, RemoteException { - } - } - - private static class YourEntity implements EntityBean { -// public Integer ejbCreate(Integer pk) throws CreateException { -// return null; -// } - -// public void ejbPostCreate(Integer pk) {} - - @Override - public void ejbActivate() throws EJBException, RemoteException { - } - - @Override - public void ejbLoad() throws EJBException, RemoteException { - } - - @Override - public void ejbPassivate() throws EJBException, RemoteException { - } - - @Override - public void ejbRemove() throws RemoveException, EJBException, RemoteException { - } - - @Override - public void ejbStore() throws EJBException, RemoteException { - } - - @Override - public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { - } - - @Override - public void unsetEntityContext() throws EJBException, RemoteException { - } - } - - private static interface BarStatelessHome extends javax.ejb.EJBHome { - public BarStatelessRemote create() throws CreateException, RemoteException; - } - - private static interface BarStatelessRemote extends javax.ejb.EJBObject { - } - - private static class BarStateless implements SessionBean { - - @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 arg0) throws EJBException, RemoteException { - } - } - - private static interface BazStatefulHome extends javax.ejb.EJBHome { - public BazStatefulRemote create() throws CreateException, RemoteException; - } - - private static interface BazStatefulRemote extends javax.ejb.EJBObject { - } - - private static interface BazStatefulLocalHome extends javax.ejb.EJBLocalHome { - public BazStatefulLocal create() throws CreateException; - } - - private static interface BazStatefulLocal extends javax.ejb.EJBLocalObject { - } - - @RemoteHome(BazStatefulHome.class) - @LocalHome(BazStatefulLocalHome.class) - private static class BazStateful implements SessionBean { - // missing ejbCreate method - - @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 arg0) throws EJBException, RemoteException { - } - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.PersistenceType; +import org.apache.openejb.jee.StatefulBean; +import org.apache.openejb.jee.StatelessBean; +import org.junit.runner.RunWith; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.EJBLocalHome; +import javax.ejb.EJBLocalObject; +import javax.ejb.EntityBean; +import javax.ejb.EntityContext; +import javax.ejb.FinderException; +import javax.ejb.LocalHome; +import javax.ejb.RemoteHome; +import javax.ejb.RemoveException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import java.rmi.RemoteException; + +@RunWith(ValidationRunner.class) +public class CheckNoCreateMethodsTest { + @Keys({@Key(value = "no.home.create", count = 4), @Key(value = "unused.ejb.create", count = 2, type = KeyType.WARNING), + @Key(value = "unused.ejbPostCreate", type = KeyType.WARNING), @Key("entity.no.ejb.create"), @Key(value = "session.no.ejb.create", count = 2)}) + public EjbJar noCreateMethod() throws OpenEJBException { + System.setProperty("openejb.validation.output.level", "VERBOSE"); + final EjbJar ejbJar = new EjbJar(); + final StatelessBean stateless = new StatelessBean(FooStateless.class); + stateless.setHomeAndRemote(FooStatelessHome.class, FooStatelessRemote.class); + stateless.setHomeAndLocal(FooStatelessLocalHome.class, FooStatelessLocal.class); + ejbJar.addEnterpriseBean(stateless); + final StatefulBean stateful = new StatefulBean(FooStateful.class); + stateful.setHomeAndRemote(FooStatefulHome.class, FooStatefulRemote.class); + stateful.setHomeAndLocal(FooStatefulLocalHome.class, FooStatefulLocal.class); + ejbJar.addEnterpriseBean(stateful); + final org.apache.openejb.jee.EntityBean bean = new org.apache.openejb.jee.EntityBean(MyEntity.class, PersistenceType.BEAN); + bean.setLocalHome(MyLocalHome.class.getName()); + bean.setLocal(MyLocal.class.getName()); + ejbJar.addEnterpriseBean(bean); + final org.apache.openejb.jee.EntityBean bean1 = new org.apache.openejb.jee.EntityBean(YourEntity.class, PersistenceType.BEAN); + bean1.setLocalHome(MyLocalHome.class.getName()); + bean1.setLocal(MyLocal.class.getName()); + ejbJar.addEnterpriseBean(bean1); + final StatelessBean bar = new StatelessBean(BarStateless.class); + bar.setHomeAndRemote(BarStatelessHome.class, BarStatelessRemote.class); + ejbJar.addEnterpriseBean(bar); + final StatefulBean bazStateful = new StatefulBean(BazStateful.class); + ejbJar.addEnterpriseBean(bazStateful); + return ejbJar; + } + + private static interface FooStatelessHome extends javax.ejb.EJBHome { + } + + private static interface FooStatelessRemote extends javax.ejb.EJBObject { + } + + private static interface FooStatelessLocalHome extends javax.ejb.EJBLocalHome { + } + + private static interface FooStatelessLocal extends javax.ejb.EJBLocalObject { + } + + private static class FooStateless implements SessionBean { + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static interface FooStatefulHome extends javax.ejb.EJBHome { + } + + private static interface FooStatefulRemote extends javax.ejb.EJBObject { + } + + private static interface FooStatefulLocalHome extends javax.ejb.EJBLocalHome { + } + + private static interface FooStatefulLocal extends javax.ejb.EJBLocalObject { + } + + private static class FooStateful implements SessionBean { + public void ejbCreate() { + } + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static interface MyLocalHome extends EJBLocalHome { + public MyLocal create(Integer pk) throws CreateException; + + public MyLocal findByPrimaryKey(Integer pk) throws FinderException; + } + + private static interface MyLocal extends EJBLocalObject { + } + + private static class MyEntity implements EntityBean { + public Integer ejbCreate(final Integer pk) throws CreateException { + return null; + } + + public void ejbPostCreate(final String str) { + } + + @Override + public void ejbActivate() throws EJBException, RemoteException { + } + + @Override + public void ejbLoad() throws EJBException, RemoteException { + } + + @Override + public void ejbPassivate() throws EJBException, RemoteException { + } + + @Override + public void ejbRemove() throws RemoveException, EJBException, RemoteException { + } + + @Override + public void ejbStore() throws EJBException, RemoteException { + } + + @Override + public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { + } + + @Override + public void unsetEntityContext() throws EJBException, RemoteException { + } + } + + private static class YourEntity implements EntityBean { +// public Integer ejbCreate(Integer pk) throws CreateException { +// return null; +// } + +// public void ejbPostCreate(Integer pk) {} + + @Override + public void ejbActivate() throws EJBException, RemoteException { + } + + @Override + public void ejbLoad() throws EJBException, RemoteException { + } + + @Override + public void ejbPassivate() throws EJBException, RemoteException { + } + + @Override + public void ejbRemove() throws RemoveException, EJBException, RemoteException { + } + + @Override + public void ejbStore() throws EJBException, RemoteException { + } + + @Override + public void setEntityContext(final EntityContext arg0) throws EJBException, RemoteException { + } + + @Override + public void unsetEntityContext() throws EJBException, RemoteException { + } + } + + private static interface BarStatelessHome extends javax.ejb.EJBHome { + public BarStatelessRemote create() throws CreateException, RemoteException; + } + + private static interface BarStatelessRemote extends javax.ejb.EJBObject { + } + + private static class BarStateless implements SessionBean { + + @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 arg0) throws EJBException, RemoteException { + } + } + + private static interface BazStatefulHome extends javax.ejb.EJBHome { + public BazStatefulRemote create() throws CreateException, RemoteException; + } + + private static interface BazStatefulRemote extends javax.ejb.EJBObject { + } + + private static interface BazStatefulLocalHome extends javax.ejb.EJBLocalHome { + public BazStatefulLocal create() throws CreateException; + } + + private static interface BazStatefulLocal extends javax.ejb.EJBLocalObject { + } + + @RemoteHome(BazStatefulHome.class) + @LocalHome(BazStatefulLocalHome.class) + private static class BazStateful implements SessionBean { + // missing ejbCreate method + + @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 arg0) throws EJBException, RemoteException { + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceContextUsageTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceContextUsageTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceContextUsageTest.java index fbd9e3a..ec84ba7 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceContextUsageTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceContextUsageTest.java @@ -1,99 +1,99 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.config.AppModule; -import org.apache.openejb.config.EjbModule; -import org.apache.openejb.config.PersistenceModule; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.StatelessBean; -import org.apache.openejb.jee.jpa.unit.PersistenceUnit; -import org.junit.runner.RunWith; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; - -@RunWith(ValidationRunner.class) -public class CheckPersistenceContextUsageTest { - @Keys({@Key(value = "persistenceContextExtented.nonStateful"), @Key(value = "persistenceContextRef.noPersistenceUnits", count = 3), - @Key(value = "persistenceContextAnnotation.onClassWithNoName"), @Key(value = "persistenceContextAnnotation.onEntityManagerFactory"), - @Key(value = "persistenceContextAnnotation.onNonEntityManager")}) - public EjbJar wrongUsage() throws OpenEJBException { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStateless.class)); - return ejbJar; - } - - @Keys({@Key(value = "persistenceContextRef.noUnitName"), @Key(value = "persistenceContextRef.noMatches")}) - public AppModule noUnitName() { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessOne.class)); - final EjbModule ejbModule = new EjbModule(ejbJar); - final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); - appModule.getEjbModules().add(ejbModule); - final PersistenceUnit pu = new PersistenceUnit("fooUnit"); - final PersistenceUnit pu1 = new PersistenceUnit("fooUnit1"); - final PersistenceUnit pu2 = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu, pu1, pu2); - final PersistenceModule pm = new PersistenceModule("foo", p); - appModule.addPersistenceModule(pm); - return appModule; - } - - @Keys({@Key(value = "persistenceContextRef.vagueMatches")}) - public AppModule vagueMatches() { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class)); - final EjbModule ejbModule = new EjbModule(ejbJar); - final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); - appModule.getEjbModules().add(ejbModule); - final PersistenceUnit pu = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu); - final PersistenceModule pm = new PersistenceModule("foo", p); - appModule.getPersistenceModules().add(pm); - final PersistenceUnit pu1 = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1); - final PersistenceModule pm1 = new PersistenceModule("foo1", p1); - appModule.addPersistenceModule(pm1); - return appModule; - } - - @PersistenceContext - private static class FooStateless { - @PersistenceContext(type = PersistenceContextType.EXTENDED) - EntityManager em; - @PersistenceContext - EntityManagerFactory emf; - @PersistenceContext - String nonEntityManager; - } - - private static class FooStatelessOne { - @PersistenceContext - EntityManager em; - @PersistenceContext(unitName = "wrongName") - EntityManager em1; - } - - private static class FooStatelessTwo { - @PersistenceContext(unitName = "fooUnit") - EntityManager em1; - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.config.AppModule; +import org.apache.openejb.config.EjbModule; +import org.apache.openejb.config.PersistenceModule; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.StatelessBean; +import org.apache.openejb.jee.jpa.unit.PersistenceUnit; +import org.junit.runner.RunWith; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.PersistenceContext; +import javax.persistence.PersistenceContextType; + +@RunWith(ValidationRunner.class) +public class CheckPersistenceContextUsageTest { + @Keys({@Key(value = "persistenceContextExtented.nonStateful"), @Key(value = "persistenceContextRef.noPersistenceUnits", count = 3), + @Key(value = "persistenceContextAnnotation.onClassWithNoName"), @Key(value = "persistenceContextAnnotation.onEntityManagerFactory"), + @Key(value = "persistenceContextAnnotation.onNonEntityManager")}) + public EjbJar wrongUsage() throws OpenEJBException { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStateless.class)); + return ejbJar; + } + + @Keys({@Key(value = "persistenceContextRef.noUnitName"), @Key(value = "persistenceContextRef.noMatches")}) + public AppModule noUnitName() { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessOne.class)); + final EjbModule ejbModule = new EjbModule(ejbJar); + final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); + appModule.getEjbModules().add(ejbModule); + final PersistenceUnit pu = new PersistenceUnit("fooUnit"); + final PersistenceUnit pu1 = new PersistenceUnit("fooUnit1"); + final PersistenceUnit pu2 = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu, pu1, pu2); + final PersistenceModule pm = new PersistenceModule("foo", p); + appModule.addPersistenceModule(pm); + return appModule; + } + + @Keys({@Key(value = "persistenceContextRef.vagueMatches")}) + public AppModule vagueMatches() { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class)); + final EjbModule ejbModule = new EjbModule(ejbJar); + final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); + appModule.getEjbModules().add(ejbModule); + final PersistenceUnit pu = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu); + final PersistenceModule pm = new PersistenceModule("foo", p); + appModule.getPersistenceModules().add(pm); + final PersistenceUnit pu1 = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1); + final PersistenceModule pm1 = new PersistenceModule("foo1", p1); + appModule.addPersistenceModule(pm1); + return appModule; + } + + @PersistenceContext + private static class FooStateless { + @PersistenceContext(type = PersistenceContextType.EXTENDED) + EntityManager em; + @PersistenceContext + EntityManagerFactory emf; + @PersistenceContext + String nonEntityManager; + } + + private static class FooStatelessOne { + @PersistenceContext + EntityManager em; + @PersistenceContext(unitName = "wrongName") + EntityManager em1; + } + + private static class FooStatelessTwo { + @PersistenceContext(unitName = "fooUnit") + EntityManager em1; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceUnitUsageTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceUnitUsageTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceUnitUsageTest.java index b0c8142..df4e669 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceUnitUsageTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckPersistenceUnitUsageTest.java @@ -1,96 +1,96 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.config.AppModule; -import org.apache.openejb.config.EjbModule; -import org.apache.openejb.config.PersistenceModule; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.StatelessBean; -import org.apache.openejb.jee.jpa.unit.PersistenceUnit; -import org.junit.runner.RunWith; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; - -@RunWith(ValidationRunner.class) -public class CheckPersistenceUnitUsageTest { - @Keys({@Key(value = "persistenceUnitRef.noPersistenceUnits", count = 3), @Key("persistenceUnitAnnotation.onClassWithNoName"), - @Key("persistenceUnitAnnotation.onEntityManager"), @Key("persistenceUnitAnnotation.onNonEntityManagerFactory")}) - public EjbJar wrongUsage() throws OpenEJBException { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStateless.class)); - return ejbJar; - } - - @Keys({@Key(value = "persistenceUnitRef.noMatches"), @Key(value = "persistenceUnitRef.noUnitName")}) - public AppModule noUnitName() { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessOne.class)); - final EjbModule ejbModule = new EjbModule(ejbJar); - final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); - appModule.getEjbModules().add(ejbModule); - final PersistenceUnit pu = new PersistenceUnit("fooUnit"); - final PersistenceUnit pu1 = new PersistenceUnit("fooUnit1"); - final PersistenceUnit pu2 = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu, pu1, pu2); - final PersistenceModule pm = new PersistenceModule("foo", p); - appModule.addPersistenceModule(pm); - return appModule; - } - - @Keys({@Key(value = "persistenceUnitRef.vagueMatches")}) - public AppModule vagueMatches() { - final EjbJar ejbJar = new EjbJar(); - ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class)); - final EjbModule ejbModule = new EjbModule(ejbJar); - final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); - appModule.getEjbModules().add(ejbModule); - final PersistenceUnit pu = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu); - final PersistenceModule pm = new PersistenceModule("foo", p); - appModule.getPersistenceModules().add(pm); - final PersistenceUnit pu1 = new PersistenceUnit("fooUnit"); - final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1); - final PersistenceModule pm1 = new PersistenceModule("foo1", p1); - appModule.addPersistenceModule(pm1); - return appModule; - } - - @javax.persistence.PersistenceUnit - private static class FooStateless { - @javax.persistence.PersistenceUnit - EntityManagerFactory emf; - @javax.persistence.PersistenceUnit - EntityManager em; - @javax.persistence.PersistenceUnit - String nonEntityManagerFactory; - } - - private static class FooStatelessOne { - @javax.persistence.PersistenceUnit(unitName = "wrongName") - EntityManagerFactory emf; - @javax.persistence.PersistenceUnit - EntityManagerFactory emf1; - } - - private static class FooStatelessTwo { - @javax.persistence.PersistenceUnit(unitName = "fooUnit") - EntityManagerFactory emf; - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.config.AppModule; +import org.apache.openejb.config.EjbModule; +import org.apache.openejb.config.PersistenceModule; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.StatelessBean; +import org.apache.openejb.jee.jpa.unit.PersistenceUnit; +import org.junit.runner.RunWith; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +@RunWith(ValidationRunner.class) +public class CheckPersistenceUnitUsageTest { + @Keys({@Key(value = "persistenceUnitRef.noPersistenceUnits", count = 3), @Key("persistenceUnitAnnotation.onClassWithNoName"), + @Key("persistenceUnitAnnotation.onEntityManager"), @Key("persistenceUnitAnnotation.onNonEntityManagerFactory")}) + public EjbJar wrongUsage() throws OpenEJBException { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStateless.class)); + return ejbJar; + } + + @Keys({@Key(value = "persistenceUnitRef.noMatches"), @Key(value = "persistenceUnitRef.noUnitName")}) + public AppModule noUnitName() { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessOne.class)); + final EjbModule ejbModule = new EjbModule(ejbJar); + final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); + appModule.getEjbModules().add(ejbModule); + final PersistenceUnit pu = new PersistenceUnit("fooUnit"); + final PersistenceUnit pu1 = new PersistenceUnit("fooUnit1"); + final PersistenceUnit pu2 = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu, pu1, pu2); + final PersistenceModule pm = new PersistenceModule("foo", p); + appModule.addPersistenceModule(pm); + return appModule; + } + + @Keys({@Key(value = "persistenceUnitRef.vagueMatches")}) + public AppModule vagueMatches() { + final EjbJar ejbJar = new EjbJar(); + ejbJar.addEnterpriseBean(new StatelessBean(FooStatelessTwo.class)); + final EjbModule ejbModule = new EjbModule(ejbJar); + final AppModule appModule = new AppModule(ejbModule.getClassLoader(), ejbModule.getJarLocation()); + appModule.getEjbModules().add(ejbModule); + final PersistenceUnit pu = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p = new org.apache.openejb.jee.jpa.unit.Persistence(pu); + final PersistenceModule pm = new PersistenceModule("foo", p); + appModule.getPersistenceModules().add(pm); + final PersistenceUnit pu1 = new PersistenceUnit("fooUnit"); + final org.apache.openejb.jee.jpa.unit.Persistence p1 = new org.apache.openejb.jee.jpa.unit.Persistence(pu1); + final PersistenceModule pm1 = new PersistenceModule("foo1", p1); + appModule.addPersistenceModule(pm1); + return appModule; + } + + @javax.persistence.PersistenceUnit + private static class FooStateless { + @javax.persistence.PersistenceUnit + EntityManagerFactory emf; + @javax.persistence.PersistenceUnit + EntityManager em; + @javax.persistence.PersistenceUnit + String nonEntityManagerFactory; + } + + private static class FooStatelessOne { + @javax.persistence.PersistenceUnit(unitName = "wrongName") + EntityManagerFactory emf; + @javax.persistence.PersistenceUnit + EntityManagerFactory emf1; + } + + private static class FooStatelessTwo { + @javax.persistence.PersistenceUnit(unitName = "fooUnit") + EntityManagerFactory emf; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckWrongClassTypeTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckWrongClassTypeTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckWrongClassTypeTest.java index 96fb35c..4bdb585 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckWrongClassTypeTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckWrongClassTypeTest.java @@ -1,41 +1,41 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.config.rules; - -import org.apache.openejb.OpenEJBException; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.EntityBean; -import org.apache.openejb.jee.PersistenceType; -import org.junit.runner.RunWith; - -@RunWith(ValidationRunner.class) -public class CheckWrongClassTypeTest { - @Keys({@Key("wrong.class.type"), @Key("noInterfaceDeclared.entity")}) - public EjbJar wrongClassType() throws OpenEJBException { - System.setProperty("openejb.validation.output.level", "VERBOSE"); - final EjbJar ejbJar = new EjbJar(); - final EntityBean entityBean = new EntityBean(); - entityBean.setEjbClass(FooEntity.class); - entityBean.setEjbName("fooEntity"); - entityBean.setPersistenceType(PersistenceType.BEAN); - ejbJar.addEnterpriseBean(entityBean); - return ejbJar; - } - - private static class FooEntity { - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.config.rules; + +import org.apache.openejb.OpenEJBException; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.EntityBean; +import org.apache.openejb.jee.PersistenceType; +import org.junit.runner.RunWith; + +@RunWith(ValidationRunner.class) +public class CheckWrongClassTypeTest { + @Keys({@Key("wrong.class.type"), @Key("noInterfaceDeclared.entity")}) + public EjbJar wrongClassType() throws OpenEJBException { + System.setProperty("openejb.validation.output.level", "VERBOSE"); + final EjbJar ejbJar = new EjbJar(); + final EntityBean entityBean = new EntityBean(); + entityBean.setEjbClass(FooEntity.class); + entityBean.setEjbName("fooEntity"); + entityBean.setPersistenceType(PersistenceType.BEAN); + ejbJar.addEnterpriseBean(entityBean); + return ejbJar; + } + + private static class FooEntity { + } +}