You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2016/09/14 10:51:57 UTC
[2/6] ignite git commit: Move tests to a separate project
Move tests to a separate project
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c359c543
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c359c543
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c359c543
Branch: refs/heads/ignite-3199-1
Commit: c359c543e21372cd2c489c239c748b3a887e6089
Parents: a5916d3
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Sep 14 13:37:47 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Sep 14 13:37:47 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.AspNet.Tests.csproj | 86 ++++
.../Apache.Ignite.AspNet.Tests.snk | Bin 0 -> 596 bytes
.../ExpiryCacheHolderTest.cs | 492 +++++++++++++++++++
.../IgniteOutputCacheProviderTest.cs | 173 +++++++
.../IgniteSessionStateItemCollectionTest.cs | 265 ++++++++++
.../IgniteSessionStateStoreDataTest.cs | 115 +++++
.../IgniteSessionStateStoreProviderTest.cs | 485 ++++++++++++++++++
.../Properties/AssemblyInfo.cs | 25 +
.../Apache.Ignite.AspNet.Tests/packages.config | 4 +
.../Properties/AssemblyInfo.cs | 2 +-
.../Apache.Ignite.Core.Tests.csproj | 5 -
.../AspNet/ExpiryCacheHolderTest.cs | 491 ------------------
.../AspNet/IgniteOutputCacheProviderTest.cs | 172 -------
.../IgniteSessionStateItemCollectionTest.cs | 267 ----------
.../AspNet/IgniteSessionStateStoreDataTest.cs | 117 -----
.../IgniteSessionStateStoreProviderTest.cs | 484 ------------------
modules/platforms/dotnet/Apache.Ignite.sln | 20 +-
17 files changed, 1664 insertions(+), 1539 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.csproj
new file mode 100644
index 0000000..d058fa6
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.csproj
@@ -0,0 +1,86 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{18EA4C71-A11D-4AB1-8042-418F7559D84F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.AspNet.Tests</RootNamespace>
+ <AssemblyName>Apache.Ignite.AspNet.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.AspNet.Tests.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.Runners.2.6.3\tools\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ExpiryCacheHolderTest.cs" />
+ <Compile Include="IgniteOutputCacheProviderTest.cs" />
+ <Compile Include="IgniteSessionStateItemCollectionTest.cs" />
+ <Compile Include="IgniteSessionStateStoreDataTest.cs" />
+ <Compile Include="IgniteSessionStateStoreProviderTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Apache.Ignite.AspNet.Tests.snk" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Apache.Ignite.AspNet\Apache.Ignite.AspNet.csproj">
+ <Project>{13EA96FC-CC83-4164-A7C0-4F30ED797460}</Project>
+ <Name>Apache.Ignite.AspNet</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj">
+ <Project>{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}</Project>
+ <Name>Apache.Ignite.Core.Tests</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.snk b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.snk
new file mode 100644
index 0000000..799e742
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Apache.Ignite.AspNet.Tests.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
new file mode 100644
index 0000000..c12fe93
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/ExpiryCacheHolderTest.cs
@@ -0,0 +1,492 @@
+\ufeff/*
+ * 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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+namespace Apache.Ignite.AspNet.Tests
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading.Tasks;
+ using Apache.Ignite.AspNet.Impl;
+ using Apache.Ignite.Core;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Expiry;
+ using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Cache.Query.Continuous;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="ExpiryCacheHolder{TK,TV}"/>.
+ /// </summary>
+ public class ExpiryCacheHolderTest
+ {
+ /// <summary>
+ /// Tests the expiry policy.
+ /// </summary>
+ [Test]
+ public void TestExpiryPolicy()
+ {
+ var cache = new CacheEx();
+
+ Assert.IsNull(cache.ExpiryPolicy);
+
+ var holder = new ExpiryCacheHolder<int, int>(cache);
+
+ // Check same cache for same expiry.
+ var cache1 = (CacheEx) holder.GetCacheWithExpiry(15);
+
+ CheckExpiry(TimeSpan.FromSeconds(15), cache1);
+ Assert.AreNotSame(cache, cache1);
+ Assert.AreSame(cache1, holder.GetCacheWithExpiry(15));
+
+ // Check rounding.
+ var cache2 = (CacheEx) holder.GetCacheWithExpiry(DateTime.UtcNow.AddSeconds(15.1));
+ Assert.AreSame(cache1, cache2);
+
+ // Check no expiration.
+ var cache3 = (CacheEx) holder.GetCacheWithExpiry(DateTime.MaxValue);
+ Assert.AreSame(cache, cache3);
+ }
+
+ /// <summary>
+ /// Checks the expiry.
+ /// </summary>
+ private static void CheckExpiry(TimeSpan timeSpan, CacheEx cache)
+ {
+ Assert.AreEqual(timeSpan, cache.ExpiryPolicy.GetExpiryForCreate());
+ Assert.IsNull(cache.ExpiryPolicy.GetExpiryForUpdate());
+ Assert.IsNull(cache.ExpiryPolicy.GetExpiryForAccess());
+ }
+
+ /// <summary>
+ /// Test cache implementation.
+ /// </summary>
+ private class CacheEx : ICache<int, int>
+ {
+ public IExpiryPolicy ExpiryPolicy { get; set; }
+
+ public IEnumerator<ICacheEntry<int, int>> GetEnumerator()
+ {
+ throw new NotImplementedException();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public string Name { get; private set; }
+
+ public IIgnite Ignite { get; private set; }
+
+ public CacheConfiguration GetConfiguration()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsEmpty()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsKeepBinary { get; private set; }
+
+ public ICache<int, int> WithSkipStore()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ICache<int, int> WithExpiryPolicy(IExpiryPolicy plc)
+ {
+ return new CacheEx {ExpiryPolicy = plc};
+ }
+
+ public ICache<TK1, TV1> WithKeepBinary<TK1, TV1>()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LoadCache(ICacheEntryFilter<int, int> p, params object[] args)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task LoadCacheAsync(ICacheEntryFilter<int, int> p, params object[] args)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LocalLoadCache(ICacheEntryFilter<int, int> p, params object[] args)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task LocalLoadCacheAsync(ICacheEntryFilter<int, int> p, params object[] args)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LoadAll(IEnumerable<int> keys, bool replaceExistingValues)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task LoadAllAsync(IEnumerable<int> keys, bool replaceExistingValues)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool ContainsKey(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> ContainsKeyAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool ContainsKeys(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> ContainsKeysAsync(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int LocalPeek(int key, params CachePeekMode[] modes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool TryLocalPeek(int key, out int value, params CachePeekMode[] modes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int this[int key]
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ public int Get(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<int> GetAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool TryGet(int key, out int value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<CacheResult<int>> TryGetAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IDictionary<int, int> GetAll(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<IDictionary<int, int>> GetAllAsync(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Put(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task PutAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public CacheResult<int> GetAndPut(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<CacheResult<int>> GetAndPutAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public CacheResult<int> GetAndReplace(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<CacheResult<int>> GetAndReplaceAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public CacheResult<int> GetAndRemove(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<CacheResult<int>> GetAndRemoveAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool PutIfAbsent(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> PutIfAbsentAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public CacheResult<int> GetAndPutIfAbsent(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<CacheResult<int>> GetAndPutIfAbsentAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Replace(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> ReplaceAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Replace(int key, int oldVal, int newVal)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> ReplaceAsync(int key, int oldVal, int newVal)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void PutAll(IDictionary<int, int> vals)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task PutAllAsync(IDictionary<int, int> vals)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LocalEvict(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Clear()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task ClearAsync()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Clear(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task ClearAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ClearAll(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task ClearAllAsync(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LocalClear(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LocalClearAll(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Remove(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> RemoveAsync(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Remove(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<bool> RemoveAsync(int key, int val)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveAll(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task RemoveAllAsync(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void RemoveAll()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task RemoveAllAsync()
+ {
+ throw new NotImplementedException();
+ }
+
+ public int GetLocalSize(params CachePeekMode[] modes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int GetSize(params CachePeekMode[] modes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<int> GetSizeAsync(params CachePeekMode[] modes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void LocalPromote(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IQueryCursor<ICacheEntry<int, int>> Query(QueryBase qry)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IContinuousQueryHandle QueryContinuous(ContinuousQuery<int, int> qry)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IContinuousQueryHandle<ICacheEntry<int, int>> QueryContinuous(ContinuousQuery<int, int> qry, QueryBase initialQry)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IEnumerable<ICacheEntry<int, int>> GetLocalEntries(params CachePeekMode[] peekModes)
+ {
+ throw new NotImplementedException();
+ }
+
+ public TRes Invoke<TArg, TRes>(int key, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<TRes> InvokeAsync<TArg, TRes>(int key, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IDictionary<int, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<IDictionary<int, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ICacheLock Lock(int key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ICacheLock LockAll(IEnumerable<int> keys)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsLocalLocked(int key, bool byCurrentThread)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ICacheMetrics GetMetrics()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task Rebalance()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ICache<int, int> WithNoRetries()
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteOutputCacheProviderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteOutputCacheProviderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteOutputCacheProviderTest.cs
new file mode 100644
index 0000000..2419ffe
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteOutputCacheProviderTest.cs
@@ -0,0 +1,173 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.AspNet.Tests
+{
+ using System;
+ using System.Collections.Specialized;
+ using System.Threading;
+ using Apache.Ignite.Core;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Tests;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="IgniteOutputCacheProvider"/>
+ /// </summary>
+ public class IgniteOutputCacheProviderTest
+ {
+ /** Grid name XML config attribute. */
+ private const string GridNameAttr = "gridName";
+
+ /** Cache name XML config attribute. */
+ private const string CacheNameAttr = "cacheName";
+
+ /** Cache name XML config attribute. */
+ private const string SectionNameAttr = "igniteConfigurationSectionName";
+
+ /** Grid name. */
+ private const string GridName = "grid1";
+
+ /** Cache name. */
+ private const string CacheName = "myCache";
+
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) {GridName = GridName});
+ }
+
+ /// <summary>
+ /// Fixture teardown.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests provider initialization.
+ /// </summary>
+ [Test]
+ public void TestInitialization()
+ {
+ var cacheProvider = new IgniteOutputCacheProvider();
+
+ // Not initialized
+ Assert.Throws<InvalidOperationException>(() => cacheProvider.Get("1"));
+
+ // Grid not started
+ Assert.Throws<IgniteException>(() =>
+ cacheProvider.Initialize("testName", new NameValueCollection
+ {
+ {GridNameAttr, "invalidGridName"},
+ {CacheNameAttr, CacheName}
+ }));
+
+ // Valid grid
+ cacheProvider = GetProvider();
+
+ cacheProvider.Set("1", 1, DateTime.MaxValue);
+ Assert.AreEqual(1, cacheProvider.Get("1"));
+ }
+
+ /// <summary>
+ /// Tests autostart from web configuration section.
+ /// </summary>
+ [Test]
+ public void TestStartFromWebConfigSection()
+ {
+ var cacheProvider = new IgniteOutputCacheProvider();
+
+ cacheProvider.Initialize("testName2", new NameValueCollection
+ {
+ {SectionNameAttr, "igniteConfiguration2"},
+ {CacheNameAttr, "cacheName2"}
+ });
+
+ cacheProvider.Set("1", 3, DateTime.MaxValue);
+ Assert.AreEqual(3, cacheProvider.Get("1"));
+ }
+
+ /// <summary>
+ /// Tests provider caching.
+ /// </summary>
+ [Test]
+ public void TestCaching()
+ {
+ var cacheProvider = GetProvider();
+
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+ cacheProvider.Set("1", 1, DateTime.MaxValue);
+ Assert.AreEqual(1, cacheProvider.Get("1"));
+
+ cacheProvider.Remove("1");
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+
+ Assert.AreEqual(null, cacheProvider.Add("2", 2, DateTime.MaxValue));
+ Assert.AreEqual(2, cacheProvider.Add("2", 5, DateTime.MaxValue));
+ }
+
+ /// <summary>
+ /// Tests cache expiration.
+ /// </summary>
+ [Test]
+ public void TestExpiry()
+ {
+ var cacheProvider = GetProvider();
+ cacheProvider.Remove("1");
+
+ // Set
+ cacheProvider.Set("1", 1, DateTime.UtcNow.AddSeconds(1.3));
+ Assert.AreEqual(1, cacheProvider.Get("1"));
+ Thread.Sleep(2000);
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+
+ cacheProvider.Set("1", 1, DateTime.UtcNow);
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+
+ // Add
+ cacheProvider.Add("1", 1, DateTime.UtcNow.AddSeconds(0.7));
+ Assert.AreEqual(1, cacheProvider.Get("1"));
+ Thread.Sleep(2000);
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+
+ cacheProvider.Add("1", 1, DateTime.UtcNow);
+ Assert.AreEqual(null, cacheProvider.Get("1"));
+ }
+
+ /// <summary>
+ /// Gets the initialized provider.
+ /// </summary>
+ private static IgniteOutputCacheProvider GetProvider()
+ {
+ var cacheProvider = new IgniteOutputCacheProvider();
+
+ cacheProvider.Initialize("testName", new NameValueCollection
+ {
+ {GridNameAttr, GridName},
+ {CacheNameAttr, CacheName}
+ });
+
+ return cacheProvider;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateItemCollectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateItemCollectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateItemCollectionTest.cs
new file mode 100644
index 0000000..e986573
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateItemCollectionTest.cs
@@ -0,0 +1,265 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.AspNet.Tests
+{
+ using System;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.AspNet.Impl;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="IgniteSessionStateItemCollection"/>.
+ /// </summary>
+ public class IgniteSessionStateItemCollectionTest
+ {
+ /// <summary>
+ /// Tests the empty collection.
+ /// </summary>
+ [Test]
+ public void TestEmpty()
+ {
+ var col1 = new IgniteSessionStateItemCollection();
+ var col2 = SerializeDeserialize(col1);
+
+ foreach (var col in new[] { col1, col2 })
+ {
+ Assert.IsFalse(col.Dirty);
+ Assert.IsFalse(col.IsSynchronized);
+ Assert.AreEqual(0, col.Count);
+ Assert.IsNotNull(col.SyncRoot);
+ Assert.IsEmpty(col);
+ Assert.IsEmpty(col.OfType<string>().ToArray());
+ Assert.IsEmpty(col.Keys);
+ Assert.IsNotNull(col.SyncRoot);
+
+ Assert.IsNull(col["key"]);
+ Assert.Throws<ArgumentOutOfRangeException>(() => col[0] = "x");
+ Assert.Throws<ArgumentOutOfRangeException>(() => Assert.AreEqual(0, col[0]));
+ Assert.Throws<ArgumentOutOfRangeException>(() => col.RemoveAt(0));
+
+ col.Clear();
+ col.Remove("test");
+
+ Assert.AreEqual(0, col.Count);
+
+ col.Dirty = true;
+ Assert.IsTrue(col.Dirty);
+ }
+ }
+
+ /// <summary>
+ /// Tests the modification.
+ /// </summary>
+ [Test]
+ public void TestModification()
+ {
+ var col = new IgniteSessionStateItemCollection();
+
+ // Populate and check.
+ col["key"] = "val";
+ col["1"] = 1;
+
+ Assert.AreEqual("val", col["key"]);
+ Assert.AreEqual(1, col["1"]);
+
+ Assert.AreEqual(2, col.Count);
+ Assert.IsTrue(col.Dirty);
+
+ CollectionAssert.AreEquivalent(new[] {"key", "1"}, col);
+ CollectionAssert.AreEquivalent(new[] {"key", "1"}, col.Keys);
+
+ // Modify using index.
+ col[0] = "val1";
+ col[1] = 2;
+
+ Assert.AreEqual("val1", col["key"]);
+ Assert.AreEqual(2, col["1"]);
+
+ // Modify using key.
+ col["1"] = 3;
+ col["key"] = "val2";
+
+ Assert.AreEqual("val2", col["key"]);
+ Assert.AreEqual(3, col["1"]);
+
+ // CopyTo.
+ var keys = new string[5];
+ col.CopyTo(keys, 2);
+ Assert.AreEqual(new[] {null, null, "key", "1", null}, keys);
+
+ // Remove.
+ col["2"] = 2;
+ col["3"] = 3;
+
+ col.Remove("invalid");
+ Assert.AreEqual(4, col.Count);
+
+ col.Remove("1");
+
+ Assert.AreEqual(new[] { "key", "2", "3" }, col.OfType<string>());
+ Assert.AreEqual(null, col["1"]);
+
+ Assert.AreEqual("val2", col["key"]);
+ Assert.AreEqual("val2", col[0]);
+
+ Assert.AreEqual(2, col["2"]);
+ Assert.AreEqual(2, col[1]);
+
+ Assert.AreEqual(3, col["3"]);
+ Assert.AreEqual(3, col[2]);
+
+ // RemoveAt.
+ col.RemoveAt(0);
+ Assert.AreEqual(new[] { "2", "3" }, col.OfType<string>());
+
+ // Clear.
+ Assert.AreEqual(2, col.Count);
+
+ col.Clear();
+ Assert.AreEqual(0, col.Count);
+
+ // Set dirty.
+ var col1 = new IgniteSessionStateItemCollection {Dirty = true};
+ Assert.IsTrue(col1.Dirty);
+ }
+
+ /// <summary>
+ /// Tests dirty tracking.
+ /// </summary>
+ [Test]
+ public void TestApplyChanges()
+ {
+ Func<IgniteSessionStateItemCollection> getCol = () =>
+ {
+ var res = new IgniteSessionStateItemCollection();
+
+ res["1"] = 1;
+ res["2"] = 2;
+ res["3"] = 3;
+
+ return res;
+ };
+
+ var col = getCol();
+
+ var col0 = SerializeDeserialize(col);
+
+ Assert.AreEqual(3, col0.Count);
+
+ col0.Remove("1");
+ col0["2"] = 22;
+ col0["4"] = 44;
+
+ // Apply non-serialized changes.
+ col.ApplyChanges(col0);
+
+ Assert.AreEqual(3, col.Count);
+ Assert.AreEqual(null, col["1"]);
+ Assert.AreEqual(22, col["2"]);
+ Assert.AreEqual(3, col["3"]);
+ Assert.AreEqual(44, col["4"]);
+
+ // Apply serialized changes without WriteChangesOnly.
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0));
+
+ Assert.AreEqual(3, col.Count);
+ Assert.AreEqual(null, col["1"]);
+ Assert.AreEqual(22, col["2"]);
+ Assert.AreEqual(3, col["3"]);
+ Assert.AreEqual(44, col["4"]);
+
+ // Apply serialized changes with WriteChangesOnly.
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0, true));
+
+ Assert.AreEqual(3, col.Count);
+ Assert.AreEqual(null, col["1"]);
+ Assert.AreEqual(22, col["2"]);
+ Assert.AreEqual(3, col["3"]);
+ Assert.AreEqual(44, col["4"]);
+
+ // Remove key then add back.
+ col0.Remove("2");
+ col0.Remove("3");
+ col0["2"] = 222;
+
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0));
+
+ Assert.AreEqual(2, col.Count);
+ Assert.AreEqual(222, col["2"]);
+ Assert.AreEqual(44, col["4"]);
+
+ // Remove all.
+ col0 = SerializeDeserialize(getCol());
+ col0.Clear();
+
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0, true));
+
+ Assert.AreEqual(0, col.Count);
+
+ // Add to empty.
+ col0["-1"] = -1;
+ col0["-2"] = -2;
+
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0));
+
+ Assert.AreEqual(2, col.Count);
+ Assert.AreEqual(-1, col0["-1"]);
+ Assert.AreEqual(-2, col0["-2"]);
+
+ // Remove initial key, then add it back, then remove again.
+ col0 = SerializeDeserialize(getCol());
+
+ col0.Remove("1");
+ col0.Remove("2");
+ col0["1"] = "111";
+ col0.Remove("1");
+
+ col = getCol();
+ col.ApplyChanges(SerializeDeserialize(col0, true));
+
+ Assert.AreEqual(1, col.Count);
+ Assert.AreEqual(3, col["3"]);
+ }
+
+ /// <summary>
+ /// Serializes and deserializes back an instance.
+ /// </summary>
+ private static IgniteSessionStateItemCollection SerializeDeserialize(IgniteSessionStateItemCollection data,
+ bool changesOnly = false)
+ {
+ var marsh = BinaryUtils.Marshaller;
+
+ using (var stream = new BinaryHeapStream(128))
+ {
+ var writer = marsh.StartMarshal(stream);
+
+ data.WriteBinary(writer.GetRawWriter(), changesOnly);
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ return new IgniteSessionStateItemCollection(marsh.StartUnmarshal(stream));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreDataTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreDataTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreDataTest.cs
new file mode 100644
index 0000000..a19ef96
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreDataTest.cs
@@ -0,0 +1,115 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.AspNet.Tests
+{
+ using System;
+ using System.IO;
+ using System.Reflection;
+ using System.Web;
+ using Apache.Ignite.AspNet.Impl;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="IgniteSessionStateStoreData"/>.
+ /// </summary>
+ public class IgniteSessionStateStoreDataTest
+ {
+ /// <summary>
+ /// Tests the data.
+ /// </summary>
+ [Test]
+ public void TestData()
+ {
+ // Modification method is internal.
+ var statics = new HttpStaticObjectsCollection();
+ statics.GetType().GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic)
+ .Invoke(statics, new object[] { "int", typeof(int), false });
+
+ var data = new IgniteSessionStateStoreData(statics, 44);
+
+ data.Items["key"] = "val";
+
+ Assert.AreEqual(44, data.Timeout);
+ Assert.AreEqual(1, data.StaticObjects.Count);
+ Assert.AreEqual(0, data.StaticObjects["int"]);
+ Assert.AreEqual("val", data.Items["key"]);
+ }
+
+ /// <summary>
+ /// Tests the empty data.
+ /// </summary>
+ [Test]
+ public void TestEmpty()
+ {
+ var data = new IgniteSessionStateStoreData(null, 0);
+
+ Assert.AreEqual(0, data.LockId);
+ Assert.AreEqual(0, data.Items.Count);
+ Assert.AreEqual(0, data.Timeout);
+ Assert.IsNull(data.LockNodeId);
+ Assert.IsNull(data.LockTime);
+ Assert.IsNull(data.StaticObjects);
+ }
+
+ /// <summary>
+ /// Tests the serialization.
+ /// </summary>
+ [Test]
+ public void TestSerialization()
+ {
+ var data = new IgniteSessionStateStoreData(null, 96)
+ {
+ Timeout = 97,
+ LockId = 11,
+ LockNodeId = Guid.NewGuid(),
+ LockTime = DateTime.UtcNow.AddHours(-1),
+ };
+
+ data.Items["key1"] = 1;
+ data.Items["key2"] = 2;
+
+ var data0 = SerializeDeserialize(data);
+
+ Assert.AreEqual(data.Timeout, data0.Timeout);
+ Assert.AreEqual(data.LockId, data0.LockId);
+ Assert.AreEqual(data.LockNodeId, data0.LockNodeId);
+ Assert.AreEqual(data.LockTime, data0.LockTime);
+ Assert.AreEqual(data.Items.Keys, data0.Items.Keys);
+ }
+
+
+ /// <summary>
+ /// Serializes and deserializes back an instance.
+ /// </summary>
+ private static IgniteSessionStateStoreData SerializeDeserialize(IgniteSessionStateStoreData data)
+ {
+ var marsh = BinaryUtils.Marshaller;
+
+ using (var stream = new BinaryHeapStream(128))
+ {
+ var writer = marsh.StartMarshal(stream);
+
+ data.WriteBinary(writer.GetRawWriter(), false);
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ return new IgniteSessionStateStoreData(marsh.StartUnmarshal(stream));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreProviderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreProviderTest.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreProviderTest.cs
new file mode 100644
index 0000000..fe41a12
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/IgniteSessionStateStoreProviderTest.cs
@@ -0,0 +1,485 @@
+\ufeff/*
+ * 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.
+ */
+
+namespace Apache.Ignite.AspNet.Tests
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Collections.Specialized;
+ using System.Linq;
+ using System.Reflection;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using System.Web;
+ using System.Web.SessionState;
+ using Apache.Ignite.Core;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Log;
+ using Apache.Ignite.Core.Tests;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="IgniteSessionStateStoreProvider"/>.
+ /// </summary>
+ public class IgniteSessionStateStoreProviderTest
+ {
+ /** Grid name XML config attribute. */
+ private const string GridNameAttr = "gridName";
+
+ /** Cache name XML config attribute. */
+ private const string CacheNameAttr = "cacheName";
+
+ /** Section name XML config attribute. */
+ private const string SectionNameAttr = "igniteConfigurationSectionName";
+
+ /** Grid name. */
+ private const string GridName = "grid1";
+
+ /** Cache name. */
+ private const string CacheName = "myCache";
+
+ /** Session id. */
+ private const string Id = "1";
+
+ /** Test context. */
+ private static readonly HttpContext HttpContext =
+ new HttpContext(new HttpRequest(null, "http://tempuri.org", null), new HttpResponse(null));
+
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) { GridName = GridName });
+ }
+
+ /// <summary>
+ /// Fixture teardown.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Test teardown.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ // Clear all caches.
+ var ignite = Ignition.GetIgnite(GridName);
+ ignite.GetCacheNames().ToList().ForEach(x => ignite.GetCache<object, object>(x).RemoveAll());
+ }
+
+ /// <summary>
+ /// Test setup.
+ /// </summary>
+ [SetUp]
+ public void SetUp()
+ {
+ // Make sure caches are empty.
+ var ignite = Ignition.GetIgnite(GridName);
+
+ foreach (var cache in ignite.GetCacheNames().Select(x => ignite.GetCache<object, object>(x)))
+ CollectionAssert.IsEmpty(cache.ToArray());
+ }
+
+ /// <summary>
+ /// Tests provider initialization.
+ /// </summary>
+ [Test]
+ public void TestInitialization()
+ {
+ var stateProvider = new IgniteSessionStateStoreProvider();
+
+ SessionStateActions actions;
+ bool locked;
+ TimeSpan lockAge;
+ object lockId;
+
+
+ // Not initialized
+ Assert.Throws<InvalidOperationException>(() =>
+ stateProvider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions));
+
+ // Grid not started
+ Assert.Throws<IgniteException>(() =>
+ stateProvider.Initialize("testName", new NameValueCollection
+ {
+ {GridNameAttr, "invalidGridName"},
+ {CacheNameAttr, CacheName}
+ }));
+
+ // Valid grid
+ stateProvider = GetProvider();
+
+ CheckProvider(stateProvider);
+ }
+
+ /// <summary>
+ /// Tests autostart from web configuration section.
+ /// </summary>
+ [Test]
+ public void TestStartFromWebConfigSection()
+ {
+ var provider = new IgniteSessionStateStoreProvider();
+
+ provider.Initialize("testName3", new NameValueCollection
+ {
+ {SectionNameAttr, "igniteConfiguration3"},
+ {CacheNameAttr, "cacheName3"}
+ });
+
+ CheckProvider(provider);
+ }
+
+ /// <summary>
+ /// Tests the caching.
+ /// </summary>
+ [Test]
+ public void TestCaching()
+ {
+ bool locked;
+ TimeSpan lockAge;
+ object lockId;
+ SessionStateActions actions;
+
+ var provider = GetProvider();
+
+ // Not locked, no item.
+ var res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNull(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ // Exclusive: not locked, no item.
+ res = provider.GetItemExclusive(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNull(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ // Add item.
+ provider.CreateUninitializedItem(HttpContext, Id, 7);
+
+ // Check added item.
+ res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(res);
+ Assert.AreEqual(7, res.Timeout);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ // Lock and update.
+ res = provider.GetItemExclusive(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+ provider.SetAndReleaseItemExclusive(HttpContext, Id, UpdateStoreData(res), lockId, true);
+
+ // Not locked, item present.
+ res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ CheckStoreData(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ // Lock item.
+ res = provider.GetItemExclusive(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ CheckStoreData(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ // Try to get it in a different thread.
+ Task.Factory.StartNew(() =>
+ {
+ object lockId1; // do not overwrite lockId
+ res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId1, out actions);
+ Assert.IsNull(res);
+ Assert.IsNotNull(lockId1);
+ Assert.IsTrue(locked);
+ Assert.Greater(lockAge, TimeSpan.Zero);
+ Assert.AreEqual(SessionStateActions.None, actions);
+ }).Wait();
+
+ // Try to get it in a different thread.
+ Task.Factory.StartNew(() =>
+ {
+ object lockId1; // do not overwrite lockId
+ res = provider.GetItemExclusive(HttpContext, Id, out locked, out lockAge, out lockId1, out actions);
+ Assert.IsNull(res);
+ Assert.IsNotNull(lockId1);
+ Assert.IsTrue(locked);
+ Assert.Greater(lockAge, TimeSpan.Zero);
+ Assert.AreEqual(SessionStateActions.None, actions);
+ }).Wait();
+
+ // Release item.
+ provider.ReleaseItemExclusive(HttpContext, Id, lockId);
+
+ // Make sure it is accessible in a different thread.
+ Task.Factory.StartNew(() =>
+ {
+ res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+ }).Wait();
+
+ // Remove item.
+ provider.RemoveItem(HttpContext, Id, lockId, null);
+
+ // Check removal.
+ res = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNull(res);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.AreEqual(SessionStateActions.None, actions);
+ }
+
+ /// <summary>
+ /// Tests the create new store data.
+ /// </summary>
+ [Test]
+ public void TestCreateNewStoreData()
+ {
+ var provider = GetProvider();
+
+ var data = provider.CreateNewStoreData(HttpContext, 56);
+
+ Assert.AreEqual(56, data.Timeout);
+ Assert.IsEmpty(data.Items);
+ Assert.IsEmpty(data.StaticObjects);
+
+ // Check that caches are empty.
+ var ignite = Ignition.GetIgnite(GridName);
+ Assert.IsFalse(ignite.GetCacheNames().SelectMany(x => ignite.GetCache<int, int>(x)).Any());
+ }
+
+ /// <summary>
+ /// Tests the expiry.
+ /// </summary>
+ [Test]
+ [Category(TestUtils.CategoryIntensive)] // Minimum expiration is 1 minute
+ public void TestExpiry()
+ {
+ var provider = GetProvider();
+
+ bool locked;
+ TimeSpan lockAge;
+ object lockId;
+ SessionStateActions actions;
+
+ // Callbacks are not supported for now.
+ Assert.IsFalse(GetProvider().SetItemExpireCallback(null));
+
+ // Check there is no item.
+ var res = provider.GetItem(HttpContext, "myId", out locked, out lockAge, out lockId, out actions);
+ Assert.IsNull(res);
+
+ // Put an item.
+ provider.CreateUninitializedItem(HttpContext, "myId", 1);
+
+ // Check that it is there.
+ res = provider.GetItem(HttpContext, "myId", out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(res);
+
+ // Wait a minute and check again.
+ Thread.Sleep(TimeSpan.FromMinutes(1.05));
+
+ res = provider.GetItem(HttpContext, "myId", out locked, out lockAge, out lockId, out actions);
+ Assert.IsNull(res);
+ }
+
+ /// <summary>
+ /// Tests the create uninitialized item.
+ /// </summary>
+ [Test]
+ public void TestCreateUninitializedItem()
+ {
+ bool locked;
+ TimeSpan lockAge;
+ object lockId;
+ SessionStateActions actions;
+
+ var provider = GetProvider();
+ provider.CreateUninitializedItem(HttpContext, "myId", 45);
+
+ var res = provider.GetItem(HttpContext, "myId", out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(res);
+ Assert.AreEqual(45, res.Timeout);
+ Assert.AreEqual(0, res.Items.Count);
+ Assert.AreEqual(0, res.StaticObjects.Count);
+ }
+
+ /// <summary>
+ /// Tests the trace logging.
+ /// </summary>
+ [Test]
+ public void TestTraceLogging()
+ {
+ var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ Logger = new SessionLogger()
+ };
+
+ using (Ignition.Start(cfg))
+ {
+ var provider = new IgniteSessionStateStoreProvider();
+
+ provider.Initialize("provider2", new NameValueCollection());
+
+ CheckProvider(provider);
+
+ var logs = SessionLogger.GetLogs();
+
+ Assert.AreEqual("Apache.Ignite.AspNet.IgniteSessionStateStoreProvider initialized: " +
+ "gridName=, cacheName=, applicationId=", logs[1]);
+
+ Assert.AreEqual("GetItem session store data found: id=1, url=/, timeout=0", logs[4]);
+ }
+ }
+
+ /// <summary>
+ /// Updates the store data.
+ /// </summary>
+ private static SessionStateStoreData UpdateStoreData(SessionStateStoreData data)
+ {
+ data.Timeout = 8;
+
+ data.Items["name1"] = 1;
+ data.Items["name2"] = "2";
+
+ var statics = data.StaticObjects;
+
+ // Modification method is internal.
+ statics.GetType().GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic)
+ .Invoke(statics, new object[] {"int", typeof(int), false});
+
+ CheckStoreData(data);
+
+ return data;
+ }
+
+ /// <summary>
+ /// Checks that store data is the same as <see cref="UpdateStoreData"/> returns.
+ /// </summary>
+ private static void CheckStoreData(SessionStateStoreData data)
+ {
+ Assert.IsNotNull(data);
+
+ Assert.AreEqual(8, data.Timeout);
+
+ Assert.AreEqual(1, data.Items["name1"]);
+ Assert.AreEqual(1, data.Items[0]);
+
+ Assert.AreEqual("2", data.Items["name2"]);
+ Assert.AreEqual("2", data.Items[1]);
+
+ Assert.AreEqual(0, data.StaticObjects["int"]);
+ }
+
+ /// <summary>
+ /// Gets the initialized provider.
+ /// </summary>
+ private static IgniteSessionStateStoreProvider GetProvider()
+ {
+ var stateProvider = new IgniteSessionStateStoreProvider();
+
+ stateProvider.Initialize("testName", new NameValueCollection
+ {
+ {GridNameAttr, GridName},
+ {CacheNameAttr, CacheName}
+ });
+
+ return stateProvider;
+ }
+
+ /// <summary>
+ /// Checks the provider.
+ /// </summary>
+ private static void CheckProvider(SessionStateStoreProviderBase provider)
+ {
+ bool locked;
+ TimeSpan lockAge;
+ object lockId;
+ SessionStateActions actions;
+
+ provider.InitializeRequest(HttpContext);
+ provider.CreateUninitializedItem(HttpContext, Id, 42);
+
+ var data = provider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions);
+ Assert.IsNotNull(data);
+ Assert.AreEqual(42, data.Timeout);
+ Assert.IsFalse(locked);
+ Assert.AreEqual(TimeSpan.Zero, lockAge);
+ Assert.IsNull(lockId);
+ Assert.AreEqual(SessionStateActions.None, actions);
+
+ provider.ResetItemTimeout(HttpContext, Id);
+ provider.EndRequest(HttpContext);
+ provider.Dispose();
+ }
+
+ /// <summary>
+ /// Logger.
+ /// </summary>
+ private class SessionLogger : ILogger
+ {
+ /** */
+ private static readonly List<string> Logs = new List<string>();
+
+ /** <inheritdoc /> */
+ public void Log(LogLevel level, string message, object[] args, IFormatProvider formatProvider, string category,
+ string nativeErrorInfo, Exception ex)
+ {
+ if (category != typeof(IgniteSessionStateStoreProvider).FullName)
+ return;
+
+ lock (Logs)
+ {
+ Logs.Add(string.Format(message, args));
+ }
+ }
+
+ /** <inheritdoc /> */
+ public bool IsEnabled(LogLevel level)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Gets the logs.
+ /// </summary>
+ /// <returns></returns>
+ public static string[] GetLogs()
+ {
+ lock (Logs)
+ {
+ return Logs.ToArray();
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..554e6de
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,25 @@
+\ufeffusing System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Apache.Ignite.AspNet.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite.NET")]
+[assembly: AssemblyCopyright("Copyright � 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("18ea4c71-a11d-4ab1-8042-418f7559d84f")]
+
+[assembly: AssemblyVersion("1.8.0.13244")]
+[assembly: AssemblyFileVersion("1.8.0.13244")]
+[assembly: AssemblyInformationalVersion("1.8.0")]
+
+[assembly: CLSCompliant(true)]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/packages.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/packages.config b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/packages.config
new file mode 100644
index 0000000..e764a30
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/packages.config
@@ -0,0 +1,4 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit.Runners" version="2.6.3" targetFramework="net40" />
+</packages>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
index cc8ba60..0910648 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs
@@ -39,4 +39,4 @@ using System.Runtime.InteropServices;
[assembly: CLSCompliant(true)]
-[assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bf8e0062a26bde53ccf0f8c42ef5b122a22052f99aecacb7028adcc163050324ee3c75ff40eb0cbe2d0426fa20eca03726cad90d7eb882ff47f5361567a82b676a27565f88b2479d7b9354ae0a1e526ee781b6e11de943d8f4a49efb53765f8c954022bede0fca86c133fab038af8dc88b67d6b6e5b9796d6ca490e699efab")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("Apache.Ignite.AspNet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bf8e0062a26bde53ccf0f8c42ef5b122a22052f99aecacb7028adcc163050324ee3c75ff40eb0cbe2d0426fa20eca03726cad90d7eb882ff47f5361567a82b676a27565f88b2479d7b9354ae0a1e526ee781b6e11de943d8f4a49efb53765f8c954022bede0fca86c133fab038af8dc88b67d6b6e5b9796d6ca490e699efab")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 12fa03a..5032533 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -59,10 +59,6 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
- <Compile Include="AspNet\ExpiryCacheHolderTest.cs" />
- <Compile Include="AspNet\IgniteSessionStateItemCollectionTest.cs" />
- <Compile Include="AspNet\IgniteSessionStateStoreDataTest.cs" />
- <Compile Include="AspNet\IgniteSessionStateStoreProviderTest.cs" />
<Compile Include="Binary\BinaryReaderWriterTest.cs" />
<Compile Include="Binary\IO\BinaryStreamsTest.cs" />
<Compile Include="Binary\JavaTypeMappingTest.cs" />
@@ -78,7 +74,6 @@
<Compile Include="Log\DefaultLoggerTest.cs" />
<Compile Include="Log\NLogLoggerTest.cs" />
<Compile Include="TestAppConfig.cs" />
- <Compile Include="AspNet\IgniteOutputCacheProviderTest.cs" />
<Compile Include="Binary\BinaryBuilderSelfTestFullFooter.cs" />
<Compile Include="Binary\BinaryCompactFooterInteropTest.cs" />
<Compile Include="Binary\BinarySelfTestFullFooter.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/ExpiryCacheHolderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/ExpiryCacheHolderTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/ExpiryCacheHolderTest.cs
deleted file mode 100644
index 6f8c2f6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/ExpiryCacheHolderTest.cs
+++ /dev/null
@@ -1,491 +0,0 @@
-\ufeff/*
- * 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.
- */
-
-// ReSharper disable UnusedAutoPropertyAccessor.Local
-namespace Apache.Ignite.Core.Tests.AspNet
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Apache.Ignite.AspNet.Impl;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Configuration;
- using Apache.Ignite.Core.Cache.Expiry;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Cache.Query.Continuous;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for <see cref="ExpiryCacheHolder{TK,TV}"/>.
- /// </summary>
- public class ExpiryCacheHolderTest
- {
- /// <summary>
- /// Tests the expiry policy.
- /// </summary>
- [Test]
- public void TestExpiryPolicy()
- {
- var cache = new CacheEx();
-
- Assert.IsNull(cache.ExpiryPolicy);
-
- var holder = new ExpiryCacheHolder<int, int>(cache);
-
- // Check same cache for same expiry.
- var cache1 = (CacheEx) holder.GetCacheWithExpiry(15);
-
- CheckExpiry(TimeSpan.FromSeconds(15), cache1);
- Assert.AreNotSame(cache, cache1);
- Assert.AreSame(cache1, holder.GetCacheWithExpiry(15));
-
- // Check rounding.
- var cache2 = (CacheEx) holder.GetCacheWithExpiry(DateTime.UtcNow.AddSeconds(15.1));
- Assert.AreSame(cache1, cache2);
-
- // Check no expiration.
- var cache3 = (CacheEx) holder.GetCacheWithExpiry(DateTime.MaxValue);
- Assert.AreSame(cache, cache3);
- }
-
- /// <summary>
- /// Checks the expiry.
- /// </summary>
- private static void CheckExpiry(TimeSpan timeSpan, CacheEx cache)
- {
- Assert.AreEqual(timeSpan, cache.ExpiryPolicy.GetExpiryForCreate());
- Assert.IsNull(cache.ExpiryPolicy.GetExpiryForUpdate());
- Assert.IsNull(cache.ExpiryPolicy.GetExpiryForAccess());
- }
-
- /// <summary>
- /// Test cache implementation.
- /// </summary>
- private class CacheEx : ICache<int, int>
- {
- public IExpiryPolicy ExpiryPolicy { get; set; }
-
- public IEnumerator<ICacheEntry<int, int>> GetEnumerator()
- {
- throw new NotImplementedException();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public string Name { get; private set; }
-
- public IIgnite Ignite { get; private set; }
-
- public CacheConfiguration GetConfiguration()
- {
- throw new NotImplementedException();
- }
-
- public bool IsEmpty()
- {
- throw new NotImplementedException();
- }
-
- public bool IsKeepBinary { get; private set; }
-
- public ICache<int, int> WithSkipStore()
- {
- throw new NotImplementedException();
- }
-
- public ICache<int, int> WithExpiryPolicy(IExpiryPolicy plc)
- {
- return new CacheEx {ExpiryPolicy = plc};
- }
-
- public ICache<TK1, TV1> WithKeepBinary<TK1, TV1>()
- {
- throw new NotImplementedException();
- }
-
- public void LoadCache(ICacheEntryFilter<int, int> p, params object[] args)
- {
- throw new NotImplementedException();
- }
-
- public Task LoadCacheAsync(ICacheEntryFilter<int, int> p, params object[] args)
- {
- throw new NotImplementedException();
- }
-
- public void LocalLoadCache(ICacheEntryFilter<int, int> p, params object[] args)
- {
- throw new NotImplementedException();
- }
-
- public Task LocalLoadCacheAsync(ICacheEntryFilter<int, int> p, params object[] args)
- {
- throw new NotImplementedException();
- }
-
- public void LoadAll(IEnumerable<int> keys, bool replaceExistingValues)
- {
- throw new NotImplementedException();
- }
-
- public Task LoadAllAsync(IEnumerable<int> keys, bool replaceExistingValues)
- {
- throw new NotImplementedException();
- }
-
- public bool ContainsKey(int key)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> ContainsKeyAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public bool ContainsKeys(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> ContainsKeysAsync(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public int LocalPeek(int key, params CachePeekMode[] modes)
- {
- throw new NotImplementedException();
- }
-
- public bool TryLocalPeek(int key, out int value, params CachePeekMode[] modes)
- {
- throw new NotImplementedException();
- }
-
- public int this[int key]
- {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- public int Get(int key)
- {
- throw new NotImplementedException();
- }
-
- public Task<int> GetAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public bool TryGet(int key, out int value)
- {
- throw new NotImplementedException();
- }
-
- public Task<CacheResult<int>> TryGetAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public IDictionary<int, int> GetAll(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public Task<IDictionary<int, int>> GetAllAsync(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public void Put(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task PutAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public CacheResult<int> GetAndPut(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<CacheResult<int>> GetAndPutAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public CacheResult<int> GetAndReplace(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<CacheResult<int>> GetAndReplaceAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public CacheResult<int> GetAndRemove(int key)
- {
- throw new NotImplementedException();
- }
-
- public Task<CacheResult<int>> GetAndRemoveAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public bool PutIfAbsent(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> PutIfAbsentAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public CacheResult<int> GetAndPutIfAbsent(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<CacheResult<int>> GetAndPutIfAbsentAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public bool Replace(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> ReplaceAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public bool Replace(int key, int oldVal, int newVal)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> ReplaceAsync(int key, int oldVal, int newVal)
- {
- throw new NotImplementedException();
- }
-
- public void PutAll(IDictionary<int, int> vals)
- {
- throw new NotImplementedException();
- }
-
- public Task PutAllAsync(IDictionary<int, int> vals)
- {
- throw new NotImplementedException();
- }
-
- public void LocalEvict(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public void Clear()
- {
- throw new NotImplementedException();
- }
-
- public Task ClearAsync()
- {
- throw new NotImplementedException();
- }
-
- public void Clear(int key)
- {
- throw new NotImplementedException();
- }
-
- public Task ClearAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public void ClearAll(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public Task ClearAllAsync(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public void LocalClear(int key)
- {
- throw new NotImplementedException();
- }
-
- public void LocalClearAll(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public bool Remove(int key)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> RemoveAsync(int key)
- {
- throw new NotImplementedException();
- }
-
- public bool Remove(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public Task<bool> RemoveAsync(int key, int val)
- {
- throw new NotImplementedException();
- }
-
- public void RemoveAll(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public Task RemoveAllAsync(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public void RemoveAll()
- {
- throw new NotImplementedException();
- }
-
- public Task RemoveAllAsync()
- {
- throw new NotImplementedException();
- }
-
- public int GetLocalSize(params CachePeekMode[] modes)
- {
- throw new NotImplementedException();
- }
-
- public int GetSize(params CachePeekMode[] modes)
- {
- throw new NotImplementedException();
- }
-
- public Task<int> GetSizeAsync(params CachePeekMode[] modes)
- {
- throw new NotImplementedException();
- }
-
- public void LocalPromote(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public IQueryCursor<ICacheEntry<int, int>> Query(QueryBase qry)
- {
- throw new NotImplementedException();
- }
-
- public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
- {
- throw new NotImplementedException();
- }
-
- public IContinuousQueryHandle QueryContinuous(ContinuousQuery<int, int> qry)
- {
- throw new NotImplementedException();
- }
-
- public IContinuousQueryHandle<ICacheEntry<int, int>> QueryContinuous(ContinuousQuery<int, int> qry, QueryBase initialQry)
- {
- throw new NotImplementedException();
- }
-
- public IEnumerable<ICacheEntry<int, int>> GetLocalEntries(params CachePeekMode[] peekModes)
- {
- throw new NotImplementedException();
- }
-
- public TRes Invoke<TArg, TRes>(int key, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
- {
- throw new NotImplementedException();
- }
-
- public Task<TRes> InvokeAsync<TArg, TRes>(int key, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
- {
- throw new NotImplementedException();
- }
-
- public IDictionary<int, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
- {
- throw new NotImplementedException();
- }
-
- public Task<IDictionary<int, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<int> keys, ICacheEntryProcessor<int, int, TArg, TRes> processor, TArg arg)
- {
- throw new NotImplementedException();
- }
-
- public ICacheLock Lock(int key)
- {
- throw new NotImplementedException();
- }
-
- public ICacheLock LockAll(IEnumerable<int> keys)
- {
- throw new NotImplementedException();
- }
-
- public bool IsLocalLocked(int key, bool byCurrentThread)
- {
- throw new NotImplementedException();
- }
-
- public ICacheMetrics GetMetrics()
- {
- throw new NotImplementedException();
- }
-
- public Task Rebalance()
- {
- throw new NotImplementedException();
- }
-
- public ICache<int, int> WithNoRetries()
- {
- throw new NotImplementedException();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteOutputCacheProviderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteOutputCacheProviderTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteOutputCacheProviderTest.cs
deleted file mode 100644
index 51bfdc1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteOutputCacheProviderTest.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-\ufeff/*
- * 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.
- */
-
-namespace Apache.Ignite.Core.Tests.AspNet
-{
- using System;
- using System.Collections.Specialized;
- using System.Threading;
- using Apache.Ignite.AspNet;
- using Apache.Ignite.Core.Common;
- using NUnit.Framework;
-
- /// <summary>
- /// Tests for <see cref="IgniteOutputCacheProvider"/>
- /// </summary>
- public class IgniteOutputCacheProviderTest
- {
- /** Grid name XML config attribute. */
- private const string GridNameAttr = "gridName";
-
- /** Cache name XML config attribute. */
- private const string CacheNameAttr = "cacheName";
-
- /** Cache name XML config attribute. */
- private const string SectionNameAttr = "igniteConfigurationSectionName";
-
- /** Grid name. */
- private const string GridName = "grid1";
-
- /** Cache name. */
- private const string CacheName = "myCache";
-
- /// <summary>
- /// Fixture setup.
- /// </summary>
- [TestFixtureSetUp]
- public void TestFixtureSetUp()
- {
- Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) {GridName = GridName});
- }
-
- /// <summary>
- /// Fixture teardown.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Tests provider initialization.
- /// </summary>
- [Test]
- public void TestInitialization()
- {
- var cacheProvider = new IgniteOutputCacheProvider();
-
- // Not initialized
- Assert.Throws<InvalidOperationException>(() => cacheProvider.Get("1"));
-
- // Grid not started
- Assert.Throws<IgniteException>(() =>
- cacheProvider.Initialize("testName", new NameValueCollection
- {
- {GridNameAttr, "invalidGridName"},
- {CacheNameAttr, CacheName}
- }));
-
- // Valid grid
- cacheProvider = GetProvider();
-
- cacheProvider.Set("1", 1, DateTime.MaxValue);
- Assert.AreEqual(1, cacheProvider.Get("1"));
- }
-
- /// <summary>
- /// Tests autostart from web configuration section.
- /// </summary>
- [Test]
- public void TestStartFromWebConfigSection()
- {
- var cacheProvider = new IgniteOutputCacheProvider();
-
- cacheProvider.Initialize("testName2", new NameValueCollection
- {
- {SectionNameAttr, "igniteConfiguration2"},
- {CacheNameAttr, "cacheName2"}
- });
-
- cacheProvider.Set("1", 3, DateTime.MaxValue);
- Assert.AreEqual(3, cacheProvider.Get("1"));
- }
-
- /// <summary>
- /// Tests provider caching.
- /// </summary>
- [Test]
- public void TestCaching()
- {
- var cacheProvider = GetProvider();
-
- Assert.AreEqual(null, cacheProvider.Get("1"));
- cacheProvider.Set("1", 1, DateTime.MaxValue);
- Assert.AreEqual(1, cacheProvider.Get("1"));
-
- cacheProvider.Remove("1");
- Assert.AreEqual(null, cacheProvider.Get("1"));
-
- Assert.AreEqual(null, cacheProvider.Add("2", 2, DateTime.MaxValue));
- Assert.AreEqual(2, cacheProvider.Add("2", 5, DateTime.MaxValue));
- }
-
- /// <summary>
- /// Tests cache expiration.
- /// </summary>
- [Test]
- public void TestExpiry()
- {
- var cacheProvider = GetProvider();
- cacheProvider.Remove("1");
-
- // Set
- cacheProvider.Set("1", 1, DateTime.UtcNow.AddSeconds(1.3));
- Assert.AreEqual(1, cacheProvider.Get("1"));
- Thread.Sleep(2000);
- Assert.AreEqual(null, cacheProvider.Get("1"));
-
- cacheProvider.Set("1", 1, DateTime.UtcNow);
- Assert.AreEqual(null, cacheProvider.Get("1"));
-
- // Add
- cacheProvider.Add("1", 1, DateTime.UtcNow.AddSeconds(0.7));
- Assert.AreEqual(1, cacheProvider.Get("1"));
- Thread.Sleep(2000);
- Assert.AreEqual(null, cacheProvider.Get("1"));
-
- cacheProvider.Add("1", 1, DateTime.UtcNow);
- Assert.AreEqual(null, cacheProvider.Get("1"));
- }
-
- /// <summary>
- /// Gets the initialized provider.
- /// </summary>
- private static IgniteOutputCacheProvider GetProvider()
- {
- var cacheProvider = new IgniteOutputCacheProvider();
-
- cacheProvider.Initialize("testName", new NameValueCollection
- {
- {GridNameAttr, GridName},
- {CacheNameAttr, CacheName}
- });
-
- return cacheProvider;
- }
- }
-}