http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java deleted file mode 100644 index 4632eff..0000000 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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.server.core.uri.testutil; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.Token; -import org.apache.olingo.server.core.uri.antlr.UriLexer; - -import java.util.List; - -import static org.junit.Assert.assertEquals; - -//TODO extend to test also exception which can occure while paring -public class TokenValidator { - - private String input = null; - - private List<? extends Token> tokens = null; - private Token curToken = null; - private Exception curException = null; - - private int startMode; - private int logLevel = 0; - - // --- Setup --- - - public TokenValidator log(final int logLevel) { - this.logLevel = logLevel; - return this; - } - - // --- Execution --- - - public TokenValidator run(final String uri) { - input = uri; - - tokens = parseInput(uri); - if (logLevel > 0) { - showTokens(); - } - - first(); - exFirst(); - logLevel = 0; - - return this; - } - - // --- Navigation --- - - // navigate within the tokenlist - public TokenValidator first() { - try { - curToken = tokens.get(0); - } catch (IndexOutOfBoundsException ex) { - curToken = null; - } - return this; - } - - public TokenValidator last() { - curToken = tokens.get(tokens.size() - 1); - return this; - } - - public TokenValidator at(final int index) { - try { - curToken = tokens.get(index); - } catch (IndexOutOfBoundsException ex) { - curToken = null; - } - return this; - } - - public TokenValidator exLast() { - // curException = exceptions.get(exceptions.size() - 1); - return this; - } - - // navigate within the exception list - public TokenValidator exFirst() { - try { - // curException = exceptions.get(0); - } catch (IndexOutOfBoundsException ex) { - curException = null; - } - return this; - - } - - public TokenValidator exAt(final int index) { - try { - // curException = exceptions.get(index); - } catch (IndexOutOfBoundsException ex) { - curException = null; - } - return this; - } - - // --- Validation --- - - public TokenValidator isText(final String expected) { - assertEquals(expected, curToken.getText()); - return this; - } - - public TokenValidator isAllText(final String expected) { - String actual = ""; - - for (Token curToken : tokens) { - actual += curToken.getText(); - } - assertEquals(expected, actual); - return this; - } - - public TokenValidator isAllInput() { - String actual = ""; - - for (Token curToken : tokens) { - actual += curToken.getText(); - } - assertEquals(input, actual); - return this; - } - - public TokenValidator isInput() { - assertEquals(input, curToken.getText()); - return this; - } - - public TokenValidator isType(final int expected) { - assertEquals(UriLexer.tokenNames[expected], UriLexer.tokenNames[curToken.getType()]); - return this; - } - - public TokenValidator isExType(final Class<?> exClass) { - assertEquals(exClass, curException.getClass()); - return this; - } - - public void globalMode(final int mode) { - startMode = mode; - } - - // --- Helper --- - - private List<? extends Token> parseInput(final String input) { - ANTLRInputStream inputStream = new ANTLRInputStream(input); - - UriLexer lexer = new UriLexerWithTrace(inputStream, logLevel, startMode); - // lexer.addErrorListener(new ErrorCollector(this)); - return lexer.getAllTokens(); - } - - public TokenValidator showTokens() { - boolean first = true; - System.out.println("input: " + input); - String nL = "\n"; - String out = "[" + nL; - for (Token token : tokens) { - if (!first) { - out += ","; - first = false; - } - int index = token.getType(); - if (index != -1) { - out += "\"" + token.getText() + "\"" + " " + UriLexer.tokenNames[index] + nL; - } else { - out += "\"" + token.getText() + "\"" + " " + index + nL; - } - } - out += ']'; - System.out.println("tokens: " + out); - return this; - } - -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java deleted file mode 100644 index 9005080..0000000 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.server.core.uri.testutil; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.Token; -import org.apache.olingo.server.core.uri.antlr.UriLexer; - -public class UriLexerWithTrace extends UriLexer { - int logLevel = 0; - - public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel) { - super(antlrInputStream); - this.logLevel = logLevel; - } - - public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel, final int mode) { - super(antlrInputStream); - super.mode(mode); - this.logLevel = logLevel; - } - - @Override - public void emit(final Token token) { - if (logLevel > 1) { - String out = String.format("%1$-" + 20 + "s", token.getText()); - - int tokenType = token.getType(); - if (tokenType == -1) { - out += "-1/EOF"; - } else { - out += UriLexer.tokenNames[tokenType]; - } - System.out.println("Lexer.emit(...):" + out); - } - - super.emit(token); - } - - @Override - public void pushMode(final int m) { - - String out = UriLexer.modeNames[_mode] + "-->"; - - super.pushMode(m); - - out += UriLexer.modeNames[_mode]; - - if (logLevel > 1) { - System.out.println(out + " "); - } - } - - @Override - public int popMode() { - - String out = UriLexer.modeNames[_mode] + "-->"; - - int m = super.popMode(); - - out += UriLexer.modeNames[_mode]; - - if (logLevel > 1) { - System.out.println(out + " "); - } - - return m; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java deleted file mode 100644 index bdde9ce..0000000 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * 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.server.core.uri.validator; - -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.http.HttpMethod; -import org.apache.olingo.server.api.uri.UriInfo; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; -import org.apache.olingo.server.core.uri.parser.Parser; -import org.apache.olingo.server.core.uri.parser.UriParserException; -import org.apache.olingo.server.core.uri.parser.UriParserSemanticException; -import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException; -import org.apache.olingo.server.core.uri.testutil.TestUriValidator; -import org.apache.olingo.server.tecsvc.provider.ContainerProvider; -import org.apache.olingo.server.tecsvc.provider.EdmTechProvider; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -public class UriValidatorTest { - - 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_REFERENCE = "/ESAllPrim(1)/$ref"; - private static final String URI_PROPERTY_COMPLEX = "/ESCompComp(1)/PropertyComp"; - private static final String URI_PROPERTY_COMPLEX_COLLECTION = - "/ESCompCollComp(1)/PropertyComp/CollPropertyComp"; - private static final String URI_PROPERTY_COMPLEX_COLLECTION_COUNT = - "/ESCompCollComp(1)/PropertyComp/CollPropertyComp/$count"; - private static final String URI_PROPERTY_PRIMITIVE = "/ESAllPrim(1)/PropertyString"; - private static final String URI_PROPERTY_PRIMITIVE_COLLECTION = "/ESCollAllPrim(1)/CollPropertyString"; - private static final String URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT = - "/ESCollAllPrim(1)/CollPropertyString/$count"; - private static final String URI_PROPERTY_PRIMITIVE_VALUE = "/ESAllPrim(1)/PropertyString/$value"; - private static final String URI_SINGLETON = "/SI"; - private static final String URI_NAV_ENTITY = "/ESKeyNav(1)/NavPropertyETKeyNavOne"; - private static final String URI_NAV_ENTITY_SET = "/ESKeyNav(1)/NavPropertyETKeyNavMany"; - - private static final String QO_FILTER = "$filter='1' eq '1'"; - private static final String QO_FORMAT = "$format=bla/bla"; - private static final String QO_EXPAND = "$expand=*"; - private static final String QO_ID = "$id=Products(0)"; - private static final String QO_COUNT = "$count=true"; - private static final String QO_ORDERBY = "$orderby=true"; - // 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 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 }, - - { 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 }, - - { URI_ENTITY_SET_COUNT, QO_FILTER }, /* { URI_ENTITY_SET_COUNT, QO_SEARCH }, */ - - { URI_ENTITY, QO_FORMAT }, { URI_ENTITY, QO_EXPAND }, { URI_ENTITY, QO_SELECT }, { URI_ENTITY, QO_LEVELS }, - - { URI_MEDIA_STREAM, QO_FORMAT }, - - { URI_REFERENCES, QO_FILTER }, { URI_REFERENCES, QO_FORMAT }, { URI_REFERENCES, QO_ORDERBY }, - /* { URI_REFERENCES, QO_SEARCH }, */{ URI_REFERENCES, QO_SKIP }, { URI_REFERENCES, QO_SKIPTOKEN }, - { URI_REFERENCES, QO_TOP }, - - { URI_REFERENCE, QO_FORMAT }, - - { URI_PROPERTY_COMPLEX, QO_FORMAT }, { URI_PROPERTY_COMPLEX, QO_SELECT }, { URI_PROPERTY_COMPLEX, QO_EXPAND }, - { URI_PROPERTY_COMPLEX, QO_LEVELS }, - - { URI_PROPERTY_COMPLEX_COLLECTION, QO_FILTER }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_FORMAT }, - { URI_PROPERTY_COMPLEX_COLLECTION, QO_EXPAND }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_COUNT }, - { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIPTOKEN }, - { URI_PROPERTY_COMPLEX_COLLECTION, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_TOP }, - { URI_PROPERTY_COMPLEX_COLLECTION, QO_ORDERBY }, - - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FILTER }, /* { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SEARCH }, */ - - { URI_PROPERTY_PRIMITIVE, QO_FORMAT }, - - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FORMAT }, - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ORDERBY }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIP }, - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_TOP }, - - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FILTER }, - /* { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SEARCH }, */ - - { URI_PROPERTY_PRIMITIVE_VALUE, QO_FORMAT }, - - { URI_SINGLETON, QO_FORMAT }, { URI_SINGLETON, QO_EXPAND }, { URI_SINGLETON, QO_SELECT }, - { URI_SINGLETON, QO_LEVELS }, - - { URI_NAV_ENTITY, QO_FORMAT }, { URI_NAV_ENTITY, QO_EXPAND }, { URI_NAV_ENTITY, QO_SELECT }, - { URI_NAV_ENTITY, QO_LEVELS }, - - { URI_NAV_ENTITY_SET, QO_FILTER }, { URI_NAV_ENTITY_SET, QO_FORMAT }, { URI_NAV_ENTITY_SET, QO_EXPAND }, - { URI_NAV_ENTITY_SET, QO_COUNT }, { URI_NAV_ENTITY_SET, QO_ORDERBY }, - /* { URI_NAV_ENTITY_SET, QO_SEARCH }, */{ URI_NAV_ENTITY_SET, QO_SELECT }, { URI_NAV_ENTITY_SET, QO_SKIP }, - { URI_NAV_ENTITY_SET, QO_SKIPTOKEN }, { URI_NAV_ENTITY_SET, QO_LEVELS }, { URI_NAV_ENTITY_SET, QO_TOP }, - - { "FINRTInt16()" }, - { "FICRTETKeyNav()" }, - { "FICRTESTwoKeyNavParam(ParameterInt16=1)" }, - { "FICRTCollString()" }, - { "FICRTCTTwoPrim()" }, - { "FICRTCollCTTwoPrim()" }, - { "FICRTETMedia()" }, - - { "ESTwoKeyNav/olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav" }, - { "ESAllPrim/olingo.odata.test1.BAESAllPrimRTETAllPrim" }, - { ContainerProvider.AIRT_COLL_STRING_TWO_PARAM }, - { ContainerProvider.AIRTET_TWO_KEY_TWO_PRIM_PARAM }, - { ContainerProvider.AIRT_STRING } - }; - - 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_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_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 }, - - { URI_ENTITY, QO_FILTER }, { URI_ENTITY, QO_ID }, { URI_ENTITY, QO_COUNT }, /* { URI_ENTITY, QO_ORDERBY }, */ - /* { URI_ENTITY, QO_SEARCH }, */{ URI_ENTITY, QO_SKIP }, { URI_ENTITY, QO_SKIPTOKEN }, { URI_ENTITY, QO_TOP }, - - { URI_MEDIA_STREAM, QO_FILTER }, { URI_MEDIA_STREAM, QO_ID }, { URI_MEDIA_STREAM, QO_EXPAND }, - { URI_MEDIA_STREAM, QO_COUNT }, { URI_MEDIA_STREAM, QO_ORDERBY }, /* { URI_MEDIA_STREAM, QO_SEARCH }, */ - { URI_MEDIA_STREAM, QO_SELECT }, { URI_MEDIA_STREAM, QO_SKIP }, { URI_MEDIA_STREAM, QO_SKIPTOKEN }, - { URI_MEDIA_STREAM, QO_LEVELS }, { URI_MEDIA_STREAM, QO_TOP }, - - { URI_REFERENCES, QO_ID }, { URI_REFERENCES, QO_EXPAND }, { URI_REFERENCES, QO_COUNT }, - { URI_REFERENCES, QO_SELECT }, { URI_REFERENCES, QO_LEVELS }, - - { URI_REFERENCE, QO_FILTER }, { URI_REFERENCE, QO_ID }, { URI_REFERENCE, QO_EXPAND }, - { URI_REFERENCE, QO_COUNT }, { URI_REFERENCE, QO_ORDERBY }, /* { URI_REFERENCE, QO_SEARCH }, */ - { URI_REFERENCE, QO_SELECT }, { URI_REFERENCE, QO_SKIP }, { URI_REFERENCE, QO_SKIPTOKEN }, - { URI_REFERENCE, QO_LEVELS }, { URI_REFERENCE, QO_TOP }, - - { URI_PROPERTY_COMPLEX, QO_FILTER }, { URI_PROPERTY_COMPLEX, QO_ID }, { URI_PROPERTY_COMPLEX, QO_COUNT }, - { URI_PROPERTY_COMPLEX, QO_ORDERBY }, /* { URI_PROPERTY_COMPLEX, QO_SEARCH }, */ - { URI_PROPERTY_COMPLEX, QO_SKIP }, { URI_PROPERTY_COMPLEX, QO_SKIPTOKEN }, { URI_PROPERTY_COMPLEX, QO_TOP }, - - { URI_PROPERTY_COMPLEX_COLLECTION, QO_ID }, - /* { URI_PROPERTY_COMPLEX_COLLECTION, QO_SEARCH }, */{ URI_PROPERTY_COMPLEX_COLLECTION, QO_SELECT }, - - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FORMAT }, - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ID }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_EXPAND }, - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_COUNT }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ORDERBY }, - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SELECT }, - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIPTOKEN }, - { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_TOP }, - - { URI_PROPERTY_PRIMITIVE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE, QO_ID }, { URI_PROPERTY_PRIMITIVE, QO_EXPAND }, - { URI_PROPERTY_PRIMITIVE, QO_COUNT }, { URI_PROPERTY_PRIMITIVE, QO_ORDERBY }, - /* { URI_PROPERTY_PRIMITIVE, QO_SEARCH }, */{ URI_PROPERTY_PRIMITIVE, QO_SELECT }, - { URI_PROPERTY_PRIMITIVE, QO_SKIP }, { URI_PROPERTY_PRIMITIVE, QO_SKIPTOKEN }, - { URI_PROPERTY_PRIMITIVE, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE, QO_TOP }, - - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ID }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_EXPAND }, - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_COUNT }, /* { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SEARCH }, */ - { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_LEVELS }, - - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FORMAT }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ID }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_EXPAND }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_COUNT }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ORDERBY }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIP }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIPTOKEN }, - { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_TOP }, - - { URI_PROPERTY_PRIMITIVE_VALUE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_ID }, - { URI_PROPERTY_PRIMITIVE_VALUE, QO_EXPAND }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_COUNT }, - { URI_PROPERTY_PRIMITIVE_VALUE, QO_ORDERBY },/* { URI_PROPERTY_PRIMITIVE_VALUE, QO_SEARCH }, */ - { URI_PROPERTY_PRIMITIVE_VALUE, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIP }, - { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_LEVELS }, - { URI_PROPERTY_PRIMITIVE_VALUE, QO_TOP }, - - { URI_SINGLETON, QO_FILTER }, { URI_SINGLETON, QO_ID }, { URI_SINGLETON, QO_COUNT }, - { URI_SINGLETON, QO_ORDERBY }, /* { URI_SINGLETON, QO_SEARCH }, */{ URI_SINGLETON, QO_SKIP }, - { URI_SINGLETON, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP }, - - { URI_NAV_ENTITY, QO_FILTER }, { URI_NAV_ENTITY, QO_ID }, { URI_NAV_ENTITY, QO_COUNT }, - { URI_NAV_ENTITY, QO_ORDERBY }, /* { URI_NAV_ENTITY, QO_SEARCH }, */{ URI_NAV_ENTITY, QO_SKIP }, - { URI_NAV_ENTITY, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP }, - - { URI_NAV_ENTITY_SET, QO_ID } - }; - - private static final Edm edm = new EdmProviderImpl(new EdmTechProvider()); - - @Test - public void validateForHttpMethods() throws Exception { - final UriInfo uri = new Parser().parseUri(URI_ENTITY, null, null, edm); - final UriValidator validator = new UriValidator(); - - validator.validate(uri, HttpMethod.GET); - validator.validate(uri, HttpMethod.POST); - validator.validate(uri, HttpMethod.PUT); - validator.validate(uri, HttpMethod.DELETE); - validator.validate(uri, HttpMethod.PATCH); - } - - @Test - public void validateSelect() throws Exception { - new TestUriValidator().setEdm(edm).run(URI_ENTITY, "$select=PropertyString"); - } - - @Test - public void validateOrderBy() throws Exception { - final TestUriValidator testUri = new TestUriValidator().setEdm(edm); - - testUri.run(URI_ENTITY_SET, "$orderby=PropertyString"); - - testUri.runEx(URI_ENTITY, "$orderby=XXXX") - .isExSemantic(UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE); - } - - @Test - public void validateCountInvalid() throws Exception { - new TestUriValidator().setEdm(edm).runEx(URI_ENTITY_SET, "$count=foo") - .isExSyntax(UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION); - } - - @Test - public void validateTopInvalid() throws Exception { - new TestUriValidator().setEdm(edm).runEx(URI_ENTITY_SET, "$top=foo") - .isExSyntax(UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION); - } - - @Test - public void validateSkipInvalid() throws Exception { - new TestUriValidator().setEdm(edm).runEx(URI_ENTITY_SET, "$skip=foo") - .isExSyntax(UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION); - } - - @Test - public void validateDoubleSystemOptions() throws Exception { - new TestUriValidator().setEdm(edm).runEx(URI_ENTITY_SET, "$skip=1&$skip=2") - .isExSyntax(UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION); - } - - @Test - public void checkKeys() throws Exception { - final TestUriValidator testUri = new TestUriValidator().setEdm(edm); - - testUri.run("ESTwoKeyNav(PropertyInt16=1, PropertyString='abc')"); - - testUri.runEx("ESTwoKeyNav(xxx=1, yyy='abc')") - .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY); - testUri.runEx("ESCollAllPrim(null)").isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY); - testUri.runEx("ESAllPrim(PropertyInt16='1')") - .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY); - testUri.runEx("ESAllPrim(12345678901234567890)") - .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY); - testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString=1)") - .isExValidation(UriValidationException.MessageKeys.INVALID_KEY_PROPERTY); - testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyInt16=1)") - .isExValidation(UriValidationException.MessageKeys.DOUBLE_KEY_PROPERTY); - } - - @Test - public void checkValidSystemQueryOption() throws Exception { - for (final String[] uriArray : urisWithValidSystemQueryOptions) { - final String[] uri = constructUri(uriArray); - try { - new UriValidator().validate( - new Parser().parseUri(uri[0], uri[1], null, edm), - HttpMethod.GET); - } catch (final UriParserException e) { - fail("Failed for uri: " + uri[0] + '?' + uri[1]); - } catch (final UriValidationException e) { - fail("Failed for uri: " + uri[0] + '?' + uri[1]); - } - } - } - - @Test - public void checkNonValidSystemQueryOption() throws Exception { - for (final String[] uriArray : urisWithNonValidSystemQueryOptions) { - final String[] uri = constructUri(uriArray); - validateWrong(uri[0], uri[1], HttpMethod.GET, - UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED); - } - } - - @Test - public void propertyOperations() throws Exception { - validateWrong(URI_PROPERTY_PRIMITIVE_COLLECTION, null, HttpMethod.PATCH, - UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD); - validateWrong(URI_PROPERTY_COMPLEX_COLLECTION, null, HttpMethod.PATCH, - UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD); - validateWrong("ESKeyNav(1)/PropertyString", null, HttpMethod.DELETE, - UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD); - validateWrong("ESKeyNav(1)/PropertyString/$value", null, HttpMethod.DELETE, - UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD); - } - - private String[] constructUri(final String[] uriParameterArray) { - final String path = uriParameterArray[0]; - String query = ""; - for (int i = 1; i < uriParameterArray.length; i++) { - if (i > 1) { - query += '&'; - } - query += uriParameterArray[i]; - } - return new String[] { path, query }; - } - - private void validateWrong(final String path, final String query, final HttpMethod method, - final UriValidationException.MessageKeys expectedMessageKey) { - try { - new UriValidator().validate(new Parser().parseUri(path, query, null, edm), method); - fail("Validation Exception not thrown: " + method + ' ' + path + '?' + query); - } catch (final UriParserException e) { - fail("Wrong Exception thrown: " + method + ' ' + path + '?' + query); - } catch (final UriValidationException e) { - assertEquals(expectedMessageKey, e.getMessageKey()); - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/ESAllPrim.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrim.json b/lib/server-test/src/test/resources/ESAllPrim.json deleted file mode 100644 index 75a6a22..0000000 --- a/lib/server-test/src/test/resources/ESAllPrim.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim", - "value" : [{ - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05" - }, { - "PropertyInt16" : -32768, - "PropertyString" : "Second Resource - negative values", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : -128, - "PropertyInt32" : -2147483648, - "PropertyInt64" : -9223372036854775808, - "PropertySingle" : -1.79000000E+08, - "PropertyDouble" : -1.7900000000000000E+05, - "PropertyDecimal" : -34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2015-11-05", - "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", - "PropertyDuration" : "P0DT0H0M9S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", - "PropertyTimeOfDay" : "23:49:14" - }, { - "PropertyInt16" : 0, - "PropertyString" : "", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : 0, - "PropertyInt32" : 0, - "PropertyInt64" : 0, - "PropertySingle" : 0.00000000E+00, - "PropertyDouble" : 0.0000000000000000E+00, - "PropertyDecimal" : 0, - "PropertyBinary" : "", - "PropertyDate" : "1970-01-01", - "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", - "PropertyDuration" : "P0DT0H0M0S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", - "PropertyTimeOfDay" : "00:01:01" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotations.json b/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotations.json deleted file mode 100644 index 915a3f0..0000000 --- a/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotations.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim", - "@custom.annotation" : "customValue", - "value" : [{ - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05" - }, { - "PropertyInt16" : -32768, - "PropertyString" : "Second Resource - negative values", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : -128, - "PropertyInt32" : -2147483648, - "PropertyInt64" : -9223372036854775808, - "PropertySingle" : -1.79000000E+08, - "PropertyDouble" : -1.7900000000000000E+05, - "PropertyDecimal" : -34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2015-11-05", - "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", - "PropertyDuration" : "P0DT0H0M9S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", - "PropertyTimeOfDay" : "23:49:14" - }, { - "PropertyInt16" : 0, - "PropertyString" : "", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : 0, - "PropertyInt32" : 0, - "PropertyInt64" : 0, - "PropertySingle" : 0.00000000E+00, - "PropertyDouble" : 0.0000000000000000E+00, - "PropertyDecimal" : 0, - "PropertyBinary" : "", - "PropertyDate" : "1970-01-01", - "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", - "PropertyDuration" : "P0DT0H0M0S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", - "PropertyTimeOfDay" : "00:01:01" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/ESAllPrimWithDoubleKey.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithDoubleKey.json b/lib/server-test/src/test/resources/ESAllPrimWithDoubleKey.json deleted file mode 100644 index 6c12ca1..0000000 --- a/lib/server-test/src/test/resources/ESAllPrimWithDoubleKey.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim", - "value" : [], - "value" : [{ - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05" - }, { - "PropertyInt16" : -32768, - "PropertyString" : "Second Resource - negative values", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : -128, - "PropertyInt32" : -2147483648, - "PropertyInt64" : -9223372036854775808, - "PropertySingle" : -1.79000000E+08, - "PropertyDouble" : -1.7900000000000000E+05, - "PropertyDecimal" : -34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2015-11-05", - "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", - "PropertyDuration" : "P0DT0H0M9S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", - "PropertyTimeOfDay" : "23:49:14" - }, { - "PropertyInt16" : 0, - "PropertyString" : "", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : 0, - "PropertyInt32" : 0, - "PropertyInt64" : 0, - "PropertySingle" : 0.00000000E+00, - "PropertyDouble" : 0.0000000000000000E+00, - "PropertyDecimal" : 0, - "PropertyBinary" : "", - "PropertyDate" : "1970-01-01", - "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", - "PropertyDuration" : "P0DT0H0M0S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", - "PropertyTimeOfDay" : "00:01:01" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotations.json b/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotations.json deleted file mode 100644 index ce3ae40..0000000 --- a/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotations.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim", - "@odata.count" : 3, - "@odata.nextLink" : "http://localhost:8080/nextLink", - "@odata.deltaLink" : "http://localhost:8080/deltaLink", - "value" : [{ - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05" - }, { - "PropertyInt16" : -32768, - "PropertyString" : "Second Resource - negative values", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : -128, - "PropertyInt32" : -2147483648, - "PropertyInt64" : -9223372036854775808, - "PropertySingle" : -1.79000000E+08, - "PropertyDouble" : -1.7900000000000000E+05, - "PropertyDecimal" : -34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2015-11-05", - "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", - "PropertyDuration" : "P0DT0H0M9S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", - "PropertyTimeOfDay" : "23:49:14" - }, { - "PropertyInt16" : 0, - "PropertyString" : "", - "PropertyBoolean" : false, - "PropertyByte" : 0, - "PropertySByte" : 0, - "PropertyInt32" : 0, - "PropertyInt64" : 0, - "PropertySingle" : 0.00000000E+00, - "PropertyDouble" : 0.0000000000000000E+00, - "PropertyDecimal" : 0, - "PropertyBinary" : "", - "PropertyDate" : "1970-01-01", - "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", - "PropertyDuration" : "P0DT0H0M0S", - "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", - "PropertyTimeOfDay" : "00:01:01" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/ESCompCollComp.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESCompCollComp.json b/lib/server-test/src/test/resources/ESCompCollComp.json deleted file mode 100644 index fa02338..0000000 --- a/lib/server-test/src/test/resources/ESCompCollComp.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "@odata.context" : "$metadata#ESCompCollComp", - "value" : [{ - "PropertyInt16" : 32767, - "PropertyComp" : { - "CollPropertyComp" : [{ - "PropertyInt16" : 555, - "PropertyString" : "1 Test Complex in Complex Property" - }, { - "PropertyInt16" : 666, - "PropertyString" : "2 Test Complex in Complex property" - }, { - "PropertyInt16" : 777, - "PropertyString" : "3 Test Complex in Complex property" - } - ] - } - }, { - "PropertyInt16" : 12345, - "PropertyComp" : { - "CollPropertyComp" : [{ - "PropertyInt16" : 888, - "PropertyString" : "11 Test Complex in Complex property" - }, { - "PropertyInt16" : 999, - "PropertyString" : "12 Test Complex in Complex property" - }, { - "PropertyInt16" : 0, - "PropertyString" : "13 Test Complex in Complex property" - } - ] - } - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json deleted file mode 100644 index b15788f..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "NavPropertyETTwoPrimMany" : [{ - "PropertyInt16" : -365, - "PropertyString" : "Test String2" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json deleted file mode 100644 index edcc3ad..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithCustomAnnotations.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "[email protected]" : "customValue", - "NavPropertyETTwoPrimMany" : [{ - "PropertyInt16" : -365, - "PropertyString" : "Test String2" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json deleted file mode 100644 index 4cbf650..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotations.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "[email protected]" : "http://localhost:8080/context", - "[email protected]" : 12, - "[email protected]" : "http://localhost:8080/nextLink", - "NavPropertyETTwoPrimMany" : [{ - "PropertyInt16" : -365, - "PropertyString" : "Test String2" - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json deleted file mode 100644 index a68a554..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "NavPropertyETTwoPrimOne" : { - "PropertyInt16" : 32767, - "PropertyString" : "Test String4" - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json deleted file mode 100644 index 85c55e7..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithCustomAnnotations.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "[email protected]" : "customValue", - "NavPropertyETTwoPrimOne" : { - "PropertyInt16" : 32767, - "PropertyString" : "Test String4" - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json deleted file mode 100644 index e778f58..0000000 --- a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotations.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "@odata.context" : "$metadata#ESAllPrim/$entity", - "PropertyInt16" : 32767, - "PropertyString" : "First Resource - positive values", - "PropertyBoolean" : true, - "PropertyByte" : 255, - "PropertySByte" : 127, - "PropertyInt32" : 2147483647, - "PropertyInt64" : 9223372036854775807, - "PropertySingle" : 1.79000000E+20, - "PropertyDouble" : -1.7900000000000000E+19, - "PropertyDecimal" : 34, - "PropertyBinary" : "ASNFZ4mrze8=", - "PropertyDate" : "2012-12-03", - "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", - "PropertyDuration" : "P0DT0H0M6S", - "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", - "PropertyTimeOfDay" : "03:26:05", - "[email protected]" : "http://localhost:8080/context", - "[email protected]" : 12, - "[email protected]" : "http://localhost:8080/nextLink", - "NavPropertyETTwoPrimOne" : { - "PropertyInt16" : 32767, - "PropertyString" : "Test String4" - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json b/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json deleted file mode 100644 index c56a809..0000000 --- a/lib/server-test/src/test/resources/EntityETMixEnumDefCollComp.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PropertyEnumString" : 2, - "PropertyDefString" : "string", - "CollPropertyEnumString" : [1, 2], - "CollPropertyDefString" : ["string1", "string2"], - "PropertyCompMixedEnumDef" : { - "PropertyEnumString" : 2, - "PropertyDefString" : "string", - "CollPropertyEnumString" : [1, 2], - "CollPropertyDefString" : ["string1", "string2"] - }, - "CollPropertyCompMixedEnumDef" : [{ - "PropertyEnumString" : 2, - "PropertyDefString" : "string", - "CollPropertyEnumString" : [1, 2], - "CollPropertyDefString" : ["string1", "string2"] - }, { - "PropertyEnumString" : 2, - "PropertyDefString" : "string", - "CollPropertyEnumString" : [1, 2], - "CollPropertyDefString" : ["string1", "string2"] - } - ] -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-test/src/test/resources/simplelogger.properties ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/simplelogger.properties b/lib/server-test/src/test/resources/simplelogger.properties deleted file mode 100644 index 2a3350c..0000000 --- a/lib/server-test/src/test/resources/simplelogger.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# 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. -# -org.slf4j.simpleLogger.defaultLogLevel=debug -org.slf4j.simpleLogger.logFile=System.out \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2cc979d..4cbfda1 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ <groupId>org.apache.olingo</groupId> <artifactId>odata-parent</artifactId> - <version>4.0.0-beta-02</version> + <version>3.0.0-beta-01-SNAPSHOT</version> <packaging>pom</packaging> <name>Olingo-OData</name> @@ -35,7 +35,7 @@ <parent> <groupId>org.apache</groupId> <artifactId>apache</artifactId> - <version>14</version> + <version>16</version> </parent> <licenses> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/client/pom.xml ---------------------------------------------------------------------- diff --git a/samples/client/pom.xml b/samples/client/pom.xml index bec3b14..aabde1d 100644 --- a/samples/client/pom.xml +++ b/samples/client/pom.xml @@ -31,7 +31,7 @@ <parent> <groupId>org.apache.olingo</groupId> <artifactId>odata-samples</artifactId> - <version>4.0.0-beta-02</version> + <version>3.0.0-beta-01-SNAPSHOT</version> <relativePath>..</relativePath> </parent> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/pom.xml ---------------------------------------------------------------------- diff --git a/samples/pom.xml b/samples/pom.xml index fa90c00..8d801e6 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -31,11 +31,7 @@ <parent> <groupId>org.apache.olingo</groupId> <artifactId>odata-parent</artifactId> - <version>4.0.0-beta-02</version> + <version>3.0.0-beta-01-SNAPSHOT</version> <relativePath>..</relativePath> </parent> - - <modules> - <module>server</module> - </modules> </project> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/server/pom.xml ---------------------------------------------------------------------- diff --git a/samples/server/pom.xml b/samples/server/pom.xml deleted file mode 100644 index b15c7f1..0000000 --- a/samples/server/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <artifactId>odata-server-sample</artifactId> - <packaging>war</packaging> - <name>${project.artifactId}</name> - - <parent> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-samples</artifactId> - <version>4.0.0-beta-02</version> - <relativePath>..</relativePath> - </parent> - - <dependencies> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-server-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-server-core</artifactId> - <version>${project.version}</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-commons-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-commons-core</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <version>1.7.7</version> - <scope>runtime</scope> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java ---------------------------------------------------------------------- diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java b/samples/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java deleted file mode 100644 index f6a17dc..0000000 --- a/samples/server/src/main/java/org/apache/olingo/server/sample/CarsServlet.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.server.sample; - -import java.io.IOException; -import java.util.ArrayList; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.olingo.server.api.OData; -import org.apache.olingo.server.api.ODataHttpHandler; -import org.apache.olingo.server.api.ServiceMetadata; -import org.apache.olingo.server.api.edmx.EdmxReference; -import org.apache.olingo.server.sample.data.DataProvider; -import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider; -import org.apache.olingo.server.sample.processor.CarsProcessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CarsServlet extends HttpServlet { - - private static final long serialVersionUID = 1L; - private static final Logger LOG = LoggerFactory.getLogger(CarsServlet.class); - - @Override - protected void service(final HttpServletRequest req, final HttpServletResponse resp) - throws ServletException, IOException { - try { - HttpSession session = req.getSession(true); - DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName()); - if (dataProvider == null) { - dataProvider = new DataProvider(); - session.setAttribute(DataProvider.class.getName(), dataProvider); - LOG.info("Created new data provider."); - } - - OData odata = OData.newInstance(); - ServiceMetadata edm = odata.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>()); - ODataHttpHandler handler = odata.createHandler(edm); - handler.register(new CarsProcessor(dataProvider)); - handler.process(req, resp); - } catch (RuntimeException e) { - LOG.error("Server Error", e); - throw new ServletException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java ---------------------------------------------------------------------- diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java deleted file mode 100644 index d59d251..0000000 --- a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.server.sample.data; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.olingo.commons.api.ODataException; -import org.apache.olingo.commons.api.data.Entity; -import org.apache.olingo.commons.api.data.EntitySet; -import org.apache.olingo.commons.api.data.Property; -import org.apache.olingo.commons.api.data.ValueType; -import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmEntityType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.core.data.EntityImpl; -import org.apache.olingo.commons.core.data.EntitySetImpl; -import org.apache.olingo.commons.core.data.PropertyImpl; -import org.apache.olingo.server.api.uri.UriParameter; - -public class DataProvider { - - private Map<String, EntitySet> data; - - public DataProvider() { - data = new HashMap<String, EntitySet>(); - data.put("Cars", createCars()); - data.put("Manufacturers", createManufacturers()); - } - - public EntitySet readAll(EdmEntitySet edmEntitySet) { - return data.get(edmEntitySet.getName()); - } - - public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException { - final EdmEntityType entityType = edmEntitySet.getEntityType(); - final EntitySet entitySet = data.get(edmEntitySet.getName()); - if (entitySet == null) { - return null; - } else { - try { - for (final Entity entity : entitySet.getEntities()) { - boolean found = true; - for (final UriParameter key : keys) { - final EdmProperty property = (EdmProperty) entityType.getProperty(key.getName()); - final EdmPrimitiveType type = (EdmPrimitiveType) property.getType(); - if (!type.valueToString(entity.getProperty(key.getName()).getValue(), - property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(), - property.isUnicode()) - .equals(key.getText())) { - found = false; - break; - } - } - if (found) { - return entity; - } - } - return null; - } catch (final EdmPrimitiveTypeException e) { - throw new DataProviderException("Wrong key!", e); - } - } - } - - public static class DataProviderException extends ODataException { - private static final long serialVersionUID = 5098059649321796156L; - - public DataProviderException(String message, Throwable throwable) { - super(message, throwable); - } - - public DataProviderException(String message) { - super(message); - } - } - - private EntitySet createCars() { - EntitySet entitySet = new EntitySetImpl(); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 1)) - .addProperty(createPrimitive("Model", "F1 W03")) - .addProperty(createPrimitive("ModelYear", "2012")) - .addProperty(createPrimitive("Price", 189189.43)) - .addProperty(createPrimitive("Currency", "EUR"))); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 2)) - .addProperty(createPrimitive("Model", "F1 W04")) - .addProperty(createPrimitive("ModelYear", "2013")) - .addProperty(createPrimitive("Price", 199999.99)) - .addProperty(createPrimitive("Currency", "EUR"))); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 3)) - .addProperty(createPrimitive("Model", "F2012")) - .addProperty(createPrimitive("ModelYear", "2012")) - .addProperty(createPrimitive("Price", 137285.33)) - .addProperty(createPrimitive("Currency", "EUR"))); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 4)) - .addProperty(createPrimitive("Model", "F2013")) - .addProperty(createPrimitive("ModelYear", "2013")) - .addProperty(createPrimitive("Price", 145285.00)) - .addProperty(createPrimitive("Currency", "EUR"))); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 5)) - .addProperty(createPrimitive("Model", "F1 W02")) - .addProperty(createPrimitive("ModelYear", "2011")) - .addProperty(createPrimitive("Price", 167189.00)) - .addProperty(createPrimitive("Currency", "EUR"))); - - return entitySet; - } - - private EntitySet createManufacturers() { - EntitySet entitySet = new EntitySetImpl(); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 1)) - .addProperty(createPrimitive("Name", "Star Powered Racing")) - .addProperty(createAddress("Star Street 137", "Stuttgart", "70173", "Germany"))); - - entitySet.getEntities().add(new EntityImpl() - .addProperty(createPrimitive("Id", 2)) - .addProperty(createPrimitive("Name", "Horse Powered Racing")) - .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy"))); - - return entitySet; - } - - private Property createAddress(final String street, final String city, final String zipCode, final String country) { - List<Property> addressProperties = new ArrayList<Property>(); - addressProperties.add(createPrimitive("Street", street)); - addressProperties.add(createPrimitive("City", city)); - addressProperties.add(createPrimitive("ZipCode", zipCode)); - addressProperties.add(createPrimitive("Country", country)); - return new PropertyImpl(null, "Address", ValueType.COMPLEX, addressProperties); - } - - private Property createPrimitive(final String name, final Object value) { - return new PropertyImpl(null, name, ValueType.PRIMITIVE, value); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java ---------------------------------------------------------------------- diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java deleted file mode 100644 index 8f1b248..0000000 --- a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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.server.sample.edmprovider; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.olingo.commons.api.ODataException; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.Target; -import org.apache.olingo.server.api.edm.provider.ComplexType; -import org.apache.olingo.server.api.edm.provider.EdmProvider; -import org.apache.olingo.server.api.edm.provider.EntityContainer; -import org.apache.olingo.server.api.edm.provider.EntityContainerInfo; -import org.apache.olingo.server.api.edm.provider.EntitySet; -import org.apache.olingo.server.api.edm.provider.EntityType; -import org.apache.olingo.server.api.edm.provider.NavigationProperty; -import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding; -import org.apache.olingo.server.api.edm.provider.Property; -import org.apache.olingo.server.api.edm.provider.PropertyRef; -import org.apache.olingo.server.api.edm.provider.Schema; - -public class CarsEdmProvider extends EdmProvider { - - // Service Namespace - public static final String NAMESPACE = "olingo.odata.sample"; - - // EDM Container - public static final String CONTAINER_NAME = "Container"; - public static final FullQualifiedName CONTAINER_FQN = new FullQualifiedName(NAMESPACE, CONTAINER_NAME); - - // Entity Types Names - public static final FullQualifiedName ET_CAR = new FullQualifiedName(NAMESPACE, "Car"); - public static final FullQualifiedName ET_MANUFACTURER = new FullQualifiedName(NAMESPACE, "Manufacturer"); - - // Complex Type Names - public static final FullQualifiedName CT_ADDRESS = new FullQualifiedName(NAMESPACE, "Address"); - - // Entity Set Names - public static final String ES_CARS_NAME = "Cars"; - public static final String ES_MANUFACTURER_NAME = "Manufacturers"; - - @Override - public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { - if (ET_CAR.equals(entityTypeName)) { - return new EntityType() - .setName(ET_CAR.getName()) - .setKey(Arrays.asList( - new PropertyRef().setPropertyName("Id"))) - .setProperties( - Arrays.asList( - new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), - new Property().setName("Model").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), - new Property().setName("ModelYear").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()) - .setMaxLength(4), - new Property().setName("Price").setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName()) - .setScale(2), - new Property().setName("Currency").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()) - .setMaxLength(3) - ) - ).setNavigationProperties(Arrays.asList( - new NavigationProperty().setName("Manufacturer").setType(ET_MANUFACTURER) - ) - ); - - } else if (ET_MANUFACTURER.equals(entityTypeName)) { - return new EntityType() - .setName(ET_MANUFACTURER.getName()) - .setKey(Arrays.asList( - new PropertyRef().setPropertyName("Id"))) - .setProperties(Arrays.asList( - new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), - new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), - new Property().setName("Address").setType(CT_ADDRESS)) - ).setNavigationProperties(Arrays.asList( - new NavigationProperty().setName("Cars").setType(ET_CAR).setCollection(true) - ) - ); - } - - return null; - } - - public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException { - if (CT_ADDRESS.equals(complexTypeName)) { - return new ComplexType().setName(CT_ADDRESS.getName()).setProperties(Arrays.asList( - new Property().setName("Street").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), - new Property().setName("City").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), - new Property().setName("ZipCode").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), - new Property().setName("Country").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()) - )); - } - return null; - } - - @Override - public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName) - throws ODataException { - if (CONTAINER_FQN.equals(entityContainer)) { - if (ES_CARS_NAME.equals(entitySetName)) { - return new EntitySet() - .setName(ES_CARS_NAME) - .setType(ET_CAR) - .setNavigationPropertyBindings( - Arrays.asList( - new NavigationPropertyBinding().setPath("Manufacturer").setTarget( - new Target().setTargetName(ES_MANUFACTURER_NAME).setEntityContainer(CONTAINER_FQN)))); - } else if (ES_MANUFACTURER_NAME.equals(entitySetName)) { - return new EntitySet() - .setName(ES_MANUFACTURER_NAME) - .setType(ET_MANUFACTURER).setNavigationPropertyBindings( - Arrays.asList( - new NavigationPropertyBinding().setPath("Cars").setTarget( - new Target().setTargetName(ES_CARS_NAME).setEntityContainer(CONTAINER_FQN)))); - } - } - - return null; - } - - @Override - public List<Schema> getSchemas() throws ODataException { - List<Schema> schemas = new ArrayList<Schema>(); - Schema schema = new Schema(); - schema.setNamespace(NAMESPACE); - // EntityTypes - List<EntityType> entityTypes = new ArrayList<EntityType>(); - entityTypes.add(getEntityType(ET_CAR)); - entityTypes.add(getEntityType(ET_MANUFACTURER)); - schema.setEntityTypes(entityTypes); - - // ComplexTypes - List<ComplexType> complexTypes = new ArrayList<ComplexType>(); - complexTypes.add(getComplexType(CT_ADDRESS)); - schema.setComplexTypes(complexTypes); - - // EntityContainer - schema.setEntityContainer(getEntityContainer()); - schemas.add(schema); - - return schemas; - } - - @Override - public EntityContainer getEntityContainer() throws ODataException { - EntityContainer container = new EntityContainer(); - container.setName(CONTAINER_FQN.getName()); - - // EntitySets - List<EntitySet> entitySets = new ArrayList<EntitySet>(); - container.setEntitySets(entitySets); - entitySets.add(getEntitySet(CONTAINER_FQN, ES_CARS_NAME)); - entitySets.add(getEntitySet(CONTAINER_FQN, ES_MANUFACTURER_NAME)); - - return container; - } - - @Override - public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException { - if (entityContainerName == null || CONTAINER_FQN.equals(entityContainerName)) { - return new EntityContainerInfo().setContainerName(CONTAINER_FQN); - } - return null; - } -}
