openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1545273 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/xml/ test/java/org/apache/webbeans/newtests/decorators/tests/ test/resources/org/apache/webbeans/newtests/decorators/tests/
Date Mon, 25 Nov 2013 13:35:26 GMT
Author: struberg
Date: Mon Nov 25 13:35:25 2013
New Revision: 1545273

URL: http://svn.apache.org/r1545273
Log:
OWB-916 also allow decorators in multiple beans.xmls

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DecoratorConfigurationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SameDecorator_broken.xml
      - copied, changed from r1545239, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleDecoratorStack.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_1.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_2.xml
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DecoratorAndInterceptorStack.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=1545273&r1=1545272&r2=1545273&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Mon Nov 25 13:35:25 2013
@@ -337,6 +337,9 @@ public final class WebBeansXMLConfigurat
         Node node;
         Element child;
         NodeList ns = decoratorsElement.getChildNodes();
+
+        Set<Class> decoratorsInFile = new HashSet<Class>();
+
         for (int i = 0; i < ns.getLength(); i++)
         {
             node = ns.item(i);
@@ -357,14 +360,15 @@ public final class WebBeansXMLConfigurat
             else
             {
                 boolean isBDAScanningEnabled=(scanner!=null && scanner.isBDABeansXmlScanningEnabled());
-                if ((isBDAScanningEnabled && !scanner.getBDABeansXmlScanner().addDecorator(clazz,
fileName))||
-                        (!isBDAScanningEnabled && manager.isDecoratorEnabled(clazz)))
+                if ((isBDAScanningEnabled && !scanner.getBDABeansXmlScanner().addDecorator(clazz,
fileName)) ||
+                    decoratorsInFile.contains(clazz))
                 {
                     throw new WebBeansConfigurationException(createConfigurationFailedMessage()
+ "Decorator class : " +
                                                              child.getTextContent().trim()
+ " is already defined");
                 }
 
                 manager.addEnabledDecorator(clazz);
+                decoratorsInFile.add(clazz);
             }
 
         }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DecoratorConfigurationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DecoratorConfigurationTest.java?rev=1545273&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DecoratorConfigurationTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DecoratorConfigurationTest.java
Mon Nov 25 13:35:25 2013
@@ -0,0 +1,70 @@
+/*
+ * 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.webbeans.newtests.decorators.tests;
+
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.decorators.multiple.Decorator1;
+import org.apache.webbeans.newtests.decorators.multiple.OutputProvider;
+import org.apache.webbeans.newtests.decorators.multiple.RequestStringBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class DecoratorConfigurationTest extends AbstractUnitTest
+{
+    public static final String PACKAGE_NAME = DecoratorConfigurationTest.class.getPackage().getName();
+
+    @Test(expected = WebBeansConfigurationException.class)
+    public void testMultipleDecoratorsInSameFile()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "SameDecorator_broken"));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Decorator1.class);
+        beanClasses.add(OutputProvider.class);
+
+        startContainer(beanClasses, beanXmls, true);
+        Assert.fail("should have thrown a deployment error");
+    }
+
+    @Test
+    public void testMultipleDecoratorsInMultipleFiles()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "SimpleDecorator_1"));
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "SimpleDecorator_2"));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Decorator1.class);
+        beanClasses.add(OutputProvider.class);
+        beanClasses.add(RequestStringBuilder.class);
+
+        startContainer(beanClasses, beanXmls, true);
+
+        OutputProvider op = getInstance(OutputProvider.class);
+        Assert.assertNotNull(op);
+        op.getOutput();
+
+    }
+}
+

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DecoratorAndInterceptorStack.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DecoratorAndInterceptorStack.xml?rev=1545273&r1=1545272&r2=1545273&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DecoratorAndInterceptorStack.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DecoratorAndInterceptorStack.xml
Mon Nov 25 13:35:25 2013
@@ -18,11 +18,11 @@ specific language governing permissions 
 under the License.
 -->
 <beans>
-   <interceptors>
-		<class>org.apache.webbeans.newtests.decorators.multiple.OutputInterceptor</class>
-	</interceptors>
-   <decorators>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator2</class>
-   </decorators>
+    <interceptors>
+        <class>org.apache.webbeans.newtests.decorators.multiple.OutputInterceptor</class>
+    </interceptors>
+    <decorators>
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator2</class>
+    </decorators>
 </beans>
\ No newline at end of file

Copied: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SameDecorator_broken.xml
(from r1545239, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleDecoratorStack.xml)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SameDecorator_broken.xml?p2=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SameDecorator_broken.xml&p1=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleDecoratorStack.xml&r1=1545239&r2=1545273&rev=1545273&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/MultipleDecoratorStack.xml
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SameDecorator_broken.xml
Mon Nov 25 13:35:25 2013
@@ -18,8 +18,9 @@ specific language governing permissions 
 under the License.
 -->
 <beans>
-   <decorators>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
-      <class>org.apache.webbeans.newtests.decorators.multiple.Decorator2</class>
-   </decorators>
+    <decorators>
+        <!-- the same decorator defined twice in the same file must lead to a deployment
exception -->
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
+    </decorators>
 </beans>
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_1.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_1.xml?rev=1545273&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_1.xml
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_1.xml
Mon Nov 25 13:35:25 2013
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans>
+    <decorators>
+        <!-- the same decorator defined twice in the same file must lead to a deployment
exception -->
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
+    </decorators>
+</beans>
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_2.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_2.xml?rev=1545273&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_2.xml
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/SimpleDecorator_2.xml
Mon Nov 25 13:35:25 2013
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans>
+    <decorators>
+        <!-- the same decorator defined twice in the same file must lead to a deployment
exception -->
+        <class>org.apache.webbeans.newtests.decorators.multiple.Decorator1</class>
+    </decorators>
+</beans>
\ No newline at end of file



Mime
View raw message