You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/10/07 22:28:46 UTC

svn commit: r454011 [2/2] - in /geronimo/server/trunk: ./ assemblies/geronimo-boilerplate-minimal/ configs/j2ee-system/ modules/geronimo-system/ modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ modules/geronimo-system/src...

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/resources/META-INF/schema/local-attributes-1.1.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/resources/META-INF/schema/local-attributes-1.1.xsd?view=diff&rev=454011&r1=454010&r2=454011
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/resources/META-INF/schema/local-attributes-1.1.xsd (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/resources/META-INF/schema/local-attributes-1.1.xsd Sat Oct  7 13:28:45 2006
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-
     Copyright 2004-2005 The Apache Software Foundation
 
     Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,13 +15,14 @@
     limitations under the License.
 -->
 
+<!-- $Rev$ $Date$ -->
+
 <xsd:schema
     targetNamespace="http://geronimo.apache.org/xml/ns/attributes-1.1"
     xmlns:atts="http://geronimo.apache.org/xml/ns/attributes-1.1"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified"
-    attributeFormDefault="unqualified"
-    >
+    attributeFormDefault="unqualified">
 
     <xsd:annotation>
         <xsd:documentation>
@@ -31,12 +31,12 @@
             Should look like this:
 
             <attributes>
-              <module name="mygroup/mycomponent/1.1/jar">
-                <gbean name="MyNetworkService">
-                  <attribute name="host">0.0.0.0</attribute>
-                  <attribute name="port">1234</attribute>
-                </gbean>
-              </module>
+                <module name="mygroup/mycomponent/1.1/jar">
+                    <gbean name="MyNetworkService">
+                        <attribute name="host">0.0.0.0</attribute>
+                        <attribute name="port">1234</attribute>
+                    </gbean>
+                </module>
             </attributes>
             ]]>
         </xsd:documentation>
@@ -46,35 +46,36 @@
     <xsd:element name="attributes" type="atts:attributesType"/>
 
     <!-- Element used by the plugin system to list individual GBeans -->
-    <xsd:element name="gbean" type="atts:gbeanType" />
+    <xsd:element name="gbean" type="atts:gbeanType"/>
 
     <xsd:complexType name="attributesType">
         <xsd:choice>
-            <xsd:element name="module" type="atts:configurationType" minOccurs="0" maxOccurs="unbounded" />
+            <xsd:element name="module" type="atts:moduleType" minOccurs="0" maxOccurs="unbounded"/>
 
             <!-- The config.xml file in 1.0 use configuration instead of module -->
-            <xsd:element name="configuration" type="atts:configurationType" minOccurs="0" maxOccurs="unbounded" />
+            <xsd:element name="configuration" type="atts:moduleType" minOccurs="0" maxOccurs="unbounded"/>
         </xsd:choice>
     </xsd:complexType>
 
-    <xsd:complexType name="configurationType">
+    <xsd:complexType name="moduleType">
         <xsd:sequence>
-            <xsd:element name="gbean" type="atts:gbeanType" minOccurs="0" maxOccurs="unbounded" />
+            <xsd:element name="gbean" type="atts:gbeanType" minOccurs="0" maxOccurs="unbounded"/>
         </xsd:sequence>
         <xsd:attribute name="name" type="xsd:string" use="required"/>
         <xsd:attribute name="load" type="xsd:boolean" use="optional" default="true"/>
+        <xsd:attribute name="condition" type="xsd:string" use="optional"/>
     </xsd:complexType>
 
     <xsd:complexType name="gbeanType">
         <xsd:annotation>
             <xsd:documentation>
                 <![CDATA[
-                  Note that the name attribute for a gbean element may hold
-                  either the full GBeanName, or only the value for the
-                  "name=" portion of the GBeanName.  If there are multiple
-                  GBeans in the module with manageable attributes and
-                  the same "name=" portion of the GBeanName, then all must be
-                  listed and all must be listed with a full GBeanName.
+                Note that the name attribute for a gbean element may hold
+                either the full GBeanName, or only the value for the
+                "name=" portion of the GBeanName.  If there are multiple
+                GBeans in the module with manageable attributes and
+                the same "name=" portion of the GBeanName, then all must be
+                listed and all must be listed with a full GBeanName.
                 ]]>
             </xsd:documentation>
         </xsd:annotation>
@@ -114,4 +115,5 @@
         </xsd:sequence>
         <xsd:attribute name="name" type="xsd:string"/>
     </xsd:complexType>
-  </xsd:schema>
+
+</xsd:schema>

Added: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java?view=auto&rev=454011
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java Sat Oct  7 13:28:45 2006
@@ -0,0 +1,95 @@
+/*
+ * 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.geronimo.system.configuration.condition;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+/**
+ * Unit tests for the {@link JexlConditionParser} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JexlConditionParserTest
+    extends TestSupport
+{
+    private JexlConditionParser parser;
+
+    protected void setUp() throws Exception {
+        parser = new JexlConditionParser();
+    }
+
+    protected void tearDown() throws Exception {
+        parser = null;
+    }
+
+    public void testTrue() throws Exception {
+        boolean result = parser.evaluate("true");
+        assertTrue(result);
+    }
+
+    public void testFalse() throws Exception {
+        boolean result = parser.evaluate("false");
+        assertTrue(!result);
+    }
+
+    public void testJavaIs1_1() throws Exception {
+        //
+        // Assume we never run in a 1.1 jvm
+        //
+        assertTrue(!SystemUtils.IS_JAVA_1_1);
+        boolean result = parser.evaluate("!java.is1_1");
+        assertTrue(result);
+    }
+
+    public void testJavaIs1_5() throws Exception {
+        boolean result = parser.evaluate("java.is1_5 " + (SystemUtils.IS_JAVA_1_5 ? "==" : "!=") + " true");
+        assertTrue(result);
+    }
+
+    public void testNonBooleanResult() throws Exception {
+        try {
+            parser.evaluate("java");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+
+    public void testBadSyntax() throws Exception {
+        try {
+            parser.evaluate("a b c d e f");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+
+    public void testInvalidVariableRef() throws Exception {
+        try {
+            parser.evaluate("nosuchvar");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/JexlConditionParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java?view=auto&rev=454011
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java Sat Oct  7 13:28:45 2006
@@ -0,0 +1,95 @@
+/*
+ * 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.geronimo.system.configuration.condition;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+/**
+ * Unit tests for the {@link OgnlConditionParser} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OgnlConditionParserTest
+    extends TestSupport
+{
+    private OgnlConditionParser parser;
+
+    protected void setUp() throws Exception {
+        parser = new OgnlConditionParser();
+    }
+
+    protected void tearDown() throws Exception {
+        parser = null;
+    }
+
+    public void testTrue() throws Exception {
+        boolean result = parser.evaluate("true");
+        assertTrue(result);
+    }
+
+    public void testFalse() throws Exception {
+        boolean result = parser.evaluate("false");
+        assertTrue(!result);
+    }
+
+    public void testJavaIs1_1() throws Exception {
+        //
+        // Assume we never run in a 1.1 jvm
+        //
+        assertTrue(!SystemUtils.IS_JAVA_1_1);
+        boolean result = parser.evaluate("!java.is1_1");
+        assertTrue(result);
+    }
+
+    public void testJavaIs1_5() throws Exception {
+        boolean result = parser.evaluate("java.is1_5 " + (SystemUtils.IS_JAVA_1_5 ? "==" : "!=") + " true");
+        assertTrue(result);
+    }
+
+    public void testNonBooleanResult() throws Exception {
+        try {
+            parser.evaluate("java");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+
+    public void testBadSyntax() throws Exception {
+        try {
+            parser.evaluate("a b c d e f");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+
+    public void testInvalidVariableRef() throws Exception {
+        try {
+            parser.evaluate("nosuchvar");
+            fail();
+        }
+        catch (ConditionParserException e) {
+            // expected
+        }
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/condition/OgnlConditionParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=454011&r1=454010&r2=454011
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Sat Oct  7 13:28:45 2006
@@ -556,7 +556,19 @@
                 <artifactId>commons-fileupload</artifactId>
                 <version>1.1.1</version>
             </dependency>
-
+            
+            <dependency>
+                <groupId>commons-jexl</groupId>
+                <artifactId>commons-jexl</artifactId>
+                <version>1.1</version>
+            </dependency>
+            
+            <dependency>
+                <groupId>ognl</groupId>
+                <artifactId>ognl</artifactId>
+                <version>2.6.9</version>
+            </dependency>
+            
             <dependency>
                 <groupId>xml-apis</groupId>
                 <artifactId>xml-apis</artifactId>