You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/03/31 05:35:07 UTC
svn commit: r1087170 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/config/
test/java/org/apache/openejb/config/rules/ test/java/org/apache/openejb/meta/
Author: dblevins
Date: Thu Mar 31 03:35:06 2011
New Revision: 1087170
URL: http://svn.apache.org/viewvc?rev=1087170&view=rev
Log:
OPENEJB-1454: Meta Annotation Support
OPENEJB-1455: Meta: @AccessTimeout
OPENEJB-1456: Meta: @AfterBegin
OPENEJB-1457: Meta: @AfterCompletion
OPENEJB-1459: Meta: @Asynchronous
OPENEJB-1460: Meta: @BeforeCompletion
OPENEJB-1461: Meta: @ConcurrencyManagement
OPENEJB-1463: Meta: @EJB
OPENEJB-1466: Meta: @Init
OPENEJB-1470: Meta: @Lock
OPENEJB-1472: Meta: @PostActivate
OPENEJB-1473: Meta: @PrePassivate
OPENEJB-1474: Meta: @Remove
OPENEJB-1475: Meta: @Schedule
OPENEJB-1476: Meta: @Schedules
OPENEJB-1480: Meta: @Startup
OPENEJB-1482: Meta: @StatefulTimeout
OPENEJB-1484: Meta: @Timeout
OPENEJB-1485: Meta: @TransactionAttribute
OPENEJB-1486: Meta: @TransactionManagement
OPENEJB-1489: Meta: @PostConstruct
OPENEJB-1490: Meta: @PreDestroy
OPENEJB-1491: Meta: @Resource
OPENEJB-1508: Meta: @Interceptors
Added:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java (with props)
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java (with props)
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidCallbacksTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1087170&r1=1087169&r2=1087170&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Thu Mar 31 03:35:06 2011
@@ -1165,7 +1165,8 @@ public class AnnotationDeployer implemen
/*
* @Interceptors
*/
- for (Annotated<Class<?>> interceptorsAnnotatedClass : sortClasses(annotationFinder.findMetaAnnotatedClasses(Interceptors.class))) {
+ List<Annotated<Class<?>>> annotatedClasses = sortClasses(annotationFinder.findMetaAnnotatedClasses(Interceptors.class));
+ for (Annotated<Class<?>> interceptorsAnnotatedClass : annotatedClasses) {
Interceptors interceptors = interceptorsAnnotatedClass.getAnnotation(Interceptors.class);
EjbJar ejbJar = ejbModule.getEjbJar();
for (Class interceptor : interceptors.value()) {
@@ -1182,7 +1183,8 @@ public class AnnotationDeployer implemen
}
}
- for (Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(Interceptors.class))) {
+ List<Annotated<Method>> annotatedMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(Interceptors.class));
+ for (Annotated<Method> method : annotatedMethods) {
Interceptors interceptors = method.getAnnotation(Interceptors.class);
if (interceptors != null) {
EjbJar ejbJar = ejbModule.getEjbJar();
@@ -3487,44 +3489,46 @@ public class AnnotationDeployer implemen
// SET THE DEFAULT
final Class<A> annotationClass = handler.getAnnotationClass();
+ List<Annotated<Class<?>>> types = sortClasses(annotationFinder.findMetaAnnotatedClasses(annotationClass));
if (!hasMethodAttribute("*", null, existingDeclarations)) {
- for (Class<?> type : ancestors(clazz)) {
- if (!hasMethodAttribute("*", type, existingDeclarations)) {
+ for (Annotated<Class<?>> type : types) {
+ if (!type.get().isAssignableFrom(clazz)) continue;
+ if (!hasMethodAttribute("*", type.get(), existingDeclarations)) {
A attribute = type.getAnnotation(annotationClass);
if (attribute != null) {
- handler.addClassLevelDeclaration(attribute, type);
+ handler.addClassLevelDeclaration(attribute, type.get());
}
}
}
}
- List<Method> methods = annotationFinder.findAnnotatedMethods(annotationClass);
- for (Method method : methods) {
+ List<Annotated<Method>> methods = annotationFinder.findMetaAnnotatedMethods(annotationClass);
+ for (Annotated<Method> method : methods) {
A attribute = method.getAnnotation(annotationClass);
- if (!existingDeclarations.containsKey(method.getName())) {
+ if (!existingDeclarations.containsKey(method.get().getName())) {
// no method with this name in descriptor
- handler.addMethodLevelDeclaration(attribute, method);
+ handler.addMethodLevelDeclaration(attribute, method.get());
} else {
// method name already declared
- List<MethodAttribute> list = existingDeclarations.get(method.getName());
+ List<MethodAttribute> list = existingDeclarations.get(method.get().getName());
for (MethodAttribute mtx : list) {
MethodParams methodParams = mtx.getMethodParams();
if (methodParams == null) {
// params not specified, so this is more specific
- handler.addMethodLevelDeclaration(attribute, method);
+ handler.addMethodLevelDeclaration(attribute, method.get());
} else {
List<String> params1 = methodParams.getMethodParam();
- String[] params2 = asStrings(method.getParameterTypes());
+ String[] params2 = asStrings(method.get().getParameterTypes());
if (params1.size() != params2.length) {
// params not the same
- handler.addMethodLevelDeclaration(attribute, method);
+ handler.addMethodLevelDeclaration(attribute, method.get());
} else {
for (int i = 0; i < params1.size(); i++) {
String a = params1.get(i);
String b = params2[i];
if (!a.equals(b)) {
// params not the same
- handler.addMethodLevelDeclaration(attribute, method);
+ handler.addMethodLevelDeclaration(attribute, method.get());
break;
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidCallbacksTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidCallbacksTest.java?rev=1087170&r1=1087169&r2=1087170&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidCallbacksTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckInvalidCallbacksTest.java Thu Mar 31 03:35:06 2011
@@ -48,7 +48,7 @@ import org.junit.runner.RunWith;
*/
@RunWith(ValidationRunner.class)
public class CheckInvalidCallbacksTest extends TestCase {
- @Keys({ @Key(value = "ignoredMethodAnnotation", count = 10, type = KeyType.WARNING), @Key("callback.missing.possibleTypo"), @Key("callback.badReturnType"),
+ @Keys({ @Key(value = "ignoredMethodAnnotation", count = 10, type = KeyType.WARNING), @Key("callback.invalidArguments"), @Key("callback.badReturnType"),
@Key("callback.badModifier"), @Key("callback.invalidArguments"), @Key("aroundInvoke.missing"), @Key("callback.missing"),
@Key(value = "callback.sessionSynchronization.invalidUse", count = 2) })
public EjbJar test() throws Exception {
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java Thu Mar 31 03:35:06 2011
@@ -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
+ *
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class AccessTimeoutMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @AccessTimeout(value = 0)
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface AwaitNever {
+ }
+
+ @AccessTimeout(value = -1)
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface AwaitForever {
+ }
+
+
+ /**
+ * Standard bean
+ */
+ @AccessTimeout(value = 0)
+ public static class ExpectedBean implements Bean {
+
+ @AccessTimeout(value = -1)
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @AwaitNever
+ public static class ActualBean implements Bean {
+
+ @AwaitForever
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AccessTimeoutMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.AfterBegin;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class AfterBeginMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface TransactionJoined {
+ public static class $ {
+
+ @TransactionJoined
+ @AfterBegin
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @AfterBegin
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @TransactionJoined
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterBeginMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.AfterCompletion;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class AfterCompletionMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface TransactionFinished {
+ public static class $ {
+
+ @TransactionFinished
+ @AfterCompletion
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @AfterCompletion
+ public void method(boolean b) {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @TransactionFinished
+ public void method(boolean b) {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AfterCompletionMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,72 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Asynchronous;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class AsynchronousMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Asynchronous
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface NonBlocking {
+ }
+
+
+ /**
+ * Standard bean
+ */
+ @Asynchronous
+ public static class ExpectedBean implements Bean {
+
+ @Asynchronous
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @NonBlocking
+ public static class ActualBean implements Bean {
+
+ @NonBlocking
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/AsynchronousMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.BeforeCompletion;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class BeforeCompletionMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface FinishTransaction {
+ public static class $ {
+
+ @FinishTransaction
+ @BeforeCompletion
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @BeforeCompletion
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @FinishTransaction
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/BeforeCompletionMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class ConcurrencyManagementMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
+ @Metatype
+ @Target({ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface ManagedConcurrency {
+ }
+
+ /**
+ * Standard bean
+ */
+ @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
+ public static class ExpectedBean implements Bean {
+ }
+
+ /**
+ * Meta bean
+ */
+ @ManagedConcurrency
+ public static class ActualBean implements Bean {
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ConcurrencyManagementMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,103 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class EjbMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @EJB(name = "orange", beanInterface = Bean.class)
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Orange {
+ }
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Yellow {
+ public static class $ {
+
+ @Yellow
+ @EJB(name = "yellow")
+ public void method() {
+ }
+ }
+ }
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Red {
+ public static class $ {
+
+ @Red
+ @EJB(name = "red")
+ public Object field;
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ @EJB(name = "orange", beanInterface = Bean.class)
+ public static class ExpectedBean implements Bean {
+
+ @EJB(name = "red")
+ private Bean red;
+
+ @EJB(name = "yellow")
+ public void setYellow(Bean yellow) {
+
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @Orange
+ public static class ActualBean implements Bean {
+
+ @EJB(name = "red")
+ private Bean red;
+
+ @EJB(name = "yellow")
+ public void setYellow(Bean yellow) {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/EjbMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Init;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class InitMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Create {
+ public static class $ {
+
+ @Create
+ @Init
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @Init
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @Create
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InitMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,108 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class InterceptorsMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+ @Interceptors({LogUser.class, LogMethod.class, LogExceptions.class})
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface CasualLogging {
+ }
+
+ @Interceptors({LogInvokeTime.class, LogArguments.class, LogReturnValue.class})
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface CriticalLogging {
+ }
+
+
+ /**
+ * Standard bean
+ */
+ @Interceptors({LogUser.class, LogMethod.class, LogExceptions.class})
+ public static class ExpectedBean implements Bean {
+
+ @Interceptors({LogInvokeTime.class, LogArguments.class, LogReturnValue.class})
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @CasualLogging
+ public static class ActualBean implements Bean {
+
+ @CriticalLogging
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+
+ public static class BaseInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ return context.proceed();
+ }
+ }
+
+ public static class LogUser extends BaseInterceptor {
+ }
+
+ public static class LogMethod extends BaseInterceptor {
+ }
+
+ public static class LogInvokeTime extends BaseInterceptor {
+ }
+
+ public static class LogArguments extends BaseInterceptor {
+ }
+
+ public static class LogReturnValue extends BaseInterceptor {
+ }
+
+ public static class LogExceptions extends BaseInterceptor {
+ }
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/InterceptorsMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,73 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class LockMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Lock(LockType.READ)
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface ReadOnly {
+ }
+
+
+ /**
+ * Standard bean
+ */
+ @Lock(LockType.READ)
+ public static class ExpectedBean implements Bean {
+
+ @Lock(LockType.READ)
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @ReadOnly
+ public static class ActualBean implements Bean {
+
+ @ReadOnly
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/LockMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,82 @@
+/**
+ * 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.meta;
+
+import org.junit.Test;
+import org.junit.internal.runners.model.ReflectiveCallable;
+import org.junit.internal.runners.statements.Fail;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MetaRunner extends BlockJUnit4ClassRunner {
+ public MetaRunner(Class<?> klass) throws InitializationError {
+ super(klass);
+ }
+
+ /**
+ * Flags an error if you have annotated a test with both @Test and @Keys. Any method annotated with @Test will be ignored anyways.
+ */
+ @Override
+ protected void collectInitializationErrors(List<Throwable> errors) {
+ super.collectInitializationErrors(errors);
+ List<FrameworkMethod> methodsAnnotatedWithKeys = getTestClass().getAnnotatedMethods(MetaTest.class);
+ for (FrameworkMethod frameworkMethod : methodsAnnotatedWithKeys) {
+ if (frameworkMethod.getAnnotation(Test.class) != null) {
+ String gripe = "The method " + frameworkMethod.getName() + "() can only be annotated with @MetaTest";
+ errors.add(new Exception(gripe));
+ }
+ }
+ }
+
+ @Override
+ protected Statement methodBlock(FrameworkMethod method) {
+ Object test;
+ try {
+ test = new ReflectiveCallable() {
+ @Override
+ protected Object runReflectiveCall() throws Throwable {
+ return createTest();
+ }
+ }.run();
+ } catch (Throwable e) {
+ return new Fail(e);
+ }
+ Statement statement = new MetaTest.$(method, test);
+ statement = withBefores(method, test, statement);
+ statement = withAfters(method, test, statement);
+ return statement;
+ }
+
+ /**
+ * By default JUnit includes all methods annotated with @Test. This method only allows methods annotated with @Keys to be included in the list of methods to be run in a
+ * TestCase. Any @Test methods will be ignored
+ */
+ @Override
+ protected List<FrameworkMethod> computeTestMethods() {
+ TestClass testClass = getTestClass();
+ List<FrameworkMethod> methods = testClass.getAnnotatedMethods(MetaTest.class);
+ return methods;
+ }
+}
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,160 @@
+/**
+ * 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.meta;
+
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ContainerInfo;
+import org.apache.openejb.assembler.classic.ContainerSystemInfo;
+import org.apache.openejb.assembler.classic.FacilitiesInfo;
+import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.ContainerTransaction;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.ManagedBean;
+import org.apache.openejb.jee.MessageDrivenBean;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.StatefulBean;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.loader.SystemInstance;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
+
+import javax.xml.bind.JAXBException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * @version $Rev$ $Date$
+ */
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface MetaTest {
+
+ Class expected();
+
+ Class actual();
+
+ Class<? extends EnterpriseBean>[] types() default {};
+
+
+ public static class $ extends Statement {
+
+ // The test method
+ private final FrameworkMethod testMethod;
+
+ public $(FrameworkMethod testMethod, Object target) {
+ this.testMethod = testMethod;
+ }
+
+ @Override
+ public void evaluate() throws Throwable {
+ MetaTest annotation = testMethod.getAnnotation(MetaTest.class);
+
+
+ Class<? extends EnterpriseBean>[] classes = annotation.types();
+
+ // for some reason these defaults do not work in the annotation
+ if (classes.length == 0) classes = new Class[]{SingletonBean.class, StatelessBean.class, StatefulBean.class, ManagedBean.class, MessageDrivenBean.class};
+
+ for (Class<? extends EnterpriseBean> beanType : classes) {
+
+
+ try {
+ ConfigurationFactory factory = factory();
+
+ EjbJar expected = new EjbJar("expected");
+ EnterpriseBean bean = expected.addEnterpriseBean(newBean(beanType, annotation.expected()));
+
+ EjbJar actual = new EjbJar("actual");
+ actual.addEnterpriseBean(newBean(beanType, annotation.actual()));
+
+
+ AppModule app = new AppModule(this.getClass().getClassLoader(), "test");
+ app.getEjbModules().add(module(expected));
+ app.getEjbModules().add(module(actual));
+
+ AppInfo appInfo = factory.configureApplication(app);
+
+ List<ContainerTransaction> expectedList = expected.getAssemblyDescriptor().getContainerTransaction();
+ List<ContainerTransaction> actualList = actual.getAssemblyDescriptor().getContainerTransaction();
+
+ assertEquals(expectedList.size(), actualList.size());
+ String expectedXml = toString(expected);
+ String actualXml = toString(actual).replaceAll("Actual", "Expected").replaceAll("actual", "expected");
+ assertEquals(expectedXml, actualXml);
+ } catch (Exception e) {
+ throw new AssertionError(beanType.getSimpleName()).initCause(e);
+ }
+ }
+ }
+
+ private ConfigurationFactory factory() {
+ try {
+ SystemInstance.reset();
+
+ Assembler assembler = new Assembler();
+ ConfigurationFactory factory = new ConfigurationFactory();
+
+ // Configure the system but don't actually build it
+ OpenEjbConfiguration conf = factory.getOpenEjbConfiguration();
+ ContainerInfo container = new ContainerInfo();
+ container.id = "foo";
+ conf.containerSystem.containers.add(container);
+
+ SystemInstance.get().setComponent(OpenEjbConfiguration.class, conf);
+
+ return factory;
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private EjbModule module(EjbJar ejbJar) {
+ OpenejbJar openejbJar = new OpenejbJar();
+ openejbJar.addEjbDeployment(ejbJar.getEnterpriseBeans()[0]).setContainerId("foo");
+
+ return new EjbModule(ejbJar, openejbJar);
+ }
+
+ private <T> T newBean(Class<T> beanType, Class ejbClass) {
+ try {
+ Constructor<T> constructor = beanType.getConstructor(Class.class);
+ return constructor.newInstance(ejbClass);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private static String toString(EjbJar ejbjar) throws JAXBException {
+ return JaxbJavaee.marshal(EjbJar.class, ejbjar);
+ }
+
+ }
+}
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/MetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java Thu Mar 31 03:35:06 2011
@@ -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
+ *
+ * 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.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+}
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/Metatype.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.PostActivate;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class PostActivateMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Deserialized {
+ public static class $ {
+
+ @Deserialized
+ @PostActivate
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @PostActivate
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @Deserialized
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostActivateMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.annotation.PostConstruct;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class PostConstructMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Started {
+ public static class $ {
+
+ @Started
+ @PostConstruct
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @PostConstruct
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @Started
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PostConstructMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.PrePassivate;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class PrePassivateMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Serializing {
+ public static class $ {
+
+ @Serializing
+ @PrePassivate
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @PrePassivate
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @Serializing
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/PrePassivateMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,111 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Properties;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class ResourceMetaTest {
+ static {
+ Properties properties = System.getProperties();
+ properties.put("orange", "new://Resource?type=DataSource");
+ properties.put("yellow", "new://Resource?type=DataSource");
+ properties.put("red", "new://Resource?type=DataSource");
+ }
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Resource(name = "orange", type = DataSource.class)
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Orange {
+ }
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Yellow {
+ public static class $ {
+
+ @Yellow
+ @Resource(name = "yellow")
+ public void method() {
+ }
+ }
+ }
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Red {
+ public static class $ {
+
+ @Red
+ @Resource(name = "red")
+ public Object field;
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ @Resource(name = "orange", type = DataSource.class)
+ public static class ExpectedBean implements Bean {
+
+ @Resource(name = "red")
+ private DataSource red;
+
+ @Resource(name = "yellow")
+ public void setYellow(DataSource yellow) {
+
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ @Orange
+ public static class ActualBean implements Bean {
+
+ @Resource(name = "red")
+ private DataSource red;
+
+ @Resource(name = "yellow")
+ public void setYellow(DataSource yellow) {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ResourceMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class ScheduleMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface Daily {
+ public static class $ {
+
+ @Daily
+ @Schedule(second="0", minute="0", hour="0", month="*", dayOfWeek="*", year="*")
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @Schedule(second="0", minute="0", hour="0", month="*", dayOfWeek="*", year="*")
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @Daily
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/ScheduleMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,81 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class SchedulesMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface BiMonthly {
+ public static class $ {
+
+ @BiMonthly
+ @Schedules({
+ @Schedule(second = "0", minute="0", hour="0", month="*", dayOfMonth="15", year="*"),
+ @Schedule(second = "59", minute="59", hour="23", month="*", dayOfMonth="Last", year="*")
+ })
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @Schedules({
+ @Schedule(second = "0", minute="0", hour="0", month="*", dayOfMonth="15", year="*"),
+ @Schedule(second = "59", minute="59", hour="23", month="*", dayOfMonth="Last", year="*")
+ })
+ public void method() {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @BiMonthly
+ public void method() {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/SchedulesMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java Thu Mar 31 03:35:06 2011
@@ -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.meta;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.Startup;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class StartupMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Startup
+ @Metatype
+ @Target({ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface StartOnDeploy {
+ }
+
+ /**
+ * Standard bean
+ */
+// TODO
+// @Startup
+ public static class ExpectedBean implements Bean {
+ }
+
+ /**
+ * Meta bean
+ */
+ @StartOnDeploy
+ public static class ActualBean implements Bean {
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StartupMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.StatefulTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class StatefulTimeoutMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @StatefulTimeout(value = -1)
+ @Metatype
+ @Target({ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface InfiniteSession {
+ }
+
+ /**
+ * Standard bean
+ */
+// TODO
+// @StatefulTimeout(value = -1)
+ public static class ExpectedBean implements Bean {
+ }
+
+ /**
+ * Meta bean
+ */
+ @InfiniteSession
+ public static class ActualBean implements Bean {
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/StatefulTimeoutMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,75 @@
+/**
+ * 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.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.Schedule;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class TimeoutMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @Metatype
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface ExecuteTimer {
+ public static class $ {
+
+ @Timeout
+ public void method(){}
+ }
+ }
+
+ /**
+ * Standard bean
+ */
+ public static class ExpectedBean implements Bean {
+
+ @Timeout
+ public void method(Timer timer) {
+ }
+ }
+
+ /**
+ * Meta bean
+ */
+ public static class ActualBean implements Bean {
+
+ @ExecuteTimer
+ public void method(Timer timer) {
+ }
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TimeoutMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java?rev=1087170&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java Thu Mar 31 03:35:06 2011
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.meta;
+
+import org.junit.runner.RunWith;
+
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@RunWith(MetaRunner.class)
+public class TransactionManagementMetaTest {
+
+ @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
+ public void test() {
+ }
+
+
+ @TransactionManagement(TransactionManagementType.CONTAINER)
+ @Metatype
+ @Target({ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public static @interface ManagedTransactions {
+ }
+
+ /**
+ * Standard bean
+ */
+ @TransactionManagement(TransactionManagementType.CONTAINER)
+ public static class ExpectedBean implements Bean {
+ }
+
+ /**
+ * Meta bean
+ */
+ @ManagedTransactions
+ public static class ActualBean implements Bean {
+ }
+
+
+ public static interface Bean {
+ }
+
+}
\ No newline at end of file
Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/meta/TransactionManagementMetaTest.java
------------------------------------------------------------------------------
svn:eol-style = native