Author: jkaputin
Date: Fri May  4 09:56:27 2007
New Revision: 535327

URL: http://svn.apache.org/viewvc?view=rev&rev=535327
Log:
WODEN-122 support for the EBNF grammar defined 
for http location.

Modified:
    
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/http/HTTPLocation.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java

Modified: 
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/http/HTTPLocation.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/http/HTTPLocation.java?view=diff&rev=535327&r1=535326&r2=535327
==============================================================================
--- 
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/http/HTTPLocation.java
 (original)
+++ 
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/http/HTTPLocation.java
 Fri May  4 09:56:27 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.woden.wsdl20.extensions.http;
 
-import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -70,8 +69,8 @@
     private String fOriginalLocation;
     boolean fValid = true;
     
-    private List fValidatedList = new Vector(); //identifies syntax errors in 
the template
-    private List fParsedList = new Vector();    //working list for value 
substitution
+    private List fValidatedList = null; //used for validating the HTTP 
location string
+    private List fConsolidatedList = null; //used for substitution and 
formatting
     
     private final String emptyString = "".intern();
     private final String questionMark = "?".intern();
@@ -80,8 +79,6 @@
     private final String doubleLeftBraces = "{{".intern();
     private final String doubleRightBraces = "}}".intern();
     private final String exclamatedLeftBrace = "{!".intern();
-    private final List curlyBraces = Arrays.asList(new String[] {
-            leftBrace, rightBrace, doubleLeftBraces, doubleRightBraces, 
exclamatedLeftBrace});
     
     /**
      * Creates an HTTPLocation object to represent the specified HTTP Location 
String value.
@@ -99,13 +96,15 @@
             //TODO throw NPE with suitable error message
             fValid = false;
         } else if(location.equals(emptyString)) {
+            fValidatedList = new Vector();
             fValidatedList.add(emptyString);
-            fParsedList.add(emptyString);
+            fConsolidatedList = new Vector();
+            fConsolidatedList.add(emptyString);
         } else {
-            List tokenizedList = tokenizeTemplate();
-            validateTemplate(tokenizedList);
-            if(fValidatedList.size() > 0) {
-                parseTemplate();
+            List tokenizedList = tokenizeLocation();
+            validateTokens(tokenizedList);
+            if(fValid) {
+                consolidateTokens();
             }
         }
     }
@@ -142,14 +141,20 @@
      * If the original HTTP Location does not contain any templates then 
substitution 
      * is not applicable and this method will return the same String returned 
by the 
      * <code>getOriginalLocation()</code> method.
+     * <p>
+     * If the HTTP Locationis invalid this method will return null.
      * 
      * @return the formatted HTTP Location String, after any template 
substitution
      */
     public String getFormattedLocation() {
+        if(!fValid) {
+            return null;
+        }
+        
         StringBuffer buffer = new StringBuffer();
         Object currToken;
         HTTPLocationTemplate template;
-        Iterator it = fParsedList.iterator();
+        Iterator it = fConsolidatedList.iterator();
         
         while(it.hasNext()) {
             currToken = it.next();
@@ -180,17 +185,21 @@
     /**
      * Return the templates that appear in the HTTP Location string in
      * the order they appear.
+     * If the HTTP Location contains no templates or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return an array of HTTPLocationTemplate objects
      */
     public HTTPLocationTemplate[] getTemplates() {
         List templates = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                templates.add(next);
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    templates.add(next);
+                }
             }
         }
         
@@ -203,19 +212,23 @@
      * Return the templates that appear in the URI Path portion of the HTTP 
Location
      * string in the order they appear.
      * This is the portion before the first occurrence of '?'.
+     * If the HTTP Location contains no templates in the Path or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return an array of HTTPLocationTemplate objects
      */
     public HTTPLocationTemplate[] getTemplatesInPath() {
         List templates = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                HTTPLocationTemplate template = (HTTPLocationTemplate)next;
-                if(!template.isQuery()) {
-                    templates.add(next);
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    HTTPLocationTemplate template = (HTTPLocationTemplate)next;
+                    if(!template.isQuery()) {
+                        templates.add(next);
+                    }
                 }
             }
         }
@@ -229,19 +242,23 @@
      * Return templates that appear in the URI Query portion of the HTTP 
Location 
      * string in the order they appear. 
      * This is the portion after the first occurrence of '?'.
+     * If the HTTP Location contains no templates in the Query or if it is 
+     * invalid this method will return an empty array.
      *  
      * @return an array of HTTPLocationTemplate objects
      */
     public HTTPLocationTemplate[] getTemplatesInQuery() {
         List templates = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                HTTPLocationTemplate template = (HTTPLocationTemplate)next;
-                if(template.isQuery()) {
-                    templates.add(next);
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    HTTPLocationTemplate template = (HTTPLocationTemplate)next;
+                    if(template.isQuery()) {
+                        templates.add(next);
+                    }
                 }
             }
         }
@@ -253,19 +270,23 @@
     
     /**
      * Return the names of the templates that appear in the HTTP Location 
string
-     * in the order they appear.
+     * in the order they appear. 
+     * If the HTTP Location contains no templates or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return a String array of template names
      */
     public String[] getTemplateNames() {
         List names = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                HTTPLocationTemplate template = (HTTPLocationTemplate)next;
-                names.add(template.getName());
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    HTTPLocationTemplate template = (HTTPLocationTemplate)next;
+                    names.add(template.getName());
+                }
             }
         }
         
@@ -278,20 +299,24 @@
      * Return the names of the templates that appear in the URI Path portion 
of the
      * HTTP Location string in the order they appear.
      * This is the portion before the first occurrence of '?'.
+     * If the HTTP Location contains no templates in the Path or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return a String array of template names
      */
     public String[] getTemplateNamesInPath() {
         List names = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                HTTPLocationTemplate template = (HTTPLocationTemplate)next;
-                if(!template.isQuery()) {
-                    names.add(template.getName());
-               }
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    HTTPLocationTemplate template = (HTTPLocationTemplate)next;
+                    if(!template.isQuery()) {
+                        names.add(template.getName());
+                    }
+                }
             }
         }
         
@@ -304,20 +329,24 @@
      * Return the names of the templates that appear in the URI Query portion 
of the 
      * HTTP Location string in the order they appear. 
      * This is the portion after the first occurrence of '?'.
+     * If the HTTP Location contains no templates in the Query or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return a String array of template names
      */
     public String[] getTemplateNamesInQuery() {
         List names = new Vector();
         
-        Iterator it = fParsedList.iterator();
-        while(it.hasNext()) {
-            Object next = it.next();
-            if(next instanceof HTTPLocationTemplate) {
-                HTTPLocationTemplate template = (HTTPLocationTemplate)next;
-                if(template.isQuery()) {
-                    names.add(template.getName());
-               }
+        if(fValid) {
+            Iterator it = fConsolidatedList.iterator();
+            while(it.hasNext()) {
+                Object next = it.next();
+                if(next instanceof HTTPLocationTemplate) {
+                    HTTPLocationTemplate template = (HTTPLocationTemplate)next;
+                    if(template.isQuery()) {
+                        names.add(template.getName());
+                    }
+                }
             }
         }
         
@@ -327,11 +356,18 @@
     }
 
     /**
-     * Return the first template with the specified name from the HTTP 
Location string.
+     * Return the first template with the specified name from the HTTP 
Location string
+     * or null if no such template is exists.
+     * <p>
+     * If the HTTP Location is invalid this method will return null.
      * 
      * @return an HTTPLocationTemplate with the specified name
      */
     public HTTPLocationTemplate getTemplate(String name) {
+        if(!fValid) {
+            return null;
+        }
+        
         HTTPLocationTemplate namedTemplate = null;
         if(name != null) {
             HTTPLocationTemplate[] templates = getTemplates();
@@ -347,12 +383,15 @@
     
     /**
      * Return the templates with the specified name from the HTTP Location 
string .
+     * If the HTTP Location contains no such templates or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return an array of HTTPLocationTemplates with the specified name
      */
     public HTTPLocationTemplate[] getTemplates(String name) {
         List namedTemplates = new Vector();
-        if(name != null) {
+        
+        if(fValid && name != null) {
             HTTPLocationTemplate[] templates = getTemplates();
             for(int i=0; i<templates.length; i++) {
                 if(templates[i].getName().equals(name)) {
@@ -368,11 +407,18 @@
     
     /**
      * Return the first template with the specified name from the URI Path 
portion of
-     * the HTTP Location string. This is the portion before the first 
occurrence of '?'.
+     * the HTTP Location string or null if no such template exists. 
+     * The Path is the portion before the first occurrence of '?'.
+     * <p>
+     * If the HTTP Location is invalid this method will return null.
      * 
      * @return an HTTPLocationTemplate with the specified name
      */
     public HTTPLocationTemplate getTemplateInPath(String name) {
+        if(!fValid) {
+            return null;
+        }
+        
         HTTPLocationTemplate namedTemplate = null;
         if(name != null) {
             HTTPLocationTemplate[] templates = getTemplatesInPath();
@@ -389,12 +435,15 @@
     /**
      * Return the templates with the specified name from the URI Path portion 
of the
      * HTTP Location string. This is the portion before the first occurrence 
of '?'.
+     * If the HTTP Location contains no such templates in the Path or if it is 
+     * invalid this method will return an empty array.
      * 
      * @return an array of HTTPLocationTemplates with the specified name
      */
     public HTTPLocationTemplate[] getTemplatesInPath(String name) {
         List namedTemplates = new Vector();
-        if(name != null) {
+        
+        if(fValid && name != null) {
             HTTPLocationTemplate[] templates = getTemplatesInPath();
             for(int i=0; i<templates.length; i++) {
                 if(templates[i].getName().equals(name)) {
@@ -410,11 +459,18 @@
     
     /**
      * Return the first template with the specified name from the URI Query 
portion of
-     * the HTTP Location string. This is the portion after the first 
occurrence of '?'.
+     * the HTTP Location string or null if no such template exists. 
+     * The Query is the portion after the first occurrence of '?'.
+     * <p>
+     * If the HTTP Location is invalid this method will return null.
      * 
      * @return an HTTPLocationTemplate with the specified name
      */
     public HTTPLocationTemplate getTemplateInQuery(String name) {
+        if(!fValid) {
+            return null;
+        }
+        
         HTTPLocationTemplate namedTemplate = null;
         if(name != null) {
             HTTPLocationTemplate[] templates = getTemplatesInQuery();
@@ -431,12 +487,15 @@
     /**
      * Return the templates with the specified name from the URI Query portion 
of the
      * HTTP Location string. This is the portion after the first occurrence of 
'?'.
+     * If the HTTP Location contains no such templates in the Query or if it 
is 
+     * invalid this method will return an empty array.
      * 
      * @return an array of HTTPLocationTemplates with the specified name
      */
     public HTTPLocationTemplate[] getTemplatesInQuery(String name) {
         List namedTemplates = new Vector();
-        if(name != null) {
+        
+        if(fValid && name != null) {
             HTTPLocationTemplate[] templates = getTemplatesInQuery();
             for(int i=0; i<templates.length; i++) {
                 if(templates[i].getName().equals(name)) {
@@ -452,15 +511,19 @@
     
     
     /*
-     * TODO - for WODEN-148, fully support the EBNF grammar in this parsing 
logic
-     * 
-     * Scan location char by char left to right. Add {!, {, }, {{ or }} or any
-     * string between these add as tokens in a new ordered list. Also, scan for
-     * the first occurrence of the '?' character, which separates
-     * the path from the query, and add this to the list. 
-     * Return this new tokenized list to be used as input to the template 
validation step.
+     * Scan the original HTTP Location string char by char, left to right, 
looking for the
+     * following string tokens:
+     *   "{{" - literal open brace
+     *   "}}" - literal close brace
+     *   "{!" - start raw template
+     *   "{"  - start encoded template
+     *   "}"  - end template
+     *   First occurrence of "?" - start of Query string
+     *   Any other string
+     *   
+     * Add these tokens to a list to be used as input to the validation step.
      */
-    private List tokenizeTemplate() {
+    private List tokenizeLocation() {
         
         StringBuffer buffer = new StringBuffer();
         int len = fOriginalLocation.length();
@@ -485,10 +548,10 @@
                 }
                 if(i < lastPos && fOriginalLocation.charAt(i+1) == '{') {
                     tokens.add(doubleLeftBraces);
-                    i++;   //continue scan from the 2nd left curly brace
+                    i++;   //move scan position to the 2nd left curly brace
                 } else if(i < lastPos && fOriginalLocation.charAt(i+1) == '!') 
{
                     tokens.add(exclamatedLeftBrace);
-                    i++;   //continue scan from the exclamation mark
+                    i++;   //move scan position to the exclamation mark
                 } else {
                     tokens.add(leftBrace);
                 }
@@ -499,7 +562,7 @@
                 }
                 if(i < lastPos && fOriginalLocation.charAt(i+1) == '}') {
                     tokens.add(doubleRightBraces);
-                    i++;   //move loop position to the 2nd right curly brace
+                    i++;   //move scan position to the 2nd right curly brace
                 } else {
                     tokens.add(rightBrace);
                 }
@@ -517,35 +580,44 @@
     }
 
     /*
-     * Identify any encoded or raw templates and check that their enclosed 
string is of type
-     * xs:NCName (i.e. the type required for an element local name).
-     * Encoded templates have a matching pairs of left and right curly braces 
"{...}".
-     * Raw templates have an exclamated left brace and a right brace "{!...}".
-     * 
-     * TODO modify the validation logic below to match the EBNF grammar added 
to the spec. WODEN-148
+     * The EBNF grammar defined for HTTP Location in WSDL 2.0 spec Part2 
Section 6.8.1.1 is:
      * 
-     * If multiple left braces precede a right brace, pair the right most one 
with the right brace
-     * and treat the others as unmatched left braces. 
-     * If multiple right braces follow a left brace, pair the left most one 
with the left brace
-     * and treat the others as unmatched right braces.
-     * Any unmatched left or right braces are added to the output list. Their 
presence in this list
-     * can be used later to identify this type of error.
+     * httpLocation ::= charData? (( openBrace | closeBrace | template ) 
charData?)*
+     * charData ::= [^{}]*
+     * openBrace ::= '{{'
+     * closeBrace ::= '}}'
+     * template ::= rawTemplate | encodedTemplate
+     * rawTemplate ::= '{!' NCName '}'
+     * encodedTemplate ::= '{' NCName '}' 
+     * 
+     * The input to this method is an ordered list consisting of the following 
tokens parsed 
+     * from the original HTTP Location string: '{{', '}}', '{!', '{', '}', 
first occurrence of ?, 
+     * any other string.
+     * 
+     * This method will validate these tokens according to the EBNF grammar 
above. That is,
+     * it will do the following checks in order against each token, stopping 
and moving on 
+     * to the next token if any check is satisfied:
+     * 1) check for a '?' indicating the start of the URI Query string
+     * 2) check for the openBrace '{{'
+     * 3) check for the closeBrace '}}'
+     * 4) check for a rawTemplate, based on the sequence of tokens '{!', 
NCName, '}' 
+     * 5) check for an encodedTemplate, based on the sequence of tokens '{', 
NCName, '}'
+     * 6) check that any remaining string is valid charData (has no curly 
braces).
      * 
-     * Replace curly brace-enclosed strings with an HTTPLocationTemplate 
object in the output list.
-     * If the enclosed string is not of type NCName, add it to the output list 
as a single string
-     * with its enclosing left and right braces (e.g. "{invalid:name}"). This 
type of string can be
-     * used later to identify this type of error.
-     * 
-     * Any double curly braces '{{' or '}}' are copied directly to the output 
list.
-     * Any other strings in the input list are also copied directly to the 
output list.
+     * Encoded templates have a matching pairs of left and right curly braces 
"{...}".
+     * Raw templates have an exclamated left brace and a right brace "{!...}".
+     * The NCName string in a raw or encoded template must be of type 
xs:NCName 
+     * (that is, xs:NCName is the type defined for the local name of an XML 
element).
      * 
-     * This output list of valid and in-error items can be used to identify 
particular types of 
-     * errors present in the template and is also used as input to the final 
parsing step. 
+     * Valid tokens will be copied to a 'validated' list. The tokens 
comprising any raw or encoded
+     * templates identified at steps 3) or 4) will be replaced in this new 
list by 
+     * HTTPLocationTemplate objects. 
      * 
+     * If an error is found, the HTTP Location will be flagged as invalid and 
no formatted location
+     * or templates will be available.
      */
-    private void validateTemplate(List tokenizedList) {
+    private void validateTokens(List tokenizedList) {
         
-        boolean valid = true;
         List tokens = new Vector();
         Object currToken;
         String nextToken;
@@ -554,66 +626,64 @@
         ListIterator it = tokenizedList.listIterator();
         boolean isQuery = false;
         
-        while(it.hasNext()) {
+        while(fValid && it.hasNext()) {
             currToken = it.next();
             int currIndex = it.previousIndex();
-            if(currToken == leftBrace || currToken == exclamatedLeftBrace) {
+            
+            if(currToken == questionMark) {
+                // 1) check for a '?' indicating the start of the URI Query 
string
+                isQuery = true;
+                tokens.add(questionMark);
+            } else if(currToken == doubleLeftBraces || currToken == 
doubleRightBraces) {
+                // 2) check for the openBrace '{{'
+                // 3) check for the closeBrace '}}'
+                tokens.add(currToken);
+            } else if(currToken == leftBrace || currToken == 
exclamatedLeftBrace) {
+                // 4) check for a rawTemplate, based on the sequence of tokens 
'{!', NCName, '}' 
+                // 5) check for an encodedTemplate, based on the sequence of 
tokens '{', NCName, '}'
                 if(size-currIndex < 3) {
-                    valid = false; //left brace or exclamated left brace not 
followed by a name and a right brace
-                    tokens.add(currToken);
+                    fValid = false; //this token is not followed by two 
further tokens 
                 } else {
-                    nextToken = (String)tokenizedList.get(currIndex+1);
-                    nextNextToken = tokenizedList.get(currIndex+2);
-                    if(!curlyBraces.contains(nextToken) && nextNextToken == 
rightBrace) {
-                        //we have a string enclosed by a pair of left and 
right curly braces
-                        if(NCName.isValid(nextToken)) {
-                            boolean isEncoded = (currToken == leftBrace);
-                            HTTPLocationTemplate template = 
-                                new HTTPLocationTemplate(nextToken, isEncoded, 
isQuery);
-                            tokens.add(template);
-                        } else {
-                            valid = false; //invalid format for a local name
-                            StringBuffer buffer = new StringBuffer(leftBrace);
-                            buffer.append(nextToken);
-                            buffer.append(rightBrace);
-                            tokens.add(buffer.toString());
-                        }
-                        it.next(); //local name
-                        it.next(); //right curly brace
+                    nextToken = (String)it.next();
+                    nextNextToken = it.next();
+                    if(NCName.isValid(nextToken) && nextNextToken == 
rightBrace) {
+                        boolean isEncoded = (currToken == leftBrace);
+                        HTTPLocationTemplate template = 
+                            new HTTPLocationTemplate(nextToken, isEncoded, 
isQuery);
+                        tokens.add(template);
                     } else {
-                        //TODO handle a string containing double curly brace 
as an invalid local name, not an unmatched left brace.
-                        valid = false; //left brace not followed by a name and 
a right brace
-                        tokens.add(leftBrace);
+                        fValid = false; //we don't have a valid template
                     }
                 }
-            } else if(currToken == rightBrace) {
-                //right brace not preceded by a name and a left brace
-                valid = false;
-                tokens.add(rightBrace);
-            } else if(currToken == questionMark) {
-                isQuery = true; //this marks the start of the query string
-                tokens.add(questionMark);
             } else {
-                //This token is double left or double right curly braces or 
some string
-                //other than "{", "{!", "}" or "?".
-                tokens.add(currToken);
+                // 6) check that any other type of token is valid charData 
(has no curly braces).
+                String s = (String)currToken;
+                int index = s.indexOf(leftBrace);
+                if(index < 0) {
+                    index = s.indexOf(rightBrace);
+                }
+                if(index >= 0) {
+                    fValid = false; //contains unmatched curly braces
+                } else {
+                    tokens.add(currToken);
+                }
             }
-            
         } //end while loop
-        
-        fValid = valid;
-        fValidatedList = tokens;
+
+        if(fValid) {
+            fValidatedList = tokens;
+        }
     }
     
     /*
-     * Create a final parsed list of items from the location template, which 
can be used
-     * for value substitution and for creating the external representation of 
the 
-     * location after substitution. The output list will contain just 
HTTPLocationTemplate
-     * object and strings concatenating any other content that appears between 
templates. 
-     * These string concatentations will include any double curly braces, 
replaced by a single brace. 
-     * They will also include any invalid curly brace-enclosed strings (e.g. 
"{invalid:name}").
+     * Consolidate the validated tokens parsed from the HTTP Location string, 
into a list containing
+     * only HTTPLocationTemplate objects, literal single braces or Strings 
representing any other 
+     * HTTP Location content.  This consolidated list will be used for 
template substitution 
+     * and for producing an external representation of the HTTP Location 
string, formatted with the 
+     * substituted values. 
+     * Note, any double curly braces will be replaced by a literal single 
brace. 
      */
-    private void parseTemplate() {
+    private void consolidateTokens() {
         
         StringBuffer buffer = new StringBuffer();
         Object currToken;
@@ -623,8 +693,7 @@
         while(it.hasNext()) {
             currToken = it.next();
             if(currToken instanceof HTTPLocationTemplate) {
-                //This is a templated local name, so output any previously 
concatentated
-                //string content then output this template.
+                //Output any previously concatentated string content then 
output this template's value.
                 if(buffer.length() > 0) {
                     tokens.add(buffer.toString());
                     buffer = new StringBuffer();
@@ -635,7 +704,7 @@
             } else if(currToken == doubleRightBraces) {
                 buffer.append(rightBrace);
             } else {
-                //just append this to any previous string content
+                //concatentate this token to previous string content
                 buffer.append(currToken);
             }
         }
@@ -644,7 +713,7 @@
             tokens.add(buffer.toString());
         }
         
-        fParsedList = tokens;
+        fConsolidatedList = tokens;
     }
     
 }

Modified: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java?view=diff&rev=535327&r1=535326&r2=535327
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java
 (original)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java
 Fri May  4 09:56:27 2007
@@ -83,6 +83,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplates();
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        templates = loc.getTemplates();
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplatesInPath_noArg() {
@@ -99,6 +103,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplatesInPath();
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/{localname}?abc");
+        templates = loc.getTemplatesInPath();
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplatesInQuery_noArg() {
@@ -115,6 +123,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplatesInQuery();
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        templates = loc.getTemplatesInQuery();
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplates_oneArg() {
@@ -137,6 +149,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplates("dummy");
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        templates = loc.getTemplates("localname");
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplatesInPath_oneArg() {
@@ -160,6 +176,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplatesInPath("dummy");
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/{localname}?abc");
+        templates = loc.getTemplatesInPath("localname");
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplatesInQuery_oneArg() {
@@ -183,6 +203,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         templates = loc.getTemplatesInQuery("dummy");
         assertEquals("Unexpected templates", 0, templates.length);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        templates = loc.getTemplatesInQuery("localname");
+        assertEquals("Location is invalid, so no templates were expected", 0, 
templates.length);
     }    
         
     public void testGetTemplate() {
@@ -207,6 +231,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         template = loc.getTemplate("dummy");
         assertNull("Unexpected template", template);
+        
+        loc = new HTTPLocation("/in}valid/{localname}");
+        template = loc.getTemplate("localname");
+        assertNull("Location is invalid, so null was expected", template);
     }    
         
     public void testGetTemplateInPath() {
@@ -230,6 +258,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         template = loc.getTemplateInPath("dummy");
         assertNull("Unexpected template", template);
+        
+        loc = new HTTPLocation("/in}valid/{localname}?abc");
+        template = loc.getTemplateInPath("localname");
+        assertNull("Location is invalid, so null was expected", template);
     }    
         
     public void testGetTemplateInQuery() {
@@ -253,6 +285,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         template = loc.getTemplateInQuery("dummy");
         assertNull("Unexpected template", template);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        template = loc.getTemplateInQuery("localname");
+        assertNull("Location is invalid, so null was expected", template);
     }    
         
     public void testGetTemplateNames() {
@@ -273,6 +309,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         names = loc.getTemplateNames();
         assertEquals("Unexpected template names", 0, names.length);
+        
+        loc = new HTTPLocation("/in}valid/{localname}");
+        names = loc.getTemplateNames();
+        assertEquals("Location is invalid, so no template names were 
expected", 0, names.length);
     }    
         
     public void testGetTemplateNamesInPath() {
@@ -289,6 +329,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         names = loc.getTemplateNamesInPath();
         assertEquals("Unexpected template names", 0, names.length);
+        
+        loc = new HTTPLocation("/in}valid/{localname}?abc");
+        names = loc.getTemplateNamesInPath();
+        assertEquals("Location is invalid, so no template names were 
expected", 0, names.length);
     }    
         
     public void testGetTemplateNamesInQuery() {
@@ -307,6 +351,10 @@
         loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
         names = loc.getTemplateNamesInQuery();
         assertEquals("Unexpected template names", 0, names.length);
+        
+        loc = new HTTPLocation("/in}valid/abc?{localname}");
+        names = loc.getTemplateNamesInQuery();
+        assertEquals("Location is invalid, so no template names were 
expected", 0, names.length);
     }    
         
     public void testGetOriginalLocation() {
@@ -370,6 +418,11 @@
         loc = new HTTPLocation(origLoc);
         returnedLoc = loc.getFormattedLocation();
         assertEquals("Unexpected location value", origLoc, returnedLoc);
+        
+        origLoc = "{invalid:name}";
+        loc = new HTTPLocation(origLoc);
+        returnedLoc = loc.getFormattedLocation();
+        assertNull("Location is invalid, so null was expected", returnedLoc);
     }
     
     public void testToString() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to