Repository: olingo-odata4 Updated Branches: refs/heads/OLINGO-562_SpringExtension f4a1f4345 -> ec82a5d11
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd ---------------------------------------------------------------------- diff --git a/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd b/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd new file mode 100644 index 0000000..bff82f0 --- /dev/null +++ b/ext/spring/src/main/resources/org/apache/olingo/ext/spring/config/spring-olingo.xsd @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + + 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. + +--> +<xsd:schema xmlns="http://olingo.apache.org/schema/olingo/spring-olingo" + xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://olingo.apache.org/schema/olingo/spring-olingo" + elementFormDefault="qualified" attributeFormDefault="unqualified"> + + <xsd:import namespace="http://www.springframework.org/schema/beans" + schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" /> + + <!-- Edm provider --> + + <xsd:attributeGroup name="configurationAttributes"> + <xsd:attribute name="id" type="xsd:string" use="required" /> + </xsd:attributeGroup> + + <xsd:element name="edm-provider" type="edmProviderBeanType"> + </xsd:element> + + <xsd:complexType name="edmProviderBeanType"> + <xsd:sequence> + <xsd:element name="schema" maxOccurs="unbounded" type="schemaBeanType"/> + </xsd:sequence> + <xsd:attribute name="id" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="schemaBeanType"> + <xsd:sequence> + <xsd:element name="entityContainer" minOccurs="1" maxOccurs="1" type="entityContainerBeanType"/> + <xsd:element name="entityType" minOccurs="0" maxOccurs="unbounded" type="entityTypeBeanType"/> + <xsd:element name="complexType" minOccurs="0" maxOccurs="unbounded" type="complexTypeBeanType"/> + </xsd:sequence> + <xsd:attribute name="namespace" type="xsd:string" use="required"/> + <xsd:attribute name="alias" type="xsd:string"/> + </xsd:complexType> + + <xsd:complexType name="entityContainerBeanType"> + <xsd:sequence> + <xsd:element name="entitySet" minOccurs="0" maxOccurs="unbounded" type="entitySetBeanType"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="entitySetBeanType"> + <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="type" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="entityTypeBeanType"> + <xsd:sequence> + <xsd:element name="key" minOccurs="1" maxOccurs="unbounded" type="entityTypeKeyBeanType"/> + <xsd:element name="property" minOccurs="1" maxOccurs="unbounded" type="entityTypePropertyBeanType"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="entityTypeKeyBeanType"> + <xsd:attribute name="property-name" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="entityTypePropertyBeanType"> + <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="type" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="complexTypeBeanType"> + <xsd:attribute name="name" type="xsd:string" use="required"/> + </xsd:complexType> + + <!-- Http handler --> + + <xsd:element name="http-handler" type="httpHandlerBeanType"> + </xsd:element> + + <xsd:complexType name="httpHandlerBeanType"> + <xsd:sequence> + <xsd:element name="reference" minOccurs="1" maxOccurs="unbounded" type="referenceBeanType"/> + <xsd:element name="processor" maxOccurs="unbounded" type="processorBeanType"/> + </xsd:sequence> + <xsd:attribute name="id" type="xsd:string" use="required"/> + <xsd:attribute name="edm-provider" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="referenceBeanType"> + <xsd:sequence> + <xsd:element name="include" maxOccurs="unbounded" type="referenceIncludeBeanType"/> + </xsd:sequence> + <xsd:attribute name="uri" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="referenceIncludeBeanType"> + <xsd:attribute name="key" type="xsd:string" use="required"/> + <xsd:attribute name="value" type="xsd:string" use="required"/> + </xsd:complexType> + + <xsd:complexType name="processorBeanType"> + <xsd:attribute name="ref" type="xsd:string" use="required"/> + </xsd:complexType> + +</xsd:schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java new file mode 100644 index 0000000..36fe33b --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoEdmProviderWithoutNamespaceTest.java @@ -0,0 +1,85 @@ +/* + * 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.ext.spring.config; + +import java.util.List; + +import org.apache.olingo.commons.api.ODataException; +import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityType; +import org.apache.olingo.commons.api.edm.provider.CsdlProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef; +import org.apache.olingo.commons.api.edm.provider.CsdlSchema; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringOlingoEdmProviderWithoutNamespaceTest { + @Test + public void testLaunchSpring() { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + "/applicationContext-edm-provider-beans.xml"); + try { + CsdlEdmProvider edmProvider = (CsdlEdmProvider) context + .getBean("edmProvider"); + Assert.assertNotNull(edmProvider); + try { + CsdlEntityContainer entityContainer = edmProvider.getEntityContainer(); + Assert.assertNotNull(entityContainer); + Assert.assertNotNull(entityContainer.getEntitySets()); + Assert.assertEquals(1, entityContainer.getEntitySets().size()); + + List<CsdlSchema> schemas = edmProvider.getSchemas(); + Assert.assertNotNull(schemas); + Assert.assertEquals(1, schemas.size()); + + CsdlSchema schema = schemas.get(0); + Assert.assertEquals("test", schema.getNamespace()); + + List<CsdlEntityType> entityTypes = schema.getEntityTypes(); + Assert.assertNotNull(entityTypes); + Assert.assertEquals(1, entityTypes.size()); + + CsdlEntityType entityType = entityTypes.get(0); + Assert.assertEquals("sources1", entityType.getName()); + + + List<CsdlProperty> properties = entityType.getProperties(); + Assert.assertNotNull(properties); + Assert.assertEquals(1, properties.size()); + CsdlProperty property0 = properties.get(0); + Assert.assertEquals("field1", property0.getName()); + Assert.assertEquals("Edm.String", property0.getType().toString()); + + List<CsdlPropertyRef> key = entityType.getKey(); + Assert.assertNotNull(key); + Assert.assertEquals(1, key.size()); + CsdlPropertyRef key0 = key.get(0); + Assert.assertEquals("field1", key0.getName()); + } catch (ODataException ex) { + ex.printStackTrace(); + } + } finally { + if (context != null) { + context.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java new file mode 100644 index 0000000..5e402a6 --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoHttpHandlerWithoutNamespaceTest.java @@ -0,0 +1,41 @@ +/* + * 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.ext.spring.config; + +import org.apache.olingo.server.api.ODataHttpHandler; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringOlingoHttpHandlerWithoutNamespaceTest { + @Test + public void testLaunchSpring() { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + "/applicationContext-http-handler-beans.xml"); + try { + ODataHttpHandler httpHandler = (ODataHttpHandler) context + .getBean("httpHandler"); + Assert.assertNotNull(httpHandler); + } finally { + if (context != null) { + context.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java new file mode 100644 index 0000000..e1380e5 --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceEdmProviderTest.java @@ -0,0 +1,105 @@ +/* + * 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.ext.spring.config; + +import java.util.List; + +import org.apache.olingo.commons.api.ODataException; +import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityType; +import org.apache.olingo.commons.api.edm.provider.CsdlProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef; +import org.apache.olingo.commons.api.edm.provider.CsdlSchema; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringOlingoNamespaceEdmProviderTest { + @Test + public void testLaunchSpring() { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + "/applicationContext-edm-provider-namespace.xml"); + try { + CsdlEdmProvider edmProvider = (CsdlEdmProvider) context + .getBean("edmProvider"); + Assert.assertNotNull(edmProvider); + try { + CsdlEntityContainer entityContainer = edmProvider.getEntityContainer(); + Assert.assertNotNull(entityContainer); + Assert.assertNotNull(entityContainer.getEntitySets()); + Assert.assertEquals(1, entityContainer.getEntitySets().size()); + + List<CsdlSchema> schemas = edmProvider.getSchemas(); + Assert.assertNotNull(schemas); + Assert.assertEquals(1, schemas.size()); + + CsdlSchema schema = schemas.get(0); + Assert.assertEquals("test", schema.getNamespace()); + + List<CsdlEntityType> entityTypes = schema.getEntityTypes(); + Assert.assertNotNull(entityTypes); + Assert.assertEquals(1, entityTypes.size()); + + CsdlEntityType entityType = entityTypes.get(0); + Assert.assertEquals("sources1", entityType.getName()); + + List<CsdlProperty> properties = entityType.getProperties(); + Assert.assertNotNull(properties); + Assert.assertEquals(6, properties.size()); + // field #0 + CsdlProperty property0 = properties.get(0); + Assert.assertEquals("field1", property0.getName()); + Assert.assertEquals("Edm.String", property0.getType().toString()); + // field #1 + CsdlProperty property1 = properties.get(1); + Assert.assertEquals("field2", property1.getName()); + Assert.assertEquals("Edm.Int32", property1.getType().toString()); + // field #2 + CsdlProperty property2 = properties.get(2); + Assert.assertEquals("field3", property2.getName()); + Assert.assertEquals("Edm.Int64", property2.getType().toString()); + // field #3 + CsdlProperty property3 = properties.get(3); + Assert.assertEquals("field4", property3.getName()); + Assert.assertEquals("Edm.Double", property3.getType().toString()); + // field #4 + CsdlProperty property4 = properties.get(4); + Assert.assertEquals("field5", property4.getName()); + Assert.assertEquals("Edm.Double", property4.getType().toString()); + // field #5 + CsdlProperty property5 = properties.get(5); + Assert.assertEquals("field6", property5.getName()); + Assert.assertEquals("Edm.Boolean", property5.getType().toString()); + + List<CsdlPropertyRef> key = entityType.getKey(); + Assert.assertNotNull(key); + Assert.assertEquals(1, key.size()); + CsdlPropertyRef key0 = key.get(0); + Assert.assertEquals("field1", key0.getName()); + } catch (ODataException ex) { + ex.printStackTrace(); + } + } finally { + if (context != null) { + context.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java new file mode 100644 index 0000000..00d4b4d --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/SpringOlingoNamespaceHttpHandlerTest.java @@ -0,0 +1,41 @@ +/* + * 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.ext.spring.config; + +import org.apache.olingo.server.api.ODataHttpHandler; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringOlingoNamespaceHttpHandlerTest { + @Test + public void testLaunchSpring() { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + "/applicationContext-http-handler-namespace.xml"); + try { + ODataHttpHandler httpHandler = (ODataHttpHandler) context + .getBean("httpHandler"); + Assert.assertNotNull(httpHandler); + } finally { + if (context != null) { + context.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java new file mode 100644 index 0000000..b60c45e --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/config/TestProcessor.java @@ -0,0 +1,33 @@ +/* + * 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.ext.spring.config; + +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.ServiceMetadata; +import org.apache.olingo.server.api.processor.Processor; + +public class TestProcessor implements Processor { + + @Override + public void init(OData arg0, ServiceMetadata arg1) { + // TODO Auto-generated method stub + + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/OlingoSpringTestServlet.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/OlingoSpringTestServlet.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/OlingoSpringTestServlet.java new file mode 100644 index 0000000..e0357b3 --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/OlingoSpringTestServlet.java @@ -0,0 +1,36 @@ +/* + * 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.ext.spring.integration; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; + +import org.apache.olingo.ext.spring.OlingoSpringServlet; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class OlingoSpringTestServlet extends OlingoSpringServlet { + + @Override + protected ApplicationContext initializeApplicationContext(ServletConfig config) + throws ServletException { + return new ClassPathXmlApplicationContext("/applicationContext-namespace.xml"); + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/SpringOlingoNamespaceIntegrationTest.java ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/SpringOlingoNamespaceIntegrationTest.java b/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/SpringOlingoNamespaceIntegrationTest.java new file mode 100644 index 0000000..e0e2f95 --- /dev/null +++ b/ext/spring/src/test/java/org/apache/olingo/ext/spring/integration/SpringOlingoNamespaceIntegrationTest.java @@ -0,0 +1,185 @@ +/* + * 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.ext.spring.integration; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest; +import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest; +import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; +import org.apache.olingo.client.api.ODataClient; +import org.apache.olingo.client.api.domain.ClientServiceDocument; +import org.apache.olingo.client.core.ODataClientFactory; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmComplexType; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.EdmSchema; +import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SpringOlingoNamespaceIntegrationTest { + private static Server server; + private static ServletHolder GET_VOCABULARIES_SERVLET = new ServletHolder(new HttpServlet() { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if("/Org.OData.Core.V1.xml".equals(req.getPathInfo())) { + resp.setStatus(HttpStatus.OK_200); + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("Org.OData.Core.V1.xml"); + copy(is, resp.getOutputStream()); + } else { + resp.setStatus(HttpStatus.EXPECTATION_FAILED_417); + } + } + }); + + private static void configureAndStartupEmbeddedWebServer(Class<? extends HttpServlet> odataServletClass) + throws Exception { + server = startupEmbeddedWebServer(); + ServletHandler handler = (ServletHandler) server.getHandler(); + handler.addServletWithMapping(odataServletClass, "/odata.svc/*"); + handler.addServletWithMapping(GET_VOCABULARIES_SERVLET, "/v4.0/cs02/vocabularies/*"); + server.start(); + } + + private static void copy(InputStream is, OutputStream os) throws IOException { + byte[] buffer = new byte[1024]; + int readCount; + while((readCount = is.read(buffer)) >= 0) { + os.write(buffer, 0, readCount); + } + + os.flush(); + } + + private static Server startupEmbeddedWebServer() throws Exception { + Server server = new Server(8080); + ServletHandler handler = new ServletHandler(); + server.setHandler(handler); + //server.start(); + + return server; + } + + private static void shutdownEmbeddedWebServer() throws Exception { + if (server!=null) { + server.stop(); + server.join(); + server.destroy(); + } + } + + @BeforeClass + public static void setUp() throws Exception { + configureAndStartupEmbeddedWebServer(OlingoSpringTestServlet.class); + } + + @AfterClass + public static void tearDown() throws Exception { + shutdownEmbeddedWebServer(); + } + + //@Test + public void testServiceDocument() { + String serviceRoot = "http://localhost:8080/odata.svc"; + + ODataClient client = ODataClientFactory.getClient(); + ODataServiceDocumentRequest req = + client.getRetrieveRequestFactory().getServiceDocumentRequest(serviceRoot); + req.setContentType("application/json;odata.metadata=minimal"); + req.setAccept("application/json;odata.metadata=minimal"); + ODataRetrieveResponse<ClientServiceDocument> res = req.execute(); + + ClientServiceDocument serviceDocument = res.getBody(); + + Collection<String> entitySetNames = serviceDocument.getEntitySetNames(); + Assert.assertEquals(1, entitySetNames.size()); + String entitySetName = entitySetNames.iterator().next(); + Assert.assertEquals("sources1", entitySetName); + + Map<String,URI> entitySets = serviceDocument.getEntitySets(); + Assert.assertEquals(1, entitySets.size()); + Entry<String, URI> entitySet = entitySets.entrySet().iterator().next(); + Assert.assertEquals("sources1", entitySet.getKey()); + Assert.assertEquals("http://localhost:8080/odata.svc/sources1", entitySet.getValue().toString()); + + Map<String,URI> singletons = serviceDocument.getSingletons(); + Assert.assertEquals(0, singletons.size()); + + Map<String,URI> functionImports = serviceDocument.getFunctionImports(); + Assert.assertEquals(0, functionImports.size()); + } + + @Test + public void testMetadata() throws InterruptedException { + //Thread.sleep(60000); + String serviceRoot = "http://localhost:8080/odata.svc"; + // http://localhost:8080/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml + + ODataClient client = ODataClientFactory.getClient(); + EdmMetadataRequest request = + client.getRetrieveRequestFactory().getMetadataRequest(serviceRoot); + ODataRetrieveResponse<Edm> response = request.execute(); + + Edm edm = response.getBody(); + + List<EdmSchema> schemas = edm.getSchemas(); + for (EdmSchema schema : schemas) { + System.out.println(schema.getNamespace()); + System.out.println(">> schema.getComplexTypes() size = "+schema.getComplexTypes().size()); + for (EdmComplexType complexType : schema.getComplexTypes()) { + System.out.println("- complex type = "+complexType); + } + System.out.println(">> schema.getEntityTypes() size = "+schema.getEntityTypes().size()); + for (EdmEntityType entityType : schema.getEntityTypes()) { + System.out.println("- entity type = "+entityType); + System.out.println(" >> qn = "+entityType.getFullQualifiedName()); + } + } + + //edm.get + // TODO: check model +// EdmEntityType customerType = edm.getEntityType( +// new FullQualifiedName("NorthwindModel", "Order")); +// List<String> propertyNames = customerType.getPropertyNames(); +// for (String propertyName : propertyNames) { +// System.out.println(" - propertyName = "+propertyName); +// EdmProperty property = customerType.getStructuralProperty(propertyName); +// FullQualifiedName typeName = property.getType().getFullQualifiedName(); +// System.out.println(" - type name = "+typeName); +// } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/Org.OData.Core.V1.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/Org.OData.Core.V1.xml b/ext/spring/src/test/resources/Org.OData.Core.V1.xml new file mode 100644 index 0000000..a7a6b91 --- /dev/null +++ b/ext/spring/src/test/resources/Org.OData.Core.V1.xml @@ -0,0 +1,125 @@ +<?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. + +--> +<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> + <edmx:DataServices> + <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Org.OData.Core.V1" Alias="Core"> + <Annotation Term="Core.Description"> + <String>Core terms needed to write vocabularies</String> + </Annotation> + + <!--Documentation --> + + <Term Name="Description" Type="Edm.String"> + <Annotation Term="Core.Description" String="A brief description of a model element" /> + <Annotation Term="Core.IsLanguageDependent" /> + </Term> + + <Term Name="LongDescription" Type="Edm.String"> + <Annotation Term="Core.Description" String="A lengthy description of a model element" /> + <Annotation Term="Core.IsLanguageDependent" /> + </Term> + + <!-- Localization --> + + <Term Name="IsLanguageDependent" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term"> + <Annotation Term="Core.Description" String="Properties and terms annotated with this term are language-dependent" /> + <Annotation Term="Core.RequiresType" String="Edm.String" /> + </Term> + + <!-- Term Restrictions --> + + <TypeDefinition Name="Tag" UnderlyingType="Edm.Boolean"> + <Annotation Term="Core.Description" String="This is the type to use for all tagging terms" /> + </TypeDefinition> + + <Term Name="RequiresType" Type="Edm.String" AppliesTo="Term"> + <Annotation Term="Core.Description" + String="Properties and terms annotated with this annotation MUST have a type that is identical to or derived from the given type name" /> + </Term> + + <!--Resource Paths --> + + <Term Name="ResourcePath" Type="Edm.String" AppliesTo="EntitySet Singleton ActionImport FunctionImport"> + <Annotation Term="Core.Description" + String="Resource path for entity container child, can be relative to xml:base and the request URL" /> + <Annotation Term="Core.IsUrl" /> + </Term> + + <Term Name="DereferenceableIDs" Type="Core.Tag" DefaultValue="true" AppliesTo="EntityContainer"> + <Annotation Term="Core.Description" String="Entity-ids are URLs that locate the identified entity" /> + </Term> + + <Term Name="ConventionalIDs" Type="Core.Tag" DefaultValue="true" AppliesTo="EntityContainer"> + <Annotation Term="Core.Description" String="Entity-ids follow OData URL conventions" /> + </Term> + + <!-- Permissions --> + + <Term Name="Permissions" Type="Core.Permission" AppliesTo="Property"> + <Annotation Term="Core.Description" String="Permissions available for a property.The value of 2 is reserved for future use." /> + </Term> + <EnumType Name="Permission" IsFlags="true"> + <Member Name="None" Value="0" /> + <Member Name="Read" Value="1" /> + <Member Name="ReadWrite" Value="3" /> + </EnumType> + + <!-- Metadata Extensions --> + + <Term Name="Immutable" Type="Core.Tag" DefaultValue="true" AppliesTo="Property"> + <Annotation Term="Core.Description" + String="A value for this non-key property can be provided on insert and remains unchanged on update" /> + </Term> + + <Term Name="Computed" Type="Core.Tag" DefaultValue="true" AppliesTo="Property"> + <Annotation Term="Core.Description" String="A value for this property is generated on both insert and update" /> + </Term> + + <Term Name="IsURL" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term"> + <Annotation Term="Core.Description" String="Properties and terms annotated with this term MUST contain a valid URL" /> + <Annotation Term="Core.RequiresType" String="Edm.String" /> + </Term> + + <Term Name="AcceptableMediaTypes" Type="Collection(Edm.String)" AppliesTo="EntityType Property"> + <Annotation Term="Core.Description" + String="Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property" /> + <Annotation Term="Core.IsMediaType" /> + </Term> + + <Term Name="MediaType" Type="Edm.String" AppliesTo="Property"> + <Annotation Term="Core.IsMediaType" /> + <Annotation Term="Core.RequiresType" String="Edm.Binary" /> + </Term> + + <Term Name="IsMediaType" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term"> + <Annotation Term="Core.Description" String="Properties and terms annotated with this term MUST contain a valid MIME type" /> + <Annotation Term="Core.RequiresType" String="Edm.String" /> + </Term> + + <Term Name="OptimisticConcurrency" Type="Collection(Edm.PropertyPath)" AppliesTo="EntitySet"> + <Annotation Term="Core.Description" + String="Data modification requires the use of Etags. A non-empty collection contains the set of properties that are used to compute the ETag" /> + </Term> + + </Schema> + </edmx:DataServices> +</edmx:Edmx> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml b/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml new file mode 100644 index 0000000..53e6323 --- /dev/null +++ b/ext/spring/src/test/resources/applicationContext-edm-provider-beans.xml @@ -0,0 +1,99 @@ +<?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. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/spring-olingo" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://olingo.apache.org/schema/spring-olingo + http://olingo.apache.org/schema/olingo/spring-olingo.xsd"> + + <!-- + <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> + <property name="customEditors"> + <map> + <entry key="org.apache.olingo.commons.api.edm.FullQualifiedName" + value="org.apache.olingo.ext.spring.editor.FullQualifiedNameEditor" /> + </map> + </property> + </bean> + --> + + <bean id="conversionService" + class="org.springframework.context.support.ConversionServiceFactoryBean"> + <property name="converters"> + <set> + <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/> + <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/> + </set> + </property> + </bean> + + <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider"> + <property name="schemas"> + <list> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlSchema"> + <property name="namespace" value="test" /> + <property name="entityContainer"> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer"> + <property name="entitySets"> + <list> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlEntitySet"> + <property name="name" value="sources1" /> + <property name="type" value="ns.sources1" /> + <!--<property name="type">--> + <!--<bean class="org.apache.olingo.commons.api.edm.FullQualifiedName">--> + <!--<constructor-arg value="ns.sources1"/>--> + <!--</bean>--> + <!--</property>--> + </bean> + </list> + </property> + </bean> + </property> + <property name="entityTypes"> + <list> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlEntityType"> + <property name="name" value="sources1" /> + <property name="key"> + <list> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef"> + <property name="name" value="field1" /> + </bean> + </list> + </property> + <property name="properties"> + <list> + <bean class="org.apache.olingo.commons.api.edm.provider.CsdlProperty"> + <property name="name" value="field1" /> + <property name="type" value="Edm.String" /> + </bean> + </list> + </property> + </bean> + </list> + </property> + </bean> + </list> + </property> + </bean> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml b/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml new file mode 100644 index 0000000..d59fb0a --- /dev/null +++ b/ext/spring/src/test/resources/applicationContext-edm-provider-namespace.xml @@ -0,0 +1,74 @@ +<?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. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://olingo.apache.org/schema/olingo/spring-olingo + http://olingo.apache.org/schema/olingo/spring-olingo.xsd"> + + <bean id="conversionService" + class="org.springframework.context.support.ConversionServiceFactoryBean"> + <property name="converters"> + <set> + <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/> + <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/> + </set> + </property> + </bean> + + <olingo:edm-provider id="edmProvider"> + <olingo:schema namespace="test" alias=""> + <olingo:entityContainer> + <olingo:entitySet name="sources1" type="sources1"/> + </olingo:entityContainer> + <!-- EnumType --> + <!-- getTypeDefinition --> + <olingo:entityType name="sources1"> + <olingo:key property-name="field1"/> + + <olingo:property name="field1" type="Edm.String"/> + <olingo:property name="field2" type="Edm.Int32"/> + <olingo:property name="field3" type="Edm.Int64"/> + <olingo:property name="field4" type="Edm.Double"/> + <olingo:property name="field5" type="Edm.Double"/> + <olingo:property name="field6" type="Edm.Boolean"/> + </olingo:entityType> + +<!-- <edm:complexType name="test"> --> +<!-- </edm:complexType> --> + + <!-- getActions --> + <!-- getFunctions --> + <!-- getTerm --> + <!-- getEntitySet --> + <!-- getSingleton --> + <!-- getActionImport --> + <!-- getFunctionImport --> + <!-- getEntityContainerInfo --> + <!-- getAliasInfos --> + <!-- getSchemas --> + <!-- getEntityContainer --> + </olingo:schema> + </olingo:edm-provider> +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml b/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml new file mode 100644 index 0000000..37c14d7 --- /dev/null +++ b/ext/spring/src/test/resources/applicationContext-http-handler-beans.xml @@ -0,0 +1,74 @@ +<?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. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:olingo="http://olingo.apache.org/schema/spring-olingo" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://olingo.apache.org/schema/spring-olingo + http://olingo.apache.org/schema/olingo/spring-olingo.xsd"> + + <bean id="conversionService" + class="org.springframework.context.support.ConversionServiceFactoryBean"> + <property name="converters"> + <set> + <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/> + <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/> + </set> + </property> + </bean> + + <bean id="odata" class="org.apache.olingo.ext.spring.factory.ODataFactoryBean" /> + + <bean id="httpHandler" + class="org.apache.olingo.ext.spring.factory.ODataHttpHandlerFactoryBean"> + <property name="odata" ref="odata" /> + <property name="serviceMetadata"> + <bean class="org.apache.olingo.ext.spring.factory.ServiceMetadataFactoryBean"> + <property name="odata" ref="odata" /> + <property name="edmProvider" ref="edmProvider" /> + <property name="references"> + <list> + <bean class="org.apache.olingo.ext.spring.factory.EdmxReferenceFactoryBean"> + <property name="uri" + value="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml" /> + <property name="includes"> + <map> + <entry key="Org.OData.Core.V1" value="Core" /> + </map> + </property> + </bean> + </list> + </property> + </bean> + </property> + <property name="processors"> + <list> + <ref bean="testProcessor" /> + </list> + </property> + </bean> + + <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider" /> + + <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" /> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml b/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml new file mode 100644 index 0000000..e40b29d --- /dev/null +++ b/ext/spring/src/test/resources/applicationContext-http-handler-namespace.xml @@ -0,0 +1,50 @@ +<?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. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://olingo.apache.org/schema/olingo/spring-olingo + http://olingo.apache.org/schema/olingo/spring-olingo.xsd"> + + <olingo:http-handler id="httpHandler" edm-provider="edmProvider"> + <olingo:reference uri="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"> + <olingo:include key="Org.OData.Core.V1" value="Core"/> + </olingo:reference> + <olingo:processor ref="testProcessor"/> + </olingo:http-handler> + + <bean id="conversionService" + class="org.springframework.context.support.ConversionServiceFactoryBean"> + <property name="converters"> + <set> + <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/> + <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/> + </set> + </property> + </bean> + + <bean id="edmProvider" class="org.apache.olingo.ext.spring.edm.GenericEdmProvider" /> + + <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" /> +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ec82a5d1/ext/spring/src/test/resources/applicationContext-namespace.xml ---------------------------------------------------------------------- diff --git a/ext/spring/src/test/resources/applicationContext-namespace.xml b/ext/spring/src/test/resources/applicationContext-namespace.xml new file mode 100644 index 0000000..4e0c384 --- /dev/null +++ b/ext/spring/src/test/resources/applicationContext-namespace.xml @@ -0,0 +1,68 @@ +<?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. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:olingo="http://olingo.apache.org/schema/olingo/spring-olingo" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://olingo.apache.org/schema/olingo/spring-olingo + http://olingo.apache.org/schema/olingo/spring-olingo.xsd"> + + <olingo:http-handler id="httpHandler" edm-provider="edmProvider"> + <olingo:reference uri="../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"> + <olingo:include key="Org.OData.Core.V1" value="Core"/> + </olingo:reference> + <olingo:processor ref="testProcessor"/> + </olingo:http-handler> + + <olingo:edm-provider id="edmProvider"> + <olingo:schema namespace="test" alias=""> + <olingo:entityContainer> + <olingo:entitySet name="sources1" type="sources1"/> + </olingo:entityContainer> + <!-- EnumType --> + <!-- getTypeDefinition --> + <olingo:entityType name="sources1"> + <olingo:key property-name="field1"/> + + <olingo:property name="field1" type="Edm.String"/> + <olingo:property name="field2" type="Edm.Int32"/> + <olingo:property name="field3" type="Edm.Int64"/> + <olingo:property name="field4" type="Edm.Double"/> + <olingo:property name="field5" type="Edm.Double"/> + <olingo:property name="field6" type="Edm.Boolean"/> + </olingo:entityType> + </olingo:schema> + </olingo:edm-provider> + + <bean id="testProcessor" class="org.apache.olingo.ext.spring.config.TestProcessor" /> + + <bean id="conversionService" + class="org.springframework.context.support.ConversionServiceFactoryBean"> + <property name="converters"> + <set> + <bean class="org.apache.olingo.ext.spring.editor.FullQualifiedNameConverter"/> + <bean class="org.apache.olingo.ext.spring.editor.ToFullQualifiedNameConverter"/> + </set> + </property> + </bean> +</beans> \ No newline at end of file
