[OLINGO-266] Merge remote-tracking branch 'origin/olingo-266-ref'

This commit is contained in:
Stephan Klevenz 2014-05-12 14:51:07 +02:00
commit 330c556995
54 changed files with 542 additions and 2264 deletions

View File

@ -1,26 +1,26 @@
<?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
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
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.
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">
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>olingo-fit</artifactId>
@ -104,6 +104,13 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-ref</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -203,6 +210,14 @@
</configfiles>
</configuration>
<deployables>
<deployable>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-ref</artifactId>
<type>war</type>
<properties>
<context>ref</context>
</properties>
</deployable>
<deployable>
<properties>
<context>stub</context>

View File

@ -0,0 +1,44 @@
/*
* 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.fit.ref;
import static org.junit.Assert.assertEquals;
import java.net.HttpURLConnection;
import java.net.URL;
import org.junit.Test;
public class PingITCase {
private static final String REF_SERVICE = "http://localhost:9080/ref/odata.svc/";
@Test
public void ping() throws Exception {
URL url = new URL(REF_SERVICE);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
assertEquals(200, code);
}
}

View File

@ -36,12 +36,12 @@
</parent>
<modules>
<module>server-api</module>
<module>server-core</module>
<module>client-api</module>
<module>client-core</module>
<module>commons-api</module>
<module>commons-core</module>
<module>ref</module>
<module>client-api</module>
<module>client-core</module>
<module>server-api</module>
<module>server-core</module>
<module>server-ref</module>
</modules>
</project>

View File

@ -1,50 +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>olingo-ref</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-lib</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-client-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,26 +1,26 @@
<?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
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
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.
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">
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>olingo-server-api</artifactId>
@ -40,6 +40,12 @@
<artifactId>olingo-commons-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,28 @@
/*
* 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.api;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface ODataHandler {
void process(HttpServletRequest request, HttpServletResponse response);
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.api;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
@ -35,6 +36,7 @@ public abstract class ODataServer {
* and avoid class loading issues also during hot deployment.
*/
final Object object = clazz.newInstance();
return (ODataServer) object;
} catch (final Exception e) {
@ -45,4 +47,6 @@ public abstract class ODataServer {
public abstract ODataSerializer getSerializer(ODataFormat format);
public abstract ODataHandler getHandler(EdmProvider edmProvider);
}

View File

@ -1,26 +1,26 @@
<?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
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
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.
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">
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>olingo-server-core</artifactId>
@ -45,7 +45,7 @@
<artifactId>olingo-commons-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
@ -66,10 +66,15 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.6</version>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@ -98,7 +103,7 @@
<listener>true</listener>
<visitor>true</visitor>
<!--maven antlr plugin has trouble with grammer import if the grammerfiles
are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
<libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory>
</configuration>
</plugin>

View File

@ -0,0 +1,81 @@
/*
* 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;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.server.api.ODataHandler;
import org.apache.olingo.server.api.ODataServer;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
public class ODataHandlerImpl implements ODataHandler {
private EdmProvider edmProvider;
private ODataServer server;
public ODataHandlerImpl(ODataServer server, EdmProvider edmProvider) {
this.edmProvider = edmProvider;
this.server = server;
}
@Override
public void process(HttpServletRequest request, HttpServletResponse response) {
try {
EdmProviderImpl edm = new EdmProviderImpl(edmProvider);
InputStream responseEntity = null;
if (request.getPathInfo().contains("$metadata")) {
ODataSerializer serializer = server.getSerializer(ODataFormat.XML);
responseEntity = serializer.metadataDocument(edm);
} else {
ODataSerializer serializer = server.getSerializer(ODataFormat.JSON);
responseEntity = serializer.serviceDocument(edm, "http//:root");
}
response.setStatus(200);
response.setContentType("application/json");
if (responseEntity != null) {
ServletOutputStream out = response.getOutputStream();
int curByte = -1;
if (responseEntity instanceof InputStream) {
while ((curByte = ((InputStream) responseEntity).read()) != -1) {
out.write((char) curByte);
}
((InputStream) responseEntity).close();
}
out.flush();
out.close();
}
} catch (Exception e) {
throw new ODataRuntimeException(e);
}
}
}

View File

@ -19,7 +19,9 @@
package org.apache.olingo.server.core;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.server.api.ODataHandler;
import org.apache.olingo.server.api.ODataServer;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.serializer.ODataJsonSerializer;
@ -44,4 +46,11 @@ public class ODataServerImpl extends ODataServer {
return serializer;
}
@Override
public ODataHandler getHandler(EdmProvider edmProvider) {
return new ODataHandlerImpl(this, edmProvider);
}
}

View File

@ -1,86 +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.servlet;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.olingo.server.api.edm.provider.EdmProvider;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.ODataServerImpl;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
public class ODataServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private HttpServletResponse resp;
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
this.resp = resp;
EdmProvider provider = createEdmProvider();
EdmProviderImpl edm = new EdmProviderImpl(provider);
ODataServerImpl impl = new ODataServerImpl();
InputStream responseEntity = null;
if (req.getPathInfo().contains("$metadata")) {
ODataSerializer serializer = impl.getSerializer(ODataFormat.XML);
responseEntity = serializer.metadataDocument(edm);
} else {
ODataSerializer serializer = impl.getSerializer(ODataFormat.JSON);
responseEntity = serializer.serviceDocument(edm, "http//:root");
}
sendResponse(responseEntity);
}
protected EdmProvider createEdmProvider() {
return null;
}
// TODO: check throws
private void sendResponse(final Object entity) throws IOException {
resp.setStatus(200);
resp.setContentType("application/json");
if (entity != null) {
ServletOutputStream out = resp.getOutputStream();
int curByte = -1;
if (entity instanceof InputStream) {
while ((curByte = ((InputStream) entity).read()) != -1) {
out.write((char) curByte);
}
((InputStream) entity).close();
} else if (entity instanceof String) {
String body = (String) entity;
out.write(body.getBytes("utf-8"));
}
out.flush();
out.close();
}
}
}

View File

@ -1,52 +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.testutil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
public class StringUtils {
public static String inputStreamToString(final InputStream in, final boolean preserveLineBreaks) {
try {
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, Charset.forName("UTF-8")));
final StringBuilder stringBuilder = new StringBuilder();
String line = null;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
if (preserveLineBreaks) {
stringBuilder.append("\n");
}
}
bufferedReader.close();
final String result = stringBuilder.toString();
return result;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,20 @@
#
# 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

83
lib/server-ref/pom.xml Normal file
View File

@ -0,0 +1,83 @@
<?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>olingo-server-ref</artifactId>
<packaging>war</packaging>
<name>${project.artifactId}</name>
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-lib</artifactId>
<version>0.1.0-SNAPSHOT</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>olingo-server-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-core</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,51 @@
/*
* 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.ref;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.olingo.server.api.ODataHandler;
import org.apache.olingo.server.api.ODataServer;
import org.apache.olingo.server.ref.provider.EdmTechProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReferenceServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ReferenceServlet.class);
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
LOG.debug("ReferenceServlet:service() called");
ODataHandler handler = ODataServer.newInstance().getHandler(new EdmTechProvider());
handler.process(req, resp);
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.ArrayList;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import java.util.ArrayList;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil.techprovider;
package org.apache.olingo.server.ref.provider;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.server.api.edm.provider.TypeDefinition;

View File

@ -0,0 +1,20 @@
#
# 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

View File

@ -0,0 +1,42 @@
<?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.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Apache Olingo OData 4.0 Reference Scenario Service</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ODataServlet</servlet-name>
<servlet-class>org.apache.olingo.server.ref.ReferenceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ODataServlet</servlet-name>
<url-pattern>/odata.svc/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -0,0 +1,32 @@
<html>
<!--
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.
-->
<body>
<h1>Olingo OData 4.0 Reference Scenario Service</h1>
<hr>
<h2>Reference Scenario Service</h2>
<lu>
<li><a href="odata.svc/">Service Document</a></li>
<li><a href="odata.svc/$metadata">Metadata</a></li>
</lu>
</body>
</html>

View File

@ -28,6 +28,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
@ -36,7 +37,6 @@ import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.server.api.ODataServer;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.testutil.StringUtils;
import org.junit.Before;
import org.junit.Test;
@ -116,7 +116,7 @@ public class ServiceDocumentTest {
InputStream result = serializer.serviceDocument(edm, serviceRoot);
assertNotNull(result);
String jsonString = StringUtils.inputStreamToString(result, true);
String jsonString = IOUtils.toString(result);
assertTrue(jsonString.contains("entitySetName1"));
assertTrue(jsonString.contains("entitySetName2"));

View File

@ -22,11 +22,13 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.Edm;
@ -56,8 +58,7 @@ import org.apache.olingo.server.api.edm.provider.TypeDefinition;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.StringUtils;
import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
import org.apache.olingo.server.ref.provider.EdmTechProvider;
import org.junit.Test;
public class MetadataDocumentTest {
@ -76,12 +77,13 @@ public class MetadataDocumentTest {
}
@Test
public void writeMetadataWithLocalTestEdm() {
public void writeMetadataWithLocalTestEdm() throws Exception {
ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
Edm edm = new EdmProviderImpl(new TestMetadataProvider());
InputStream metadata = serializer.metadataDocument(edm);
assertNotNull(metadata);
String metadataString = StringUtils.inputStreamToString(metadata, false);
String metadataString = IOUtils.toString(metadata);
assertTrue(metadataString
.contains("<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">"));

View File

@ -36,8 +36,6 @@ import org.apache.olingo.server.api.uri.UriInfoResource;
import org.apache.olingo.server.api.uri.UriInfoService;
import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl;
import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
@ -52,6 +50,8 @@ import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.ref.provider.EntityTypeProvider;
import org.junit.Test;
public class UriInfoImplTest {

View File

@ -41,12 +41,12 @@ import org.apache.olingo.server.core.edm.provider.EdmComplexTypeImpl;
import org.apache.olingo.server.core.edm.provider.EdmEntitySetImpl;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.edm.provider.EdmSingletonImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.ref.provider.ActionProvider;
import org.apache.olingo.server.ref.provider.ComplexTypeProvider;
import org.apache.olingo.server.ref.provider.EntityTypeProvider;
import org.junit.Test;
public class UriResourceImplTest {

View File

@ -30,15 +30,15 @@ import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKin
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
import org.apache.olingo.server.ref.provider.ComplexTypeProvider;
import org.apache.olingo.server.ref.provider.EntityTypeProvider;
import org.apache.olingo.server.ref.provider.EnumTypeProvider;
import org.apache.olingo.server.ref.provider.PropertyProvider;
import org.junit.Test;
public class TestFullResourcePath {

View File

@ -28,14 +28,14 @@ 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.MethodKind;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
import org.apache.olingo.server.ref.provider.ComplexTypeProvider;
import org.apache.olingo.server.ref.provider.EntityTypeProvider;
import org.apache.olingo.server.ref.provider.PropertyProvider;
import org.junit.Test;
public class TestUriParserImpl {

View File

@ -28,11 +28,11 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.server.api.uri.UriInfoResource;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.UriInfoImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.AliasImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.junit.Test;
//TOOD add getKind check to all

View File

@ -36,15 +36,15 @@ import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitEx
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
import org.apache.olingo.server.core.testutil.techprovider.FunctionProvider;
import org.apache.olingo.server.core.uri.UriInfoImpl;
import org.apache.olingo.server.core.uri.UriResourceActionImpl;
import org.apache.olingo.server.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.testutil.FilterTreeToText;
import org.apache.olingo.server.ref.provider.ActionProvider;
import org.apache.olingo.server.ref.provider.EntityTypeProvider;
import org.apache.olingo.server.ref.provider.EnumTypeProvider;
import org.apache.olingo.server.ref.provider.FunctionProvider;
import org.junit.Test;
public class ExpressionTest {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.server.core.testutil;
package org.apache.olingo.server.core.uri.testutil;
import java.util.Arrays;
import java.util.List;
@ -29,7 +29,7 @@ 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.Property;
import org.apache.olingo.server.api.edm.provider.PropertyRef;
import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
import org.apache.olingo.server.ref.provider.EdmTechProvider;
/**
* Implement the EdmTechProvider and

View File

@ -26,9 +26,9 @@ 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;
import org.apache.olingo.server.core.testutil.EdmTechProvider;
import org.apache.olingo.server.core.uri.parser.Parser;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.ref.provider.EdmTechProvider;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;