You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/08/28 05:48:46 UTC
[39/51] [partial] rename folder /datajs into /odatajs. no file
modification.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/datajs/tests-tmp/endpoints/FoodStoreDataServiceV4.svc
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/endpoints/FoodStoreDataServiceV4.svc b/datajs/tests-tmp/endpoints/FoodStoreDataServiceV4.svc
deleted file mode 100644
index ac1cfe7..0000000
--- a/datajs/tests-tmp/endpoints/FoodStoreDataServiceV4.svc
+++ /dev/null
@@ -1,590 +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.
- */
--->
-
-<%@ ServiceHost Language="C#" Factory="Microsoft.OData.Service.DataServiceHostFactory, Microsoft.OData.Service, Version=6.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
- Service="DataJS.Tests.V4.FoodStoreDataService" %>
-
-namespace DataJS.Tests.V4
-{
- using System;
- using System.Collections.Generic;
- using Microsoft.OData.Service;
- using Microsoft.OData.Service.Providers;
- using System.Linq;
- using System.ServiceModel.Web;
- using System.Web;
- using System.IO;
- using Microsoft.Spatial;
-
- /// <summary>
- /// Provides a service similar to FoodStoreDataService, but uses V4 and WCF Data Services 6.0.0-beta1
- /// features.
- /// </summary>
- [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
- public class FoodStoreDataService : DataService<FoodContainer>
- {
- // This method is called only once to initialize service-wide policies.
- public static void InitializeService(DataServiceConfiguration config)
- {
- config.SetEntitySetAccessRule("*", EntitySetRights.All);
- config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
- config.UseVerboseErrors = true;
- // Set Foods page size to 5 for cache testing
- config.SetEntitySetPageSize("Foods", 5);
- // Make the Categories set paged to have a paged feed
- config.SetEntitySetPageSize("Categories", 1);
- }
-
- [WebInvoke]
- public string ResetData()
- {
- this.CurrentDataSource.ResetData();
- return "Data Reset";
- }
-
- [WebGet]
- public IQueryable<string> FoodsAvailable()
- {
- return this.CurrentDataSource.Foods.Select(food => food.Name);
- }
-
- [WebGet]
- public IQueryable<Package> PackagingTypes()
- {
- return this.CurrentDataSource.Foods.Select(food => food.Packaging);
- }
-
- [WebGet]
- public string UserNameAndPassword()
- {
- var request = WebOperationContext.Current.IncomingRequest;
- string authorization = request.Headers["Authorization"];
- if (String.IsNullOrEmpty(authorization))
- {
- WebOperationContext.Current.OutgoingResponse.Headers["WWW-Authenticate"] = "Basic realm=\"localhost\"";
- throw new DataServiceException(401, "Access denied in UserNameAndPassword");
- }
-
- return authorization;
- }
- }
-
- public class FoodContainer : ReflectionDataContext, IUpdatable, IDataServiceStreamProvider2
- {
- private static bool dataInitialized;
-
- public IQueryable<Category> Categories
- {
- get { return this.GetResourceSetEntities<Category>("Categories").AsQueryable(); }
- }
-
- public IQueryable<Food> Foods
- {
- get { return this.GetResourceSetEntities<Food>("Foods").AsQueryable(); }
- }
-
- public void ResetData()
- {
- this.ClearData();
-
- var builder = SpatialImplementation.CurrentImplementation.CreateBuilder();
- builder.GeometryPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);
- builder.GeometryPipeline.BeginGeometry(SpatialType.Collection);
- builder.GeometryPipeline.BeginFigure(new GeometryPosition(5.0, 5.0));
- builder.GeometryPipeline.EndFigure();
- builder.GeometryPipeline.EndGeometry();
-
- int i = 0;
- Category[] categories = new Category[]
- {
- new Category { CategoryID = i++, Name = "Baking Supplies" },
- new Category { CategoryID = i++, Name = "Condiments" },
- new Category { CategoryID = i++, Name = "Empty Category" }
- };
- Array.ForEach(categories, (category) => this.GetResourceSetEntities<Category>("Categories").Add(category));
-
- i = 0;
- Food[] foods = new Food[]
- {
- new Food()
- {
- FoodID = i++,
- Name = "flour",
- UnitPrice = .19999,
- ServingSize = 1,
- MeasurementUnit = "Cup",
- ProteinGrams = 3,
- FatGrams = 1,
- CarbohydrateGrams = 20,
- CaloriesPerServing = 140,
- IsAvailable = true,
- ExpirationDate = new DateTime(2010, 12, 25, 12, 0, 0),
- ItemGUID = new Guid("27272727272727272727272727272727"),
- Weight = 10f,
- AvailableUnits = 1,
-
- Packaging = new Package(){
- Type = null,
- Color = String.Empty,
- NumberPerPackage = int.MaxValue,
- RequiresRefridgeration = false,
- PackageDimensions = new Dimensions()
- {
- Length = Decimal.MaxValue,
- Height = Int16.MaxValue,
- Width = Int64.MaxValue,
- Volume = double.MaxValue,
- },
- ShipDate = new DateTime(2000, 12, 29)
- },
-
- CookedSize = new CookedDimensions()
- {
- Height = 1,
- Length = 2,
- Width = 3,
- Volume = 1 * 2 * 3
- },
-
- Category = categories[0],
-
- AlternativeNames = new List<string>() {"ground cereal", "ground grain"},
-
- Providers = new List<Provider> {
- new Provider() {
- Name= "Flour Provider",
- Aliases = new List<string>() {"fp1", "flour provider1"},
- Details = new ProviderDetails() {
- Telephone= "555-555-555",
- PreferredCode = 1001
- }
- },
- new Provider() {
- Name= "Ground Grains",
- Aliases = new List<string>()
- }
- },
-
- SpatialData = (GeometryCollection)builder.ConstructedGeometry
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "sugar",
- UnitPrice = .2,
- ServingSize = 1,
- MeasurementUnit = "tsp",
- ProteinGrams = 0,
- FatGrams = 0,
- CarbohydrateGrams = 4,
- CaloriesPerServing = 16,
- IsAvailable = false,
- ExpirationDate = new DateTime(2011, 12, 28),
- ItemGUID = new Guid("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"),
- Weight = 0.1f,
- AvailableUnits = 0,
-
- Packaging = new Package(){
- Type = " ",
- Color = "BLUE",
- NumberPerPackage = int.MinValue,
- RequiresRefridgeration = true,
- PackageDimensions = new Dimensions(){
- Length = Decimal.MinValue,
- Height = Int16.MinValue,
- Width = Int64.MinValue,
- Volume = double.MinValue,
- },
- ShipDate = new DateTime(2000, 12, 29),
- },
-
- Category = categories[1],
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "1 Chicken Egg",
- UnitPrice = 0.55,
- MeasurementUnit = null,
- ServingSize = 1,
- ProteinGrams = 6,
- FatGrams = 1,
- CarbohydrateGrams = 1,
- CaloriesPerServing = 70,
- IsAvailable = true,
- ExpirationDate = new DateTime(2000, 12, 29),
- ItemGUID = new Guid("00000000000000000000000000000000"),
- Weight = 0,
- AvailableUnits = -128,
-
- Packaging = new Package(){
- Type = "18 - Carton",
- Color = " brown ",
- NumberPerPackage = 0,
- RequiresRefridgeration = true,
- PackageDimensions = null,
- ShipDate = new DateTime(2000, 12, 29),
- },
-
- Category = null,
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Brown Sugar",
- UnitPrice = 1.6,
- ServingSize = 1,
- MeasurementUnit = "TSP.",
- ProteinGrams = 0,
- FatGrams = 0,
- CarbohydrateGrams = 5,
- CaloriesPerServing = 16,
- IsAvailable = true,
- ExpirationDate = new DateTime(2011, 12, 28),
- ItemGUID = new Guid("0123456789abcdef0123456789abcdef"),
- Weight = 4.5f,
- AvailableUnits = 127,
- Packaging = null,
- Category = categories[1],
- },
-
- new PreparedFood()
- {
- FoodID = i++,
- Name = "Cobb Salad",
- UnitPrice = 1.99,
- ServingSize = -1,
- MeasurementUnit = "cups",
- ProteinGrams = 6,
- FatGrams = 1,
- CarbohydrateGrams = 3,
- CaloriesPerServing = 5,
- IsAvailable = true,
- ExpirationDate = new DateTime(2000, 12, 29),
- ItemGUID = new Guid("0123456789abcdef0123456789abcdef"),
- Weight = 5.674f,
- AvailableUnits = 127,
- Packaging = null,
- Category = categories[1],
- Instructions = "1.) Open 2.) Eat",
- NumberOfIngredients = 4,
- },
-
- new PreparedFood()
- {
- FoodID = i++,
- Name = "Lasagna",
- UnitPrice = 0,
- ServingSize = 8,
- MeasurementUnit = " servings",
- ProteinGrams = 100,
- FatGrams = 4,
- CarbohydrateGrams = 27,
- CaloriesPerServing = 389,
- IsAvailable = true,
- ExpirationDate = new DateTime(1904, 2, 29),
- ItemGUID = new Guid("0123456789abcdef0123456789abcdef"),
- Weight = 0,
- AvailableUnits = 4,
- Packaging = new Package(){
- Type = "box",
- Color = " 1 ",
- NumberPerPackage = 1,
- RequiresRefridgeration = true,
- PackageDimensions = new Dimensions(){
- Length = 3,
- Height = 1,
- Width = 5,
- Volume = 1.5,
- },
- ShipDate = new DateTime(2000, 12, 29),
- },
- Category = categories[0],
- Instructions = "Bake in oven",
- NumberOfIngredients = 15,
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Chocolate"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Pizza"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Avocados"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Quinoa"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Oatmeal"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Peanut Butter"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Banana"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Yam"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Clam"
- },
-
- new Food()
- {
- FoodID = i++,
- Name = "Spam"
- }
- };
- Array.ForEach(foods, (food) => this.GetResourceSetEntities<Food>("Foods").Add(food));
-
- categories[0].Foods.Add(foods[0]);
- categories[1].Foods.Add(foods[2]);
- categories[1].Foods.Add(foods[3]);
- }
-
- protected override void EnsureDataIsInitialized()
- {
- if (!dataInitialized)
- {
- this.ResetData();
- dataInitialized = true;
- }
- }
-
- public Stream GetReadStream(object entity, ResourceProperty streamProperty, string etag, bool? checkETagForEquality, DataServiceOperationContext operationContext)
- {
- return new MemoryStream();
- }
-
- public Uri GetReadStreamUri(object entity, ResourceProperty streamProperty, DataServiceOperationContext operationContext)
- {
- if (streamProperty.Name == "Icon")
- {
- return null;
- }
- return new Uri(operationContext.AbsoluteServiceUri, streamProperty.Name);
- }
-
- public string GetStreamContentType(object entity, ResourceProperty streamProperty, DataServiceOperationContext operationContext)
- {
- if (streamProperty.Name == "Icon")
- {
- return "image/gif";
- }
- return "image/png";
- }
-
- public string GetStreamETag(object entity, ResourceProperty streamProperty, DataServiceOperationContext operationContext)
- {
- return "W/\"123456789\"";
- }
-
- public Stream GetWriteStream(object entity, ResourceProperty streamProperty, string etag, bool? checkETagForEquality, DataServiceOperationContext operationContext)
- {
- return new MemoryStream();
- }
-
- public void DeleteStream(object entity, DataServiceOperationContext operationContext)
- {
- // do nothing.
- }
-
- public Stream GetReadStream(object entity, string etag, bool? checkETagForEquality, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public Uri GetReadStreamUri(object entity, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public string GetStreamContentType(object entity, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public string GetStreamETag(object entity, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public Stream GetWriteStream(object entity, string etag, bool? checkETagForEquality, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public string ResolveType(string entitySetName, DataServiceOperationContext operationContext)
- {
- throw new NotImplementedException();
- }
-
- public int StreamBufferSize
- {
- get { return 1024; }
- }
- }
-
- /// <summary>
- /// The Category class is a simple class with V1-compatible feed customizations.
- /// </summary>
- public class Category
- {
- public Category()
- {
- this.Foods = new List<Food>();
- }
-
- public int CategoryID { get; set; }
- public string Name { get; set; }
- public List<Food> Foods { get; set; }
- }
-
- /// <summary>
- /// The Food class has a mixture of V1-compatible and incompatible feed
- /// customizations (thus it's V2), and custom mappings.
- /// </summary>
- public class Food
- {
- private List<string> alternativeNames = new List<string>();
- private List<Provider> providers = new List<Provider>();
-
- // Primitive types
- public int FoodID { get; set; }
- public string Name { get; set; }
- public double UnitPrice { get; set; }
- public Decimal ServingSize { get; set; }
- public string MeasurementUnit { get; set; }
- public Byte ProteinGrams { get; set; }
- public Int16 FatGrams { get; set; }
- public Int32 CarbohydrateGrams { get; set; }
- public Int64 CaloriesPerServing { get; set; }
- public Boolean IsAvailable { get; set; }
- public DateTime ExpirationDate { get; set; }
- public Guid ItemGUID { get; set; }
- public Single Weight { get; set; }
- public sbyte AvailableUnits { get; set; }
-
- // Complex types
- public Package Packaging { get; set; }
- public CookedDimensions CookedSize { get; set; }
-
- // Navigation properties
- public Category Category { get; set; }
-
- // Collection properties
- public List<string> AlternativeNames
- {
- get { return alternativeNames; }
- set { alternativeNames = value; }
- }
-
- public List<Provider> Providers
- {
- get { return providers; }
- set { providers = value; }
- }
-
- public GeometryCollection SpatialData
- {
- get;
- set;
- }
-
- }
-
- public class Provider
- {
- public string Name { get; set; }
- public List<string> Aliases { get; set; }
- public ProviderDetails Details { get; set; }
- }
-
- public class ProviderDetails
- {
- public string Telephone { get; set; }
- public int PreferredCode { get; set; }
- }
-
- public class Package
- {
- public string Type { get; set; }
- public string Color { get; set; }
- public int NumberPerPackage { get; set; }
- public Boolean RequiresRefridgeration { get; set; }
- public DateTime ShipDate { get; set; }
- public Dimensions PackageDimensions { get; set; }
- }
-
- public class Dimensions
- {
- public Decimal Length { get; set; }
- public Int16 Height { get; set; }
- public Int64 Width { get; set; }
- public double Volume { get; set; }
- }
-
- public class CookedDimensions
- {
- public Decimal Length { get; set; }
- public Int16 Height { get; set; }
- public Int64 Width { get; set; }
- public double Volume { get; set; }
- }
-
- public class PreparedFood : Food
- {
- public string Instructions { get; set; }
- public float NumberOfIngredients { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/datajs/tests-tmp/endpoints/LargeCollectionService.svc
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/endpoints/LargeCollectionService.svc b/datajs/tests-tmp/endpoints/LargeCollectionService.svc
deleted file mode 100644
index bfbd3ef..0000000
--- a/datajs/tests-tmp/endpoints/LargeCollectionService.svc
+++ /dev/null
@@ -1,113 +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.
- */
--->
-
-<%@ ServiceHost Language="C#" Factory="Microsoft.OData.Service.DataServiceHostFactory, Microsoft.OData.Service, Version=6.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
- Service="DataJS.Tests.LargeCollectionService" %>
-
-namespace DataJS.Tests
-{
- using System;
- using System.Collections.Generic;
- using Microsoft.OData.Service;
- using System.Linq;
- using System.ServiceModel;
- using System.ServiceModel.Web;
- using System.Web;
-
- [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
- public class LargeCollectionService : DataService<LargeCollection>
- {
- // This method is called only once to initialize service-wide policies.
- public static void InitializeService(DataServiceConfiguration config)
- {
- config.SetEntitySetAccessRule("*", EntitySetRights.All);
- config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
- config.UseVerboseErrors = true;
- }
-
- [WebInvoke]
- public void ResetData()
- {
- this.CurrentDataSource.ResetData();
- }
- }
-
- public class LargeCollection : ReflectionDataContext, IUpdatable
- {
- private static bool dataInitialized;
-
- public IQueryable<Customer> Customers
- {
- get { return this.GetResourceSetEntities<Customer>("Customers").AsQueryable(); }
- }
-
- public IQueryable<Supplier> Suppliers
- {
- get { return this.GetResourceSetEntities<Supplier>("Suppliers").AsQueryable(); }
- }
-
- public void ResetData()
- {
- this.ClearData();
-
- IList<Customer> customers = this.GetResourceSetEntities<Customer>("Customers");
- foreach (int i in Enumerable.Range(1, 2 * 1024 * 1024))
- {
- customers.Add(new Customer()
- {
- ID = i,
- Name = "Customer " + i
- });
- }
-
- IList<Supplier> suppliers = this.GetResourceSetEntities<Supplier>("Suppliers");
- foreach (int i in Enumerable.Range(1, 5000))
- {
- suppliers.Add(new Supplier()
- {
- ID = i,
- Name = "Supplier " + i
- });
- }
- }
-
- protected override void EnsureDataIsInitialized()
- {
- if (!dataInitialized)
- {
- this.ResetData();
- dataInitialized = true;
- }
- }
- }
-
- public class Customer
- {
- public int ID { get; set; }
- public string Name { get; set; }
- }
-
- public class Supplier
- {
- public int ID { get; set; }
- public string Name { get; set; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/datajs/tests-tmp/endpoints/web.config
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/endpoints/web.config b/datajs/tests-tmp/endpoints/web.config
deleted file mode 100644
index 116a567..0000000
--- a/datajs/tests-tmp/endpoints/web.config
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version='1.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.
- */
--->
-<configuration>
- <system.web>
- <compilation debug='true'>
- <assemblies>
- <add assembly='System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089'/>
- <add assembly='System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089'/>
- <add assembly='System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'/>
- <add assembly='System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089'/>
- <add assembly='System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089'/>
- <add assembly='System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089'/>
- <add assembly='System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'/>
- <add assembly="Microsoft.OData.Core, Version=6.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
- <add assembly="Microsoft.OData.Service, Version=6.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
- <add assembly="Microsoft.OData.Client, Version=6.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
- </assemblies>
- </compilation>
- </system.web>
- <system.codedom>
- <compilers>
- <compiler language='c#;cs;csharp' extension='.cs' type='Microsoft.CSharp.CSharpCodeProvider,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'>
- <providerOption name='CompilerVersion' value='v4.0' />
- </compiler>
- </compilers>
- </system.codedom>
-</configuration>
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/datajs/tests-tmp/odata-json-tests-todo-analyse.js
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/odata-json-tests-todo-analyse.js b/datajs/tests-tmp/odata-json-tests-todo-analyse.js
deleted file mode 100644
index 702e015..0000000
--- a/datajs/tests-tmp/odata-json-tests-todo-analyse.js
+++ /dev/null
@@ -1,828 +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.
- */
-
-// odata-tests.js
-
-(function (window, undefined) {
- djstest.addTest(function jsonParserTest() {
- var tests = [
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" }, expected: {} },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/OData.svc/$metadata",
- value: [
- {
- name: "Products",
- kind: "EntitySet",
- url: "Products"
- },
- {
- name: "ProductDetails",
- kind: "EntitySet",
- url: "ProductDetails"
- }
- ]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- value: [
- {
- name: "Products",
- kind: "EntitySet",
- url: "http://foo/OData.svc/Products"
- },
- {
- name: "ProductDetails",
- kind: "EntitySet",
- url: "http://foo/OData.svc/ProductDetails"
- }
- ]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" }, expected: { "@odata.context": "http://foo/OData.svc/$metadata#Products(0)/Name", value: "Bread"} },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/OData.svc/$metadata#Products",
- value: [
- {
- "@odata.type": "#ODataDemo.Product",
- "@odata.id": "http://foo/OData.svc/Products(0)",
- "@odata.editLink": "Products(0)",
- "Categories@odata.navigationLink": "Products(0)/Categories",
- "Categories@odata.associationLink": "Products(0)/Categories/$ref",
- "Supplier@odata.navigationLink": "Products(0)/Supplier",
- "Supplier@odata.associationLink": "Products(0)/Supplier/$ref",
- "ProductDetail@odata.navigationLink": "Products(0)/ProductDetail",
- "ProductDetail@odata.associationLink": "Products(0)/ProductDetail/$ref",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- "ReleaseDate@odata.type": "#DateTimeOffset",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- "Rating@odata.type": "#Int16",
- Rating: 4,
- Price: 2.5
- }]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/OData.svc/$metadata#Products",
- value: [
- {
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- value: [
- {
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/OData.svc/$metadata#Products/$entry",
- "@odata.type": "#ODataDemo.Product",
- "@odata.id": "http://foo/OData.svc/Products(0)",
- "@odata.editLink": "Products(0)",
- "Categories@odata.navigationLink": "Products(0)/Categories",
- "Categories@odata.associationLink": "Products(0)/Categories/$ref",
- "Supplier@odata.navigationLink": "Products(0)/Supplier",
- "Supplier@odata.associationLink": "Products(0)/Supplier/$ref",
- "ProductDetail@odata.navigationLink": "Products(0)/ProductDetail",
- "ProductDetail@odata.associationLink": "Products(0)/ProductDetail/$ref",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- "ReleaseDate@odata.type": "#DateTimeOffset",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- "Rating@odata.type": "#Int16",
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/OData.svc/$metadata#Products/$entry",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.context": "http://foo/$metadata#Customer(-10)/PrimaryContactInfo/AlternativeNames",
- "@odata.type": "#Collection(String)",
- value: [
- "グぁマせぺネソぁぼソひバたぴソ歹九ネボボяポソ畚クяせべ歹珱Я欲タハバミ裹ぼボをヲ歹んひ九ひ匚ぁa",
- "qckrnuruxcbhjfimnsykgfquffobcadpsaocixoeljhspxrhebkudppgndgcrlyvynqhbujrnvyxyymhnroemigogsqulvgallta",
- "btsnhqrjqryqzgxducl",
- "qbtlssjhunufmzdv",
- "ボんЯぜチべゼボボほa匚ミぼ九ぁひチ珱黑ミんぁタび暦クソソボゾんんあゼぞひタボタぜん弌ひべ匚",
- "vicqasfdkxsuyuzspjqunxpyfuhlxfhgfqnlcpdfivqnxqoothnfsbuykfguftgulgldnkkzufssbae",
- "九ソミせボぜゾボёaをぜЯまゾタぜタひ縷ダんaバたゼソ",
- "ぽマタぁぁ黑ソゼミゼ匚zソダマぁァゾぽミaタゾ弌ミゼタそzぺポせ裹バポハハヲぺチあマ匚ミ",
- "hssiißuamtctgqhglmusexyikhcsqctusonubxorssyizhyqpbtbdßjnelxqttkhdalabibuqhiubtßsptrmzelud",
- "gbjssllxzzxkmßppyyrhgmoeßizlcmsuqqnvjßudszevtfunflqzqcuubukypßqjcix"
- ]
- }
- }
- ];
-
- var i, len;
- for (i = 0, len = tests.length; i < len; i++) {
- var data = JSON.stringify(tests[i].expected);
- var actual = window.odatajs.oData.json.jsonParser(window.odatajs.oData.json.jsonHandler, data, tests[i].context);
- djstest.assertAreEqualDeep(actual, tests[i].expected, "test " + i + "didn't return the expected data");
- }
-
- djstest.done();
- });
-
- djstest.addTest(function jsonSerializerTest() {
- var tests = [
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" }, expected: { value: ""} },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" }, expected: { value: []} },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- value: [
- "グぁマせぺネソぁぼソひバたぴソ歹九ネボボяポソ畚クяせべ歹珱Я欲タハバミ裹ぼボをヲ歹んひ九ひ匚ぁa",
- "qckrnuruxcbhjfimnsykgfquffobcadpsaocixoeljhspxrhebkudppgndgcrlyvynqhbujrnvyxyymhnroemigogsqulvgallta",
- "btsnhqrjqryqzgxducl",
- "qbtlssjhunufmzdv",
- "ボんЯぜチべゼボボほa匚ミぼ九ぁひチ珱黑ミんぁタび暦クソソボゾんんあゼぞひタボタぜん弌ひべ匚",
- "vicqasfdkxsuyuzspjqunxpyfuhlxfhgfqnlcpdfivqnxqoothnfsbuykfguftgulgldnkkzufssbae",
- "九ソミせボぜゾボёaをぜЯまゾタぜタひ縷ダんaバたゼソ",
- "ぽマタぁぁ黑ソゼミゼ匚zソダマぁァゾぽミaタゾ弌ミゼタそzぺポせ裹バポハハヲぺチあマ匚ミ",
- "hssiißuamtctgqhglmusexyikhcsqctusonubxorssyizhyqpbtbdßjnelxqttkhdalabibuqhiubtßsptrmzelud",
- "gbjssllxzzxkmßppyyrhgmoeßizlcmsuqqnvjßudszevtfunflqzqcuubukypßqjcix"
- ]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- data: {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.id": "Foods(4)",
- value : [{
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 2,
- ComplexInLayerThreeList: [
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- }],
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: ["BreadInLayer1", "BreadInLayer12", "BreadInLayer13"],
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 2,
- ComplexInLayerThreeList: [
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- }],
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: ["BreadInLayer1", "BreadInLayer12", "BreadInLayer13"],
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }]
- },
- data: {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.editLink": "Foods(0)",
- value : [{
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer1",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer1",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer1",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer1",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer2",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer2",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer2",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer2",
- ID: 2,
- ComplexInLayerThreeList: [
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer3",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer3",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer3",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer3",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer3",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer3",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer3",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer3",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- }],
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: ["BreadInLayer1", "BreadInLayer12", "BreadInLayer13"],
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer1",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer1",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer1",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer1",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer2",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer2",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer2",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer2",
- ID: 2,
- ComplexInLayerThreeList: [
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer3",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer3",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer3",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer3",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer3",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer3",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer3",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer3",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- }],
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: ["BreadInLayer1", "BreadInLayer12", "BreadInLayer13"],
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }]
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 2,
- ComplexInLayerThree:
- {
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: "BreadInLayer1",
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- data: {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag",
- ID: 0,
- ComplexInLayerOne:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer1",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer1",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer1",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer1",
- ID: 1,
- ComplexInLayerTwo:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer2",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer2",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer2",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer2",
- ID: 2,
- ComplexInLayerThree:
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink/layer3",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink/layer3",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType/layer3",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag/layer3",
- ID: 3,
- Name: "BreadInLayer3",
- Description: "Whole grain bread inLayer3",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 7,
- Price: 5.5
- },
- Name: "BreadInLayer2",
- Description: "Whole grain bread inLayer2",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 4.5
- },
- Name: "BreadInLayer1",
- Description: "Whole grain bread inLayer1",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 5,
- Price: 3.5
- },
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- }
- },
- { context: { response: { requestUri: "http://base.org" }, dataServiceVersion: "4.0" },
- expected: {
- value: [{
- "@odata.id": "Foods(4)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- {
- "@odata.id": "Foods(2)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- ID: 1,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1999-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 3.5
- }]
- },
- data: {
- value: [{
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(4)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(0)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag",
- ID: 0,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1992-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 4,
- Price: 2.5
- },
- {
- "@odata.context": "http://base.org/$metadata#Foods/$entity",
- "@odata.id": "Foods(2)",
- "@odata.etag": "W/MjAxMy0wNS0yN1QxMTo1OFo=",
- "@odata.editLink": "Foods(2)",
- "@odata.type": "#DataJS.Tests.V4.Food",
- "@odata.mediaEditLink": "http://base.org/$metadata#Foods/mediaEditLink2",
- "@odata.mediaReadLink": "http://base.org/$metadata#Foods/mediaReadLink2",
- "@odata.mediaContentType": "http://base.org/$metadata#Foods/mediaContentType2",
- "@odata.mediaEtag": "http://base.org/$metadata#Foods/mediaEtag2",
- ID: 1,
- Name: "Bread",
- Description: "Whole grain bread",
- ReleaseDate: "1999-01-01T00:00:00Z",
- DiscontinuedDate: null,
- Rating: 6,
- Price: 3.5
- }]
- }
- }
- ];
- var i, len;
- for (i = 0, len = tests.length; i < len; i++) {
- var data = tests[i].data ? tests[i].data : tests[i].expected;
- var actual = window.odatajs.oData.json.jsonSerializer(window.odatajs.oData.json.jsonHandler, data, tests[i].context);
- var expected = JSON.stringify(tests[i].expected);
- djstest.assertAreEqualDeep(actual, expected, "test " + i + "didn't return the expected data");
- }
- djstest.done();
- });
-
- djstest.addTest(function normalizeHeadersReadTest() {
- // Verifies that headers are normalized for reading.
- // See issue at http://datajs.codeplex.com/workitem/148
- MockHttpClient.clear();
-
- MockHttpClient.clear().addResponse("/foo", {
- statusCode: 200,
- body: { "@odata.context": "http://foo", value: [] },
- headers: { "unknown": "u", "Content-Encoding": "compress, gzip", "Content-Length": "8042",
- "Content-Type": "application/json", "OData-Version": "4.0", "Etag": "Vetag", "Location": "foo", "OData-EntityId": "entityId",
- "Preference-Applied": "prefered", "Retry-After": "retry"
- }
- });
-
- odatajs.oData.read("/foo", function (data, response) {
- // djstest.assertAreEqual(data.results.length, 2, "data.results.length has two entries");
- djstest.assertAreEqual(response.headers.unknown, "u", "u unmodified");
- djstest.assertAreEqual(response.headers["Content-Encoding"], "compress, gzip", "Content-Encoding available");
- djstest.assertAreEqual(response.headers["Content-Length"], "8042", "Content-Length available");
- djstest.assertAreEqual(response.headers["Content-Type"], "application/json", "Content-Type available");
- djstest.assertAreEqual(response.headers["ETag"], "Vetag", "Content-Type available");
- djstest.assertAreEqual(response.headers["Location"], "foo", "Content-Type available");
- djstest.assertAreEqual(response.headers["OData-EntityId"], "entityId", "OData-EntityId available");
- djstest.assertAreEqual(response.headers["Preference-Applied"], "prefered", "Preference-Applied available");
- djstest.assertAreEqual(response.headers["Retry-After"], "retry", "Retry available");
- djstest.assertAreEqual(response.headers["OData-Version"], "4.0", "OData-Version available");
- djstest.done();
- }, undefined, undefined, MockHttpClient);
- });
-
- djstest.addTest(function normalizeHeadersWriteTest() {
-
- // Verifies that headers are normalized for writing.
- // See issue at http://datajs.codeplex.com/workitem/148
-
- MockHttpClient.clear().addRequestVerifier("/foo", function (request) {
- djstest.assertAreEqual(request.headers.Accept, "application/json", "Accept available");
- djstest.assertAreEqual(request.headers["Content-Type"], "application/json", "json found");
- djstest.assertAreEqual(request.headers["Content-Encoding"], "compress, gzip", "Content-Encoding available");
- djstest.assertAreEqual(request.headers["Content-Length"], "8042", "Content-Length available");
- djstest.assertAreEqual(request.headers["OData-Version"], "4.0", "OData-Version available");
- djstest.assertAreEqual(request.headers["Accept-Charset"], "Accept-Charset", "Accept-Charset available");
- djstest.assertAreEqual(request.headers["If-Match"], "true", "If-Match available");
- djstest.assertAreEqual(request.headers["If-None-Match"], "false", "If-None-Match available");
- djstest.assertAreEqual(request.headers["OData-Isolation"], "isolation", "OData-Isolation available");
- djstest.assertAreEqual(request.headers["OData-MaxVersion"], "4.0", "OData-MaxVersion available");
- djstest.assertAreEqual(request.headers["Prefer"], "prefer", "prefer available");
- djstest.done();
- });
-
- var request = {
- method: "POST",
- requestUri: "/foo",
- data: { value: 123 },
- headers: { "Accept": "application/json", "Content-Encoding": "compress, gzip", "Content-Length": "8042", "content-type": "application/json", "OData-Version": "4.0",
- "accept-charset": "Accept-Charset", "if-match": "true", "if-none-match": "false", "odata-isolation": "isolation",
- "odata-maxversion": "4.0", "prefer": "prefer"
- }
- };
- odatajs.oData.request(request, function (data) { }, undefined, undefined, MockHttpClient);
-
- });
-
-
-})(window);
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/datajs/tests-tmp/odata-qunit-tests-launcher.htm
----------------------------------------------------------------------
diff --git a/datajs/tests-tmp/odata-qunit-tests-launcher.htm b/datajs/tests-tmp/odata-qunit-tests-launcher.htm
deleted file mode 100644
index 4f8a390..0000000
--- a/datajs/tests-tmp/odata-qunit-tests-launcher.htm
+++ /dev/null
@@ -1,61 +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.
- */
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
- <meta http-equiv="cache-control" content="no-cache" />
- <meta http-equiv="pragma" content="no-cache" />
- <meta http-equiv="expires" content="-1" />
-
- <title>OData unit tests</title>
- <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.10.0.css" type="text/css" />
-
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js" ></script>
- <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.10.0.js"></script>
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.5/rx.all.js"></script>
-
-
- <script type="text/javascript" src="../build/odatajs-4.0.0-beta-01.js"></script>
-
- <script type="text/javascript" src="./common/logging.js"></script>
-
- <script type="text/javascript" src="./common/odataCacheVerifier.js"></script>
- <script type="text/javascript" src="./common/odataVerifyReader.js"></script>
-
-
- <script type="text/javascript" src="./common/mockHttpClient.js"></script>
-
-
-
- <script type="text/javascript" src="./common/djstest.js"></script>
- <script type="text/javascript" src="./common/djstest-browser.js"></script>
-
-
- <script type="text/javascript" src="./bn-odata-json-tests.js"></script>
- <script type="text/javascript" src="./a-odata-json-tests.js"></script>
- <script type="text/javascript" src="./b-cache-tests.js"></script>
- <body>
- <div id="qunit"></div>
- </body>
-
-</html>
\ No newline at end of file