You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cr...@apache.org on 2006/11/17 07:53:56 UTC

svn commit: r476063 - in /beehive/trunk/netui: src/compiler-core/org/apache/beehive/netui/compiler/ src/compiler-core/org/apache/beehive/netui/compiler/grammar/ test/src/compilerTests/testsuite/Jira1158/ test/src/compilerTests/testsuite/Jira1158/Jira11...

Author: crogers
Date: Thu Nov 16 22:53:55 2006
New Revision: 476063

URL: http://svn.apache.org/viewvc?view=rev&rev=476063
Log:
Fix for BEEHIVE-1158. The ValidXmlFileType.onCheck() override will report an error if the path is an empty string. A new compiler test has also been created for empty string error conditions with the strutsMerge and validatorMerge property.

Tests: NetUI BVT (WinXP passed)


Added:
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java   (with props)
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/index.jsp   (with props)
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/
    beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected   (with props)
Modified:
    beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
    beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidXmlFileType.java

Modified: beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java?view=diff&rev=476063&r1=476062&r2=476063
==============================================================================
--- beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java (original)
+++ beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java Thu Nov 16 22:53:55 2006
@@ -18,6 +18,18 @@
  */
 package org.apache.beehive.netui.compiler;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+
 import org.apache.beehive.netui.compiler.typesystem.declaration.*;
 import org.apache.beehive.netui.compiler.typesystem.env.CoreAnnotationProcessorEnv;
 import org.apache.beehive.netui.compiler.typesystem.env.Filer;
@@ -31,18 +43,6 @@
 import org.apache.beehive.netui.compiler.typesystem.type.TypeVariable;
 import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition;
 
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-
 
 public class CompilerUtils
         implements JpfLanguageConstants
@@ -1190,7 +1190,7 @@
                                                     CoreAnnotationProcessorEnv env )
             throws FatalCompileTimeException
     {
-        assert relativePath.length() > 0;
+        if (relativePath.length() == 0) return null;
         
         //
         // If it starts with '/', just find the webapp-relative file.

Modified: beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidXmlFileType.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidXmlFileType.java?view=diff&rev=476063&r1=476062&r2=476063
==============================================================================
--- beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidXmlFileType.java (original)
+++ beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidXmlFileType.java Thu Nov 16 22:53:55 2006
@@ -18,26 +18,30 @@
  */
 package org.apache.beehive.netui.compiler.grammar;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.apache.beehive.netui.compiler.AnnotationGrammar;
+import org.apache.beehive.netui.compiler.FatalCompileTimeException;
 import org.apache.beehive.netui.compiler.FlowControllerInfo;
 import org.apache.beehive.netui.compiler.LocalFileEntityResolver;
+import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
+import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
+import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 import org.w3c.dom.Document;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 
 /**
  * A type that requires a valid XML file.  Can accept a specific XML schema, and will fall back to DTD-checking.
@@ -55,6 +59,23 @@
         _schemaFileName = schemaFileName;
     }
 
+    public Object onCheck(AnnotationTypeElementDeclaration valueDecl,
+                          AnnotationValue value,
+                          AnnotationInstance[] parentAnnotations,
+                          MemberDeclaration classMember,
+                          int annotationArrayIndex) throws FatalCompileTimeException {
+        // report an error if the path is an empty string
+        String filePath = (String) value.getValue();
+        if (filePath == null) {
+            return null;
+        }
+        else if (filePath.length() == 0) {
+            addError(value, "error.file-not-found", filePath);
+            return null;
+        }
+
+        return super.onCheck(valueDecl, value, parentAnnotations, classMember, annotationArrayIndex);
+    }
 
     protected boolean checkAnyExtension()
     {
@@ -82,7 +103,6 @@
 
     protected void runAdditionalChecks( File file, AnnotationValue value )
     {
-
         //
         // We cache the results of parsing the file until the file is actually modified,
         // so we don't end up continually re-parsing it.

Added: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java?view=auto&rev=476063
==============================================================================
--- beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java (added)
+++ beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java Thu Nov 16 22:53:55 2006
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * $Header:$
+ */
+package Jira1158;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+/*
+ * Test error failure for an empty String in the strutsMerge
+ * and validatorMerge properties of the @Jpf.Controller annotation.
+ */
+@Jpf.Controller(
+    strutsMerge = "",
+    validatorMerge = "",
+    simpleActions={
+        @Jpf.SimpleAction(name="begin", path="index.jsp")
+    }
+)
+public class Controller extends PageFlowController
+{
+}

Propchange: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/Controller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/index.jsp
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/index.jsp?view=auto&rev=476063
==============================================================================
    (empty)

Propchange: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/Jira1158/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected?view=auto&rev=476063
==============================================================================
--- beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected (added)
+++ beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected Thu Nov 16 22:53:55 2006
@@ -0,0 +1,7 @@
+[LOCAL_PATH]\WEB-INF\.tmpbeansrc\Jira1158\Controller.java:35: File "" could not be found in the web application.
+public class Controller extends PageFlowController
+       ^
+[LOCAL_PATH]\WEB-INF\.tmpbeansrc\Jira1158\Controller.java:35: File "" could not be found in the web application.
+public class Controller extends PageFlowController
+       ^
+2 errors

Propchange: beehive/trunk/netui/test/src/compilerTests/testsuite/Jira1158/expectedOutput/warningsorerrors.expected
------------------------------------------------------------------------------
    svn:eol-style = native