You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/03/19 17:54:57 UTC

[1/4] git commit: [OLINGO-207] fix for URI Parser encoding/decoding and service document detection

Repository: incubator-olingo-odata4
Updated Branches:
  refs/heads/olingo-206-validator c0db941b8 -> 99d578194


[OLINGO-207] fix for URI Parser encoding/decoding and service document detection


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/21aa475f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/21aa475f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/21aa475f

Branch: refs/heads/olingo-206-validator
Commit: 21aa475f2c7f98da166b7d46f7fc7e2178ced4dd
Parents: ec39fd6
Author: Sven Kobler <sv...@sap.com>
Authored: Tue Mar 18 15:41:11 2014 +0100
Committer: Sven Kobler <sv...@sap.com>
Committed: Tue Mar 18 15:41:32 2014 +0100

----------------------------------------------------------------------
 .../org/apache/olingo/commons/core/Decoder.java |  90 +++++++++++++
 .../org/apache/olingo/commons/core/Encoder.java | 130 +++++++++++++++++++
 .../apache/olingo/commons/core/DecoderTest.java |  89 +++++++++++++
 .../apache/olingo/commons/core/EncoderTest.java | 106 +++++++++++++++
 .../olingo/server/core/uri/parser/Parser.java   |  21 +--
 .../server/core/uri/parser/UriDecoder.java      |  33 ++---
 .../olingo/server/core/uri/RawUriTest.java      |   2 +
 .../core/uri/antlr/TestFullResourcePath.java    |  27 ++--
 8 files changed, 457 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Decoder.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Decoder.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Decoder.java
new file mode 100644
index 0000000..e7f6656
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Decoder.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.olingo.commons.core;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Decodes a Java String containing a percent-encoded UTF-8 String value
+ * into a Java String (in its internal UTF-16 encoding).
+ * 
+ */
+public class Decoder {
+
+  /**
+   * Decodes a percent-encoded UTF-8 String value into a Java String
+   * (in its internal UTF-16 encoding).
+   * @param value the encoded String
+   * @return the Java String
+   * @throws IllegalArgumentException if value contains characters not representing UTF-8 bytes
+   * or ends with an unfinished percent-encoded character
+   * @throws NumberFormatException if the two characters after a percent character
+   * are not hexadecimal digits
+   */
+  public static String decode(final String value) throws IllegalArgumentException, NumberFormatException {
+    if (value == null) {
+      return value;
+    }
+
+    // Use a tiny finite-state machine to handle decoding on byte level.
+    // There are only three states:
+    // -2: normal bytes
+    // -1: a byte representing the percent character has been read
+    // >= 0: a byte representing the first half-byte of a percent-encoded byte has been read
+    // The variable holding the state is also used to store the value of the first half-byte.
+    byte[] result = new byte[value.length()];
+    int position = 0;
+    byte encodedPart = -2;
+    for (final char c : value.toCharArray()) {
+      if (c <= Byte.MAX_VALUE) {
+        if (c == '%') {
+          if (encodedPart == -2) {
+            encodedPart = -1;
+          } else {
+            throw new IllegalArgumentException();
+          }
+        } else if (encodedPart == -1) {
+          encodedPart = (byte) c;
+        } else if (encodedPart >= 0) {
+          final int i = Integer.parseInt(String.valueOf(new char[] { (char) encodedPart, c }), 16);
+          if (i >= 0) {
+            result[position++] = (byte) i;
+          } else {
+            throw new NumberFormatException();
+          }
+          encodedPart = -2;
+        } else {
+          result[position++] = (byte) c;
+        }
+      } else {
+        throw new IllegalArgumentException();
+      }
+    }
+
+    if (encodedPart >= 0) {
+      throw new IllegalArgumentException();
+    }
+
+    try {
+      return new String(result, 0, position, "UTF-8");
+    } catch (UnsupportedEncodingException e) {
+      throw new IllegalArgumentException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Encoder.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Encoder.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Encoder.java
new file mode 100644
index 0000000..99ea86a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/Encoder.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.olingo.commons.core;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Encodes a Java String (in its internal UTF-16 encoding) into its
+ * percent-encoded UTF-8 representation according to
+ * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>
+ * (with consideration of its predecessor RFC 2396).
+ * 
+ */
+public class Encoder {
+
+  /**
+   * Encodes a Java String (in its internal UTF-16 encoding) into its
+   * percent-encoded UTF-8 representation according to
+   * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
+   * suitable for parts of an OData path segment.
+   * @param value the Java String
+   * @return the encoded String
+   */
+  public static String encode(final String value) {
+    return encoder.encodeInternal(value);
+  }
+
+  // OData has special handling for "'", so we allow that to remain unencoded.
+  // Other sub-delims not used neither by JAX-RS nor by OData could be added
+  // if the encoding is considered to be too aggressive.
+  // RFC 3986 would also allow the gen-delims ":" and "@" to appear literally
+  // in path-segment parts.
+  private static final String ODATA_UNENCODED = "'";
+
+  // Character classes from RFC 3986
+  private final static String UNRESERVED = "-._~"; // + ALPHA + DIGIT
+  // RFC 3986 says: "For consistency, URI producers and normalizers should
+  // use uppercase hexadecimal digits for all percent-encodings."
+  private final static String[] hex = { "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A",
+      "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A",
+      "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "%2A",
+      "%2B", "%2C", "%2D", "%2E", "%2F", "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", "%38", "%39", "%3A",
+      "%3B", "%3C", "%3D", "%3E", "%3F", "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", "%48", "%49", "%4A",
+      "%4B", "%4C", "%4D", "%4E", "%4F", "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", "%58", "%59", "%5A",
+      "%5B", "%5C", "%5D", "%5E", "%5F", "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", "%68", "%69", "%6A",
+      "%6B", "%6C", "%6D", "%6E", "%6F", "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", "%78", "%79", "%7A",
+      "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88",
+      "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98",
+      "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8",
+      "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8",
+      "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8",
+      "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8",
+      "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8",
+      "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8",
+      "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" };
+
+  private static final Encoder encoder = new Encoder(ODATA_UNENCODED);
+
+  /** characters to remain unencoded in addition to {@link #UNRESERVED} */
+  private final String unencoded;
+
+  private Encoder(final String unencoded) {
+    this.unencoded = unencoded == null ? "" : unencoded;
+  }
+
+  /**
+   * <p>Returns the percent-encoded UTF-8 representation of a String.</p>
+   * <p>In order to avoid producing percent-encoded CESU-8 (as described in
+   * the Unicode Consortium's <a href="http://www.unicode.org/reports/tr26/">
+   * Technical Report #26</a>), this is done in two steps:
+   * <ol>
+   * <li>Re-encode the characters from their Java-internal UTF-16 representations
+   * into their UTF-8 representations.</li>
+   * <li>Percent-encode each of the bytes in the UTF-8 representation.
+   * This is possible on byte level because all characters that do not have
+   * a <code>%xx</code> representation are represented in one byte in UTF-8.</li>
+   * </ol></p>
+   * @param input input String
+   * @return encoded representation
+   */
+  private String encodeInternal(final String input) {
+    StringBuilder resultStr = new StringBuilder();
+
+    try {
+      for (byte utf8Byte : input.getBytes("UTF-8")) {
+        final char character = (char) utf8Byte;
+        if (isUnreserved(character)) {
+          resultStr.append(character);
+        } else if (isUnencoded(character)) {
+          resultStr.append(character);
+        } else if (utf8Byte >= 0) {
+          resultStr.append(hex[utf8Byte]);
+        } else {
+          // case UTF-8 continuation byte
+          resultStr.append(hex[256 + utf8Byte]); // index adjusted for the usage of signed bytes
+        }
+      }
+    } catch (final UnsupportedEncodingException e) { // should never happen; UTF-8 is always there
+      return null;
+    }
+    return resultStr.toString();
+  }
+
+  private static boolean isUnreserved(final char character) {
+    return 'A' <= character && character <= 'Z' // case A..Z
+        || 'a' <= character && character <= 'z' // case a..z
+        || '0' <= character && character <= '9' // case 0..9
+        || UNRESERVED.indexOf(character) >= 0;
+  }
+
+  private boolean isUnencoded(final char character) {
+    return unencoded.indexOf(character) >= 0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/commons-core/src/test/java/org/apache/olingo/commons/core/DecoderTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/DecoderTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/DecoderTest.java
new file mode 100644
index 0000000..78ac9cf
--- /dev/null
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/DecoderTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.olingo.commons.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+/**
+ *  
+ */
+public class DecoderTest {
+
+  @Test
+  public void asciiCharacters() {
+    assertNull(Decoder.decode(null));
+
+    String s = "azAZ019";
+    assertEquals(s, Decoder.decode(s));
+
+    s = "\"\\`{}|";
+    assertEquals(s, Decoder.decode(s));
+  }
+
+  @Test
+  public void asciiControl() {
+    assertEquals("\u0000\b\t\n\r", Decoder.decode("%00%08%09%0a%0d"));
+  }
+
+  @Test
+  public void asciiEncoded() {
+    assertEquals("<>%&", Decoder.decode("%3c%3e%25%26"));
+    assertEquals(":/?#[]@", Decoder.decode("%3a%2f%3f%23%5b%5d%40"));
+    assertEquals(" !\"$'()*+,-.", Decoder.decode("%20%21%22%24%27%28%29%2A%2B%2C%2D%2E"));
+  }
+
+  @Test
+  public void unicodeCharacters() {
+    assertEquals("€", Decoder.decode("%E2%82%AC"));
+    assertEquals("\uFDFC", Decoder.decode("%EF%B7%BC"));
+  }
+
+  @Test
+  public void charactersOutsideBmp() {
+    assertEquals(String.valueOf(Character.toChars(0x1F603)), Decoder.decode("%f0%9f%98%83"));
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void wrongCharacter() {
+    Decoder.decode("%20ä");
+  }
+
+  @Test(expected = NumberFormatException.class)
+  public void wrongPercentNumber() {
+    Decoder.decode("%-3");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void wrongPercentPercent() {
+    Decoder.decode("%%a");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void unfinishedPercent() {
+    Decoder.decode("%a");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void nullByte() {
+    Decoder.decode("%\u0000ff");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/commons-core/src/test/java/org/apache/olingo/commons/core/EncoderTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/EncoderTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/EncoderTest.java
new file mode 100644
index 0000000..8100b81
--- /dev/null
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/EncoderTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.olingo.commons.core;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.junit.Test;
+
+/**
+ * Tests for percent-encoding.
+ * 
+ */
+public class EncoderTest  {
+
+  private final static String RFC3986_UNRESERVED = "-._~"; // + ALPHA + DIGIT
+  private final static String RFC3986_GEN_DELIMS = ":/?#[]@";
+  private final static String RFC3986_SUB_DELIMS = "!$&'()*+,;=";
+  private final static String RFC3986_RESERVED = RFC3986_GEN_DELIMS + RFC3986_SUB_DELIMS;
+
+  @Test
+  public void asciiCharacters() {
+    final String s = "azAZ019";
+    assertEquals(s, Encoder.encode(s));
+    assertEquals(s, Encoder.encode(s));
+  }
+
+  @Test
+  public void asciiControl() {
+    assertEquals("%08%09%0A%0D", Encoder.encode("\b\t\n\r"));
+  }
+
+  @Test
+  public void unsafe() {
+    assertEquals("%3C%3E%25%26", Encoder.encode("<>%&"));
+    assertEquals("%22%5C%60%7B%7D%7C", Encoder.encode("\"\\`{}|"));
+  }
+
+  @Test
+  public void rfc3986Unreserved() {
+    assertEquals(RFC3986_UNRESERVED, Encoder.encode(RFC3986_UNRESERVED));
+  }
+
+  @Test
+  public void rfc3986GenDelims() {
+    assertEquals("%3A%2F%3F%23%5B%5D%40", Encoder.encode(RFC3986_GEN_DELIMS));
+  }
+
+  @Test
+  public void rfc3986SubDelims() {
+    assertEquals("%21%24%26'%28%29%2A%2B%2C%3B%3D", Encoder.encode(RFC3986_SUB_DELIMS));
+  }
+
+  @Test
+  public void rfc3986Reserved() {
+    assertEquals("%3A%2F%3F%23%5B%5D%40%21%24%26'%28%29%2A%2B%2C%3B%3D", Encoder.encode(RFC3986_RESERVED));
+  }
+
+  @Test
+  public void unicodeCharacters() {
+    assertEquals("%E2%82%AC", Encoder.encode("€"));
+    assertEquals("%EF%B7%BC", Encoder.encode("\uFDFC")); // RIAL SIGN
+  }
+
+  @Test
+  public void charactersOutsideBmp() {
+    // Unicode characters outside the Basic Multilingual Plane are stored
+    // in a Java String in two surrogate characters.
+    final String s = String.valueOf(Character.toChars(0x1F603));
+    assertEquals("%F0%9F%98%83", Encoder.encode(s));
+  }
+
+  @Test
+  public void uriDecoding() throws URISyntaxException {
+    final String decodedValue = RFC3986_UNRESERVED + RFC3986_RESERVED + "0..1..a..z..A..Z..@"
+        + "\u2323\uFDFC" + String.valueOf(Character.toChars(0x1F603));
+
+    final String encodedPath = Encoder.encode(decodedValue) + "/" + Encoder.encode(decodedValue);
+    final String encodedQuery = Encoder.encode(decodedValue);
+    final URI uri = new URI("http://host:80/" + encodedPath + "?" + encodedQuery + "=" + encodedQuery);
+
+    assertEquals(uri.getPath(), "/" + decodedValue + "/" + decodedValue);
+    assertEquals(uri.getQuery(), decodedValue + "=" + decodedValue);
+
+    assertEquals(uri.getRawPath(), "/" + encodedPath);
+    assertEquals(uri.getRawQuery(), encodedQuery + "=" + encodedQuery);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index ac2eada..e6a2256 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -1,18 +1,18 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -91,7 +91,10 @@ public class Parser {
         firstSegment = uri.pathSegmentListDecoded.get(0);
       }
 
-      if (firstSegment.startsWith("$batch")) {
+      if (firstSegment.length() == 0) {
+        readQueryParameter = true;
+        context.contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.service);
+      } else if (firstSegment.startsWith("$batch")) {
         BatchEOFContext ctxBatchEOF =
             (BatchEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.Batch);
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
index 9710b24..cf9606c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
@@ -1,25 +1,23 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.olingo.server.core.uri.parser;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
@@ -27,13 +25,14 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.olingo.commons.core.Decoder;
 import org.apache.olingo.server.core.uri.parser.RawUri.QueryOption;
 
 public class UriDecoder {
 
   static Pattern uriPattern = Pattern.compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
 
-  public static RawUri decodeUri(final String uri, final int scipSegments) throws UriParserSyntaxException {
+  public static RawUri decodeUri(final String uri, final int scipSegments) {
     RawUri rawUri = new RawUri();
 
     Matcher m = uriPattern.matcher(uri);
@@ -52,7 +51,7 @@ public class UriDecoder {
     return rawUri;
   }
 
-  private static void decode(final RawUri rawUri) throws UriParserSyntaxException {
+  private static void decode(final RawUri rawUri) {
     rawUri.pathSegmentListDecoded = new ArrayList<String>();
     for (String segment : rawUri.pathSegmentList) {
       rawUri.pathSegmentListDecoded.add(decode(segment));
@@ -119,19 +118,13 @@ public class UriDecoder {
       start = end + 1;
     }
 
-    
     list.add(input.substring(start));
-    
 
     return list;
   }
 
-  public static String decode(final String encoded) throws UriParserSyntaxException {
-    try {
-      return URLDecoder.decode(encoded, "UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new UriParserSyntaxException("Error while decoding");
-    }
+  public static String decode(final String encoded) {
+    return Decoder.decode(encoded);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
index 89c2df7..f100eef 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
@@ -122,6 +122,8 @@ public class RawUriTest {
 
     rawUri = runRawParser("nonServiceSegment/entitySet", 1);
     checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("entitySet"));
+    
+    rawUri = runRawParser("http://test.org/a?abc=xx+yz", 0);
   }
 
   

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/21aa475f/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 7cd16a0..351fd54 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1,29 +1,29 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.olingo.server.core.uri.antlr;
 
 import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.util.Arrays;
 
 import org.apache.olingo.commons.api.ODataApplicationException;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.core.Encoder;
 import org.apache.olingo.server.api.uri.UriInfoKind;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
@@ -2573,7 +2573,10 @@ public class TestFullResourcePath {
   @Test
   public void misc() {
 
-    testUri.run("");
+    testUri.run("")
+        .isKind(UriInfoKind.service);
+    testUri.run("/")
+        .isKind(UriInfoKind.service);
 
     testUri.run("$all")
         .isKind(UriInfoKind.all);
@@ -5079,7 +5082,7 @@ public class TestFullResourcePath {
         + "/com.sap.odata.test1.CTBase/com.sap.odata.test1.CTBase").isExSemantic(0);
 
     testUri.runEx("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav").isExSemantic(0);
-    
+
     // $ref
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$ref").isExSemantic(0);
     testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplexTwoPrim/$count").isExSemantic(0);
@@ -5097,7 +5100,7 @@ public class TestFullResourcePath {
   }
 
   public static String encode(final String decoded) throws UnsupportedEncodingException {
-    return URLEncoder.encode(decoded, "UTF-8");
+    return Encoder.encode(decoded);
 
   }
 


[4/4] git commit: [OLINGO-206] TDD refactoring

Posted by sk...@apache.org.
[OLINGO-206] TDD refactoring


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/99d57819
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/99d57819
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/99d57819

Branch: refs/heads/olingo-206-validator
Commit: 99d578194051e5b891c433fe4101bfae1b04b5d9
Parents: d3d4111
Author: Stephan Klevenz <st...@sap.com>
Authored: Wed Mar 19 17:54:25 2014 +0100
Committer: Stephan Klevenz <st...@sap.com>
Committed: Wed Mar 19 17:54:25 2014 +0100

----------------------------------------------------------------------
 .../olingo/server/api/uri/UriInfoResource.java  |   7 +
 .../olingo/server/core/uri/UriInfoImpl.java     |   5 +
 .../olingo/server/core/uri/parser/Parser.java   |   3 +-
 .../uri/validator/SystemQueryValidator.java     |  89 +++++--
 .../core/uri/validator/UriEdmValidatorTest.java | 236 ++++++++++++++-----
 5 files changed, 269 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/99d57819/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
index cc3077a..5ea67b5 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
@@ -114,5 +114,12 @@ public interface UriInfoResource {
    * @return List of resource parts.
    */
   List<UriResource> getUriResourceParts();
+  
+  /**
+   * Give the last part of a resource path.
+   * 
+   * @return An uri resource object.
+   */
+  UriResource getUriResourceLastPart();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/99d57819/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
index 758d8d9..0e99107 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
@@ -286,4 +286,9 @@ public class UriInfoImpl implements UriInfo {
   public Collection<SystemQueryOption> getSystemQueryOptions() {
     return Collections.unmodifiableCollection(systemQueryOptions.values());
   }
+
+  @Override
+  public UriResource getUriResourceLastPart() {
+    return lastResourcePart;
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/99d57819/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index e6a2256..cdc060e 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -99,6 +99,7 @@ public class Parser {
             (BatchEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.Batch);
 
         uriParseTreeVisitor.visitBatchEOF(ctxBatchEOF);
+        readQueryParameter = true;
       } else if (firstSegment.startsWith("$metadata")) {
         MetadataEOFContext ctxMetadataEOF =
             (MetadataEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.Metadata);
@@ -207,7 +208,7 @@ public class Parser {
 
             context.contextUriInfo.setSystemQueryOption(filterOption);
           } else if (option.name.equals("$search")) {
-            // TODO $search is not supported yet
+            throw new RuntimeException("System query option '$search' not implemented!");
           } else if (option.name.equals("$select")) {
             SelectEOFContext ctxSelectEOF =
                 (SelectEOFContext) parseRule(option.value, ParserEntryRules.Select);

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/99d57819/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
index b37ccde..04efdb1 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
@@ -18,9 +18,12 @@
  */
 package org.apache.olingo.server.core.uri.validator;
 
+import java.util.List;
+
 import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
 
@@ -39,7 +42,9 @@ public class SystemQueryValidator {
           /*                         resource  5 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
           /*                          service  6 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
           /*                        entitySet  7 */ { true ,   true ,   true ,   false,   true ,   true ,    true ,   true ,   true ,   true ,      true ,    true  },
+
           /*                   entitySetCount  8 */ { false,   false,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          
           /*                           entity  9 */ { false,   true ,   true ,   false,   false,   false,    false,   true ,   false,   false,      true ,    false },
           /*                      mediaStream 10 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
           /*                       references 11 */ { true ,   true ,   false,   false,   false,   true ,    true ,   false,   true ,   true ,      false,    true  },
@@ -57,7 +62,7 @@ public class SystemQueryValidator {
 
   public void validate(final UriInfo uriInfo, final Edm edm) throws UriValidationException {
 
-    validateQueryOptions(uriInfo);
+    validateQueryOptions(uriInfo, edm);
     validateKeyPredicateTypes(uriInfo, edm);
 
   }
@@ -108,7 +113,7 @@ public class SystemQueryValidator {
     return idx;
   }
 
-  private int rowIndex(final UriInfo uriInfo) {
+  private int rowIndex(final UriInfo uriInfo, Edm edm) throws UriValidationException {
     int idx;
 
     switch (uriInfo.getKind()) {
@@ -128,7 +133,7 @@ public class SystemQueryValidator {
       idx = 4;
       break;
     case resource:
-      idx = 5;
+      idx = rowIndexForResourceKind(uriInfo, edm);
       break;
     case service:
       idx = 6;
@@ -140,27 +145,77 @@ public class SystemQueryValidator {
     return idx;
   }
 
-  private void validateQueryOptions(final UriInfo uriInfo) throws UriValidationException {
-    try {
-    int row = rowIndex(uriInfo);
+  private int rowIndexForResourceKind(UriInfo uriInfo, Edm edm) throws UriValidationException {
+    int idx = 5;
 
-    for (SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
-      int col = colIndex(option.getKind());
-      
-      System.out.print("[" + row +"][" + col +"]");
+    UriResource lastPathSegemnt = uriInfo.getUriResourceLastPart();
 
-      
-      if (!decisionMatrix[row][col]) {
-        throw new UriValidationException("System query option not allowed: " + option.getName());
+    switch (lastPathSegemnt.getKind()) {
+    case count:
+      List<UriResource> parts = uriInfo.getUriResourceParts();
+      UriResource secondLastPart = parts.get(parts.size() - 2);
+      switch (secondLastPart.getKind()) {
+      case entitySet:
+        idx = 8;
+        break;
+        default : throw new UriValidationException("Illegal path part kind: " + lastPathSegemnt.getKind());
       }
+      break;
+    case action:
+      break;
+    case complexProperty:
+      break;
+    case entitySet:
+      idx = 7;
+      break;
+    case function:
+      break;
+    case it:
+      break;
+    case lambdaAll:
+      break;
+    case lambdaAny:
+      break;
+    case lambdaVariable:
+      break;
+    case navigationProperty:
+      break;
+    case primitiveProperty:
+      break;
+    case ref:
+      break;
+    case root:
+      break;
+    case singleton:
+      break;
+    case value:
+      break;
+    default:
+      throw new ODataRuntimeException("Unsupported uriResource kind: " + lastPathSegemnt.getKind());
     }
-    }finally {
+
+    return idx;
+  }
+
+  private void validateQueryOptions(final UriInfo uriInfo, Edm edm) throws UriValidationException {
+    try {
+      int row = rowIndex(uriInfo, edm);
+
+      for (SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
+        int col = colIndex(option.getKind());
+
+        System.out.print("[" + row + "][" + col + "]");
+
+        if (!decisionMatrix[row][col]) {
+          throw new UriValidationException("System query option not allowed: " + option.getName());
+        }
+      }
+    } finally {
       System.out.println();
     }
-    
-  }
 
-  private void validateKeyPredicateTypes(final UriInfo uriInfo, final Edm edm) throws UriValidationException {
   }
 
+  private void validateKeyPredicateTypes(final UriInfo uriInfo, final Edm edm) throws UriValidationException {}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/99d57819/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
index 14e93cc..4912406 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
@@ -21,6 +21,8 @@ package org.apache.olingo.server.core.uri.validator;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
+
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
@@ -32,48 +34,128 @@ import org.junit.Test;
 
 public class UriEdmValidatorTest {
 
+  private static final String URI_ALL = "$all";
+  private static final String URI_BATCH = "$batch";
+  private static final String URI_CROSSJOIN = "$crossjoin(ESAllPrim)";
+  private static final String URI_ENTITY_ID = "/$entity";
+  private static final String URI_METADATA = "$metadata";
+  private static final String URI_SERVICE = "";
+  private static final String URI_ENTITY_SET = "/ESAllPrim";
+  private static final String URI_ENTITY_SET_COUNT = "/ESAllPrim/$count";
+  private static final String URI_ENTITY = "/ESAllPrim(1)";
+  private static final String URI_MEDIA_STREAM = "/ESMedia(1)/$value";
+  private static final String URI_REFERENCES = "/ESAllPrim/$ref";
+  private static final String URI_REFERENECE = "/ESAllPrim(1)/$ref";
+  private static final String URI_PROPERTY_COMPLEX = "/ESCompComp(1)/PropertyComplex";
+  private static final String URI_PROPERTY_COMPLEX_COLLECTION =
+      "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex";
+  private static final String URI_PROPERTY_COMPLEX_COLLECTION_COUNT =
+      "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex/$count";
+  private static final String URI_PROPERTY_PRIMITIVE = "/ESAllPrim(1)/PropertyString";
+  private static final String URI_PROPERTY_PRIMITIVE_COLLECTION = "/ESCollAllPrim/CollPropertyString";
+  private static final String URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT =
+      "/ESCollAllPrim/CollPropertyString/$count";
+  private static final String URI_PROPERTY_PRIMITIVE_VALUE = "/ESAllPrim(1)/PropertyString/$value";
+
+  private static final String QO_FILTER = "$filter='1' eq '1'";
+  private static final String QO_FORMAT = "$format=bla";
+  private static final String QO_EXPAND = "$expand=*";
+  private static final String QO_ID = "$id=Products(0)";
+  private static final String QO_COUNT = "$count";
+//  private static final String QO_ORDERBY = "$orderby=bla asc";
+//  private static final String QO_SEARCH = "$search='bla'";
+  private static final String QO_SELECT = "$select=*";
+  private static final String QO_SKIP = "$skip=3";
+  private static final String QO_SKIPTOKEN = "$skiptoken=123";
+  private static final String QO_LEVELS = "$expand=*($levels=1)";
+  private static final String QO_TOP = "$top=1";
+
   private Edm edm = new EdmProviderImpl(new EdmTechProvider());
 
+  private String[][] urisWithValidSystemQueryOptions = {
+      { URI_ALL, QO_FILTER, }, { URI_ALL, QO_FORMAT }, { URI_ALL, QO_EXPAND }, { URI_ALL, QO_COUNT },
+      /* { URI_ALL, QO_ORDERBY }, *//* { URI_ALL, QO_SEARCH }, */{ URI_ALL, QO_SELECT }, { URI_ALL, QO_SKIP },
+      { URI_ALL, QO_SKIPTOKEN }, { URI_ALL, QO_LEVELS },
 
-  String[] tmpUri = {
-      "$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid                                                                    ",
-      "$crossjoin(invalidEntitySet)                                                                                 ",
-      "$entity                                                                                                      ",
-      "$entity?$idfalse=ESKeyNav(1)                                                                                 ",
-      "ESAllPrim(PropertyInt16='1')                                                                                 ",
-      "ESCollAllPrim(null)                                                                                          ",
-      "ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)                                                                   ",
-      "ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)                                     ",
-      "ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)                                     ",
-      "FICRTCollCTTwoPrimParam(ParameterInt16='1',ParameterString='2')                                              ",
-      "FICRTESTwoKeyNavParam(ParameterInt16=@invalidAlias)?@validAlias=1                                            ",
-      "FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/PropertyComplex                         ",
-      "FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/$count                                  ",
-      // "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref                                                              ",
-//      "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count                                                            ",
-//      "ESKeyNav?$top=-3                                                                                             ",
-//      "ESAllPrim?$count=foo                                                                                         ",
-//      "ESAllPrim?$skip=-3                                                                                           "
+      { URI_CROSSJOIN, QO_FILTER, }, { URI_CROSSJOIN, QO_FORMAT },
+      { URI_CROSSJOIN, QO_EXPAND }, { URI_CROSSJOIN, QO_COUNT }, /* { URI_CROSSJOIN, QO_ORDERBY }, */
+      /* { URI_CROSSJOIN, QO_SEARCH }, */{ URI_CROSSJOIN, QO_SELECT }, { URI_CROSSJOIN, QO_SKIP },
+      { URI_CROSSJOIN, QO_SKIPTOKEN }, { URI_CROSSJOIN, QO_LEVELS }, { URI_CROSSJOIN, QO_TOP },
+
+      { URI_ENTITY_ID, QO_ID, QO_FORMAT }, { URI_ENTITY_ID, QO_ID, }, { URI_ENTITY_ID, QO_ID, QO_EXPAND },
+      { URI_ENTITY_ID, QO_ID, QO_SELECT }, { URI_ENTITY_ID, QO_ID, QO_LEVELS },
+
+      { URI_METADATA, QO_FORMAT },
+
+      { URI_SERVICE, QO_FORMAT },
+
+      { URI_ENTITY_SET, QO_FILTER, }, { URI_ENTITY_SET, QO_FORMAT }, { URI_ENTITY_SET, QO_EXPAND },
+      { URI_ENTITY_SET, QO_COUNT }, /* { URI_ENTITY_SET, QO_ORDERBY }, *//* { URI_ENTITY_SET, QO_SEARCH }, */
+      { URI_ENTITY_SET, QO_SELECT },
+      { URI_ENTITY_SET, QO_SKIP }, { URI_ENTITY_SET, QO_SKIPTOKEN }, { URI_ENTITY_SET, QO_LEVELS },
+      { URI_ENTITY_SET, QO_TOP },
+
+  };
+
+  private String[][] urisWithNonValidSystemQueryOptions = {
+      { URI_ALL, QO_ID, }, { URI_ALL, QO_TOP },
+
+      { URI_BATCH, QO_FILTER, }, { URI_BATCH, QO_FORMAT }, { URI_BATCH, QO_ID, }, { URI_BATCH, QO_EXPAND },
+      { URI_BATCH, QO_COUNT }, /* { URI_BATCH, QO_ORDERBY }, *//* { URI_BATCH, QO_SEARCH }, */{ URI_BATCH, QO_SELECT },
+      { URI_BATCH, QO_SKIP }, { URI_BATCH, QO_SKIPTOKEN }, { URI_BATCH, QO_LEVELS }, { URI_BATCH, QO_TOP },
+
+      { URI_CROSSJOIN, QO_ID, },
+
+      { URI_ENTITY_ID, QO_ID, QO_FILTER, },
+      { URI_ENTITY_ID, QO_ID, QO_COUNT }, /* { URI_ENTITY_ID, QO_ORDERBY }, *//* { URI_ENTITY_ID, QO_SEARCH }, */
+
+      { URI_ENTITY_ID, QO_ID, QO_SKIP }, { URI_ENTITY_ID, QO_ID, QO_SKIPTOKEN }, { URI_ENTITY_ID, QO_ID, QO_TOP },
+
+      { URI_METADATA, QO_FILTER, }, { URI_METADATA, QO_ID, }, { URI_METADATA, QO_EXPAND },
+      { URI_METADATA, QO_COUNT }, /* { URI_METADATA, QO_ORDERBY }, *//* { URI_METADATA, QO_SEARCH }, */
+      { URI_METADATA, QO_SELECT }, { URI_METADATA, QO_SKIP }, { URI_METADATA, QO_SKIPTOKEN },
+      { URI_METADATA, QO_LEVELS }, { URI_METADATA, QO_TOP },
+
+      { URI_SERVICE, QO_FILTER }, { URI_SERVICE, QO_ID }, { URI_SERVICE, QO_EXPAND }, { URI_SERVICE, QO_COUNT },
+      /* { URI_SERVICE, QO_ORDERBY }, *//* { URI_SERVICE, QO_SEARCH }, */{ URI_SERVICE, QO_SELECT },
+      { URI_SERVICE, QO_SKIP }, { URI_SERVICE, QO_SKIPTOKEN }, { URI_SERVICE, QO_LEVELS }, { URI_SERVICE, QO_TOP },
+
+      { URI_ENTITY_SET, QO_ID },
+
+      { URI_ENTITY_SET_COUNT, QO_FILTER }, { URI_ENTITY_SET_COUNT, QO_FORMAT }, { URI_ENTITY_SET_COUNT, QO_ID },
+      { URI_ENTITY_SET_COUNT, QO_EXPAND }, { URI_ENTITY_SET_COUNT, QO_COUNT },
+      /* { URI_ENTITY_SET_COUNT, QO_ORDERBY }, *//* { URI_ENTITY_SET_COUNT, QO_SEARCH }, */
+      { URI_ENTITY_SET_COUNT, QO_SELECT }, { URI_ENTITY_SET_COUNT, QO_SKIP }, { URI_ENTITY_SET_COUNT, QO_SKIPTOKEN },
+      { URI_ENTITY_SET_COUNT, QO_LEVELS }, { URI_ENTITY_SET_COUNT, QO_TOP },
   };
 
   @Test
-  @Ignore("key predicate validation not implemented")
-  public void keyPredicateValidTypes() throws Exception {
-    String[] uris = {};
+  public void bla() throws Exception {
+    String[][] m = { { URI_ENTITY_SET_COUNT, QO_FILTER } };
+    String[] uris = constructUri(m);
+    System.out.println(uris[0]);
+
+    parseAndValidate(uris[0]);
+  }
+
+  @Test
+  public void checkValidSystemQueryOption() throws Exception {
+    String[] uris = constructUri(urisWithValidSystemQueryOptions);
 
     for (String uri : uris) {
-      parseAndValidate(uri);
+      try {
+        parseAndValidate(uri);
+      } catch (Exception e) {
+        throw new Exception("Faild for uri: " + uri, e);
+      }
     }
-
   }
 
   @Test
-  @Ignore("key predicate validation not implemented")
-  public void keyPredicateInvalidTypes() throws UriParserException {
-    String[] uris = {};
+  public void checkNonValidSystemQueryOption() throws Exception {
+    String[] uris = constructUri(urisWithNonValidSystemQueryOptions);
 
     for (String uri : uris) {
-
       try {
         parseAndValidate(uri);
         fail("Validation Exception not thrown: " + uri);
@@ -84,19 +166,20 @@ public class UriEdmValidatorTest {
   }
 
   @Test
+  @Ignore
   public void systemQueryOptionValid() throws Exception {
     String[] uris =
     {
         /* $filter */
         "/$all?$format=bla",
-        "/$batch?$format=bla",
+        // "/$batch?$format=bla",
         "/$crossjoin(ESAllPrim)?$format=bla",
         "/$entity?$id=Products(0)?$format=bla",
         "/$metadata?$format=bla",
         "?$format=bla",
         "/ESAllPrim?$format=bla",
         "/ESAllPrim/$count?$format=bla",
-        "/ESAllPrim(1)?$format=bla"        ,
+        "/ESAllPrim(1)?$format=bla",
         "/ESMedia(1)/$value?$format=bla",
         "/ESAllPrim/$ref?$format=bla",
         "/ESAllPrim(1)/$ref?$format=bla",
@@ -107,26 +190,7 @@ public class UriEdmValidatorTest {
         "/ESCollAllPrim/CollPropertyString?$format=bla",
         "/ESCollAllPrim/CollPropertyString/$count?$format=bla",
         "/ESAllPrim(1)/PropertyString/$value?$format=bla"
-        /* all */
-        /* batch */
-        /* crossjoin */
-        /* entityId */
-        /* metadata */
-        /* resource */
-        /* service */
-        /* entitySet */
-        /* entitySetCount */
-        /* entity */
-        /* mediaStream */
-        /* references */
-        /* reference */
-        /* propertyComplex */
-        /* propertyComplexCollection */
-        /* propertyComplexCollectionCount */
-        /* propertyPrimitive */
-        /* propertyPrimitiveCollection */
-        /* propertyPrimitiveCollectionCount */
-        /* propertyPrimitiveValue */};
+    };
 
     for (String uri : uris) {
       try {
@@ -138,11 +202,77 @@ public class UriEdmValidatorTest {
 
   }
 
+  String[] tmpUri = {
+      "$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid                                                                    ",
+      "$crossjoin(invalidEntitySet)                                                                                 ",
+      "$entity                                                                                                      ",
+      "$entity?$idfalse=ESKeyNav(1)                                                                                 ",
+      "ESAllPrim(PropertyInt16='1')                                                                                 ",
+      "ESCollAllPrim(null)                                                                                          ",
+      "ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)                                                                   ",
+      "ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)                                     ",
+      "ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)                                     ",
+      "FICRTCollCTTwoPrimParam(ParameterInt16='1',ParameterString='2')                                              ",
+      "FICRTESTwoKeyNavParam(ParameterInt16=@invalidAlias)?@validAlias=1                                            ",
+      "FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/PropertyComplex                         ",
+      "FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/$count                                  ",
+      // "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref                                                              ",
+//      "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count                                                            ",
+//      "ESKeyNav?$top=-3                                                                                             ",
+//      "ESAllPrim?$count=foo                                                                                         ",
+//      "ESAllPrim?$skip=-3                                                                                           "
+  };
+
+  @Test
+  @Ignore("key predicate validation not implemented")
+  public void keyPredicateValidTypes() throws Exception {
+    String[] uris = {};
+
+    for (String uri : uris) {
+      parseAndValidate(uri);
+    }
+
+  }
+
+  @Test
+  @Ignore("key predicate validation not implemented")
+  public void keyPredicateInvalidTypes() throws UriParserException {
+    String[] uris = {};
+
+    for (String uri : uris) {
+
+      try {
+        parseAndValidate(uri);
+        fail("Validation Exception not thrown: " + uri);
+      } catch (UriValidationException e) {
+        assertTrue(e instanceof UriValidationException);
+      }
+    }
+  }
+
+  private String[] constructUri(String[][] uriParameterMatrix) {
+    ArrayList<String> uris = new ArrayList<String>();
+    for (String[] uriParameter : uriParameterMatrix) {
+      String uri = uriParameter[0];
+      if (uriParameter.length > 1) {
+        uri += "?";
+      }
+      for (int i = 1; i < uriParameter.length; i++) {
+        uri += uriParameter[i];
+        if (i < (uriParameter.length - 1)) {
+          uri += "&";
+        }
+      }
+      uris.add(uri);
+    }
+    return uris.toArray(new String[0]);
+  }
+
   @Test
   @Ignore
   public void systemQueryOptionInvalid() throws Exception {
     String[] uris =
-        {
+    {
         };
 
     for (String uri : uris) {
@@ -159,8 +289,8 @@ public class UriEdmValidatorTest {
   private void parseAndValidate(String uri) throws UriParserException, UriValidationException {
     UriInfo uriInfo = new Parser().parseUri(uri.trim(), edm);
     SystemQueryValidator validator = new SystemQueryValidator();
-    
-    System.out.print("URI: " + uri );
+
+    System.out.print("URI: " + uri);
     validator.validate(uriInfo, edm);
   }
 }


[2/4] git commit: [OLINGO-206] Merge remote-tracking branch 'origin/master' into olingo-206-val

Posted by sk...@apache.org.
[OLINGO-206] Merge remote-tracking branch 'origin/master' into olingo-206-val


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/f3d5d667
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/f3d5d667
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/f3d5d667

Branch: refs/heads/olingo-206-validator
Commit: f3d5d66735808113cce0563b3eaf93ab5985dfdb
Parents: c0db941 21aa475
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Mar 18 18:49:31 2014 +0100
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Mar 18 18:49:31 2014 +0100

----------------------------------------------------------------------
 .../org/apache/olingo/commons/core/Decoder.java |  90 +++++++++++++
 .../org/apache/olingo/commons/core/Encoder.java | 130 +++++++++++++++++++
 .../apache/olingo/commons/core/DecoderTest.java |  89 +++++++++++++
 .../apache/olingo/commons/core/EncoderTest.java | 106 +++++++++++++++
 .../olingo/server/core/uri/parser/Parser.java   |  21 +--
 .../server/core/uri/parser/UriDecoder.java      |  33 ++---
 .../olingo/server/core/uri/RawUriTest.java      |   2 +
 .../core/uri/antlr/TestFullResourcePath.java    |  27 ++--
 8 files changed, 457 insertions(+), 41 deletions(-)
----------------------------------------------------------------------



[3/4] git commit: [OLINGO-206] more validation tests

Posted by sk...@apache.org.
[OLINGO-206] more validation tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/d3d41111
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/d3d41111
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/d3d41111

Branch: refs/heads/olingo-206-validator
Commit: d3d411118eb84175b37e6614aba8e801c734491f
Parents: f3d5d66
Author: Stephan Klevenz <st...@sap.com>
Authored: Tue Mar 18 18:51:01 2014 +0100
Committer: Stephan Klevenz <st...@sap.com>
Committed: Tue Mar 18 18:51:01 2014 +0100

----------------------------------------------------------------------
 .../uri/validator/SystemQueryValidator.java     | 63 +++++++++++---------
 .../core/uri/validator/UriEdmValidatorTest.java | 58 +++++++++++++-----
 2 files changed, 78 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3d41111/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
index 0fd944f..b37ccde 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/SystemQueryValidator.java
@@ -30,27 +30,27 @@ public class SystemQueryValidator {
   //CHECKSTYLE:OFF (Maven checkstyle)
   private boolean[][] decisionMatrix =
       {
-          /*                                       FILTER FORMAT EXPAND ID     COUNT  ORDERBY SEARCH SELECT SKIP   SKIPTOKEN LEVELS TOP */
-          /*                              all */ { true , true , true , false, true , true ,  true , true , true , true ,    true , false },
-          /*                            batch */ { false, false, false, false, false, false,  false, false, false, false,    false, false },
-          /*                        crossjoin */ { true , true , true , false, true , true ,  true , true , true , true ,    true , true  },
-          /*                         entityId */ { false, true , true , true , false, false,  false, true , false, false,    true , false },
-          /*                         metadata */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*                         resource */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*                          service */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*                        entitySet */ { true , true , true , false, true , true ,  true , true , true , true ,    true , true  },
-          /*                   entitySetCount */ { false, false, false, false, false, false,  false, false, false, false,    false, false },
-          /*                           entity */ { false, true , true , false, false, false,  false, true , false, false,    true , false },
-          /*                      mediaStream */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*                       references */ { true , true , false, false, false, true ,  true , false, true , true ,    false, true  },
-          /*                        reference */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*                  propertyComplex */ { false, true , true , false, false, false,  false, true , false, false,    true , false },
-          /*        propertyComplexCollection */ { true , true , true , false, true , true ,  false, false, true , true ,    true , true  },
-          /*   propertyComplexCollectionCount */ { false, false, false, false, false, false,  false, false, false, false,    false, false },
-          /*                propertyPrimitive */ { false, true , false, false, false, false,  false, false, false, false,    false, false },
-          /*      propertyPrimitiveCollection */ { true , true , false, false, false, true ,  false, false, true , true ,    false, true  },
-          /* propertyPrimitiveCollectionCount */ { false, false, false, false, false, false,  false, false, false, false,    false, false },
-          /*           propertyPrimitiveValue */ { false, true , false, false, false, false,  false, false, false, false,    false, false },          
+          /*                                          0-FILTER 1-FORMAT 2-EXPAND 3-ID     4-COUNT  5-ORDERBY 6-SEARCH 7-SELECT 8-SKIP   9-SKIPTOKEN 10-LEVELS 11-TOP */
+          /*                              all  0 */ { true ,   true ,   true ,   false,   true ,   true ,    true ,   true ,   true ,   true ,      true ,    false },
+          /*                            batch  1 */ { false,   false,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                        crossjoin  2 */ { true ,   true ,   true ,   false,   true ,   true ,    true ,   true ,   true ,   true ,      true ,    true  },
+          /*                         entityId  3 */ { false,   true ,   true ,   true ,   false,   false,    false,   true ,   false,   false,      true ,    false },
+          /*                         metadata  4 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                         resource  5 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                          service  6 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                        entitySet  7 */ { true ,   true ,   true ,   false,   true ,   true ,    true ,   true ,   true ,   true ,      true ,    true  },
+          /*                   entitySetCount  8 */ { false,   false,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                           entity  9 */ { false,   true ,   true ,   false,   false,   false,    false,   true ,   false,   false,      true ,    false },
+          /*                      mediaStream 10 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                       references 11 */ { true ,   true ,   false,   false,   false,   true ,    true ,   false,   true ,   true ,      false,    true  },
+          /*                        reference 12 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                  propertyComplex 13 */ { false,   true ,   true ,   false,   false,   false,    false,   true ,   false,   false,      true ,    false },
+          /*        propertyComplexCollection 14 */ { true ,   true ,   true ,   false,   true ,   true ,    false,   false,   true ,   true ,      true ,    true  },
+          /*   propertyComplexCollectionCount 15 */ { false,   false,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*                propertyPrimitive 16 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*      propertyPrimitiveCollection 17 */ { true ,   true ,   false,   false,   false,   true ,    false,   false,   true ,   true ,      false,    true  },
+          /* propertyPrimitiveCollectionCount 18 */ { false,   false,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },
+          /*           propertyPrimitiveValue 19 */ { false,   true ,   false,   false,   false,   false,    false,   false,   false,   false,      false,    false },          
       };
   //CHECKSTYLE:ON
   //@formatter:on
@@ -102,7 +102,7 @@ public class SystemQueryValidator {
       idx = 11;
       break;
     default:
-      throw new ODataRuntimeException("Unsupported Option: " + queryOptionKind);
+      throw new ODataRuntimeException("Unsupported option: " + queryOptionKind);
     }
 
     return idx;
@@ -134,26 +134,33 @@ public class SystemQueryValidator {
       idx = 6;
       break;
     default:
-      throw new ODataRuntimeException("Unsupported Option: " + uriInfo.getKind());
+      throw new ODataRuntimeException("Unsupported uriInfo kind: " + uriInfo.getKind());
     }
 
     return idx;
   }
 
-  private void validateKeyPredicateTypes(final UriInfo uriInfo, final Edm edm) throws UriValidationException {
-
-  }
-
   private void validateQueryOptions(final UriInfo uriInfo) throws UriValidationException {
+    try {
     int row = rowIndex(uriInfo);
 
     for (SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
       int col = colIndex(option.getKind());
+      
+      System.out.print("[" + row +"][" + col +"]");
+
+      
       if (!decisionMatrix[row][col]) {
-        throw new UriValidationException("Unsupported System Query Option for Uri Type: " + option.getName());
+        throw new UriValidationException("System query option not allowed: " + option.getName());
       }
     }
+    }finally {
+      System.out.println();
+    }
+    
+  }
 
+  private void validateKeyPredicateTypes(final UriInfo uriInfo, final Edm edm) throws UriValidationException {
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d3d41111/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
index de5578c..14e93cc 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/validator/UriEdmValidatorTest.java
@@ -34,6 +34,7 @@ public class UriEdmValidatorTest {
 
   private Edm edm = new EdmProviderImpl(new EdmTechProvider());
 
+
   String[] tmpUri = {
       "$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid                                                                    ",
       "$crossjoin(invalidEntitySet)                                                                                 ",
@@ -86,12 +87,46 @@ public class UriEdmValidatorTest {
   public void systemQueryOptionValid() throws Exception {
     String[] uris =
     {
-        /* service document */
-        "",
+        /* $filter */
+        "/$all?$format=bla",
+        "/$batch?$format=bla",
+        "/$crossjoin(ESAllPrim)?$format=bla",
+        "/$entity?$id=Products(0)?$format=bla",
+        "/$metadata?$format=bla",
+        "?$format=bla",
+        "/ESAllPrim?$format=bla",
+        "/ESAllPrim/$count?$format=bla",
+        "/ESAllPrim(1)?$format=bla"        ,
+        "/ESMedia(1)/$value?$format=bla",
+        "/ESAllPrim/$ref?$format=bla",
+        "/ESAllPrim(1)/$ref?$format=bla",
+        "/ESCompComp(1)/PropertyComplex?$format=bla",
+        "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex?$format=bla",
+        "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex/$count?$format=bla",
+        "/ESAllPrim(1)/PropertyString?$format=bla",
+        "/ESCollAllPrim/CollPropertyString?$format=bla",
+        "/ESCollAllPrim/CollPropertyString/$count?$format=bla",
+        "/ESAllPrim(1)/PropertyString/$value?$format=bla"
+        /* all */
+        /* batch */
+        /* crossjoin */
+        /* entityId */
         /* metadata */
-        "/$metadata",
-        "/$metadata?$format=atom",
-    };
+        /* resource */
+        /* service */
+        /* entitySet */
+        /* entitySetCount */
+        /* entity */
+        /* mediaStream */
+        /* references */
+        /* reference */
+        /* propertyComplex */
+        /* propertyComplexCollection */
+        /* propertyComplexCollectionCount */
+        /* propertyPrimitive */
+        /* propertyPrimitiveCollection */
+        /* propertyPrimitiveCollectionCount */
+        /* propertyPrimitiveValue */};
 
     for (String uri : uris) {
       try {
@@ -104,19 +139,10 @@ public class UriEdmValidatorTest {
   }
 
   @Test
+  @Ignore
   public void systemQueryOptionInvalid() throws Exception {
     String[] uris =
         {
-            /* service document */
-            /* metadata */
-            "/$metadata?$format=json&$top=3&$skip=5&$skiptoken=123",
-
-            /* misc */
-            "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref                                                              ",
-            "ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count                                                            ",
-            "ESKeyNav?$top=-3                                                                                             ",
-            "ESAllPrim?$count=foo                                                                                         ",
-            "ESAllPrim?$skip=-3                                                                                           "
         };
 
     for (String uri : uris) {
@@ -133,6 +159,8 @@ public class UriEdmValidatorTest {
   private void parseAndValidate(String uri) throws UriParserException, UriValidationException {
     UriInfo uriInfo = new Parser().parseUri(uri.trim(), edm);
     SystemQueryValidator validator = new SystemQueryValidator();
+    
+    System.out.print("URI: " + uri );
     validator.validate(uriInfo, edm);
   }
 }