Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 44340200B80 for ; Wed, 14 Sep 2016 12:51:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3F8DB160ABA; Wed, 14 Sep 2016 10:51:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BB055160AB4 for ; Wed, 14 Sep 2016 12:51:57 +0200 (CEST) Received: (qmail 3083 invoked by uid 500); 14 Sep 2016 10:51:57 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 3061 invoked by uid 99); 14 Sep 2016 10:51:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Sep 2016 10:51:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BCF14DFCC0; Wed, 14 Sep 2016 10:51:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: ptupitsyn@apache.org To: commits@ignite.apache.org Date: Wed, 14 Sep 2016 10:51:56 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/6] ignite git commit: Move tests to a separate project archived-at: Wed, 14 Sep 2016 10:51:59 -0000 Repository: ignite Updated Branches: refs/heads/ignite-3199-1 a5916d3d7 -> 68e4cd0bc http://git-wip-us.apache.org/repos/asf/ignite/blob/c359c543/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateItemCollectionTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateItemCollectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateItemCollectionTest.cs deleted file mode 100644 index 823d3d0..0000000 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateItemCollectionTest.cs +++ /dev/null @@ -1,267 +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. - */ - -namespace Apache.Ignite.Core.Tests.AspNet -{ - using System; - using System.IO; - using System.Linq; - using Apache.Ignite.AspNet.Impl; - using Apache.Ignite.Core.Impl.Binary; - using Apache.Ignite.Core.Impl.Binary.IO; - using NUnit.Framework; - - /// - /// Tests for . - /// - public class IgniteSessionStateItemCollectionTest - { - /// - /// Tests the empty collection. - /// - [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().ToArray()); - Assert.IsEmpty(col.Keys); - Assert.IsNotNull(col.SyncRoot); - - Assert.IsNull(col["key"]); - Assert.Throws(() => col[0] = "x"); - Assert.Throws(() => Assert.AreEqual(0, col[0])); - Assert.Throws(() => col.RemoveAt(0)); - - col.Clear(); - col.Remove("test"); - - Assert.AreEqual(0, col.Count); - - col.Dirty = true; - Assert.IsTrue(col.Dirty); - } - } - - /// - /// Tests the modification. - /// - [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()); - 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()); - - // 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); - } - - /// - /// Tests dirty tracking. - /// - [Test] - public void TestApplyChanges() - { - Func 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"]); - } - - /// - /// Serializes and deserializes back an instance. - /// - 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.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs deleted file mode 100644 index c9ee30a..0000000 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreDataTest.cs +++ /dev/null @@ -1,117 +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. - */ - -namespace Apache.Ignite.Core.Tests.AspNet -{ - using System; - using System.IO; - using System.Reflection; - using System.Web; - using Apache.Ignite.AspNet.Impl; - using Apache.Ignite.Core.Impl.Binary; - using Apache.Ignite.Core.Impl.Binary.IO; - using NUnit.Framework; - - /// - /// Tests for . - /// - public class IgniteSessionStateStoreDataTest - { - /// - /// Tests the data. - /// - [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"]); - } - - /// - /// Tests the empty data. - /// - [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); - } - - /// - /// Tests the serialization. - /// - [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); - } - - - /// - /// Serializes and deserializes back an instance. - /// - 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.Core.Tests/AspNet/IgniteSessionStateStoreProviderTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreProviderTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreProviderTest.cs deleted file mode 100644 index 0cedc0e..0000000 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/AspNet/IgniteSessionStateStoreProviderTest.cs +++ /dev/null @@ -1,484 +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. - */ - -namespace Apache.Ignite.Core.Tests.AspNet -{ - 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.AspNet; - using Apache.Ignite.Core.Common; - using Apache.Ignite.Core.Log; - using NUnit.Framework; - - /// - /// Tests for . - /// - 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)); - - /// - /// Fixture setup. - /// - [TestFixtureSetUp] - public void TestFixtureSetUp() - { - Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) { GridName = GridName }); - } - - /// - /// Fixture teardown. - /// - [TestFixtureTearDown] - public void TestFixtureTearDown() - { - Ignition.StopAll(true); - } - - /// - /// Test teardown. - /// - [TearDown] - public void TearDown() - { - // Clear all caches. - var ignite = Ignition.GetIgnite(GridName); - ignite.GetCacheNames().ToList().ForEach(x => ignite.GetCache(x).RemoveAll()); - } - - /// - /// Test setup. - /// - [SetUp] - public void SetUp() - { - // Make sure caches are empty. - var ignite = Ignition.GetIgnite(GridName); - - foreach (var cache in ignite.GetCacheNames().Select(x => ignite.GetCache(x))) - CollectionAssert.IsEmpty(cache.ToArray()); - } - - /// - /// Tests provider initialization. - /// - [Test] - public void TestInitialization() - { - var stateProvider = new IgniteSessionStateStoreProvider(); - - SessionStateActions actions; - bool locked; - TimeSpan lockAge; - object lockId; - - - // Not initialized - Assert.Throws(() => - stateProvider.GetItem(HttpContext, Id, out locked, out lockAge, out lockId, out actions)); - - // Grid not started - Assert.Throws(() => - stateProvider.Initialize("testName", new NameValueCollection - { - {GridNameAttr, "invalidGridName"}, - {CacheNameAttr, CacheName} - })); - - // Valid grid - stateProvider = GetProvider(); - - CheckProvider(stateProvider); - } - - /// - /// Tests autostart from web configuration section. - /// - [Test] - public void TestStartFromWebConfigSection() - { - var provider = new IgniteSessionStateStoreProvider(); - - provider.Initialize("testName3", new NameValueCollection - { - {SectionNameAttr, "igniteConfiguration3"}, - {CacheNameAttr, "cacheName3"} - }); - - CheckProvider(provider); - } - - /// - /// Tests the caching. - /// - [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); - } - - /// - /// Tests the create new store data. - /// - [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(x)).Any()); - } - - /// - /// Tests the expiry. - /// - [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); - } - - /// - /// Tests the create uninitialized item. - /// - [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); - } - - /// - /// Tests the trace logging. - /// - [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]); - } - } - - /// - /// Updates the store data. - /// - 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; - } - - /// - /// Checks that store data is the same as returns. - /// - 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"]); - } - - /// - /// Gets the initialized provider. - /// - private static IgniteSessionStateStoreProvider GetProvider() - { - var stateProvider = new IgniteSessionStateStoreProvider(); - - stateProvider.Initialize("testName", new NameValueCollection - { - {GridNameAttr, GridName}, - {CacheNameAttr, CacheName} - }); - - return stateProvider; - } - - /// - /// Checks the provider. - /// - 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(); - } - - /// - /// Logger. - /// - private class SessionLogger : ILogger - { - /** */ - private static readonly List Logs = new List(); - - /** */ - 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)); - } - } - - /** */ - public bool IsEnabled(LogLevel level) - { - return true; - } - - /// - /// Gets the logs. - /// - /// - 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.sln ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.sln b/modules/platforms/dotnet/Apache.Ignite.sln index b2dd535..e8375d4 100644 --- a/modules/platforms/dotnet/Apache.Ignite.sln +++ b/modules/platforms/dotnet/Apache.Ignite.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests", "Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj", "{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}" @@ -38,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.AspNet", "Apa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.NLog", "Apache.Ignite.NLog\Apache.Ignite.NLog.csproj", "{C6B58E4A-A2E9-4554-AD02-68CE6DA5CFB7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.AspNet.Tests", "Apache.Ignite.AspNet.Tests\Apache.Ignite.AspNet.Tests.csproj", "{18EA4C71-A11D-4AB1-8042-418F7559D84F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -188,6 +192,18 @@ Global {C6B58E4A-A2E9-4554-AD02-68CE6DA5CFB7}.Release|x64.Build.0 = Release|Any CPU {C6B58E4A-A2E9-4554-AD02-68CE6DA5CFB7}.Release|x86.ActiveCfg = Release|Any CPU {C6B58E4A-A2E9-4554-AD02-68CE6DA5CFB7}.Release|x86.Build.0 = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|x64.ActiveCfg = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|x64.Build.0 = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|x86.ActiveCfg = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Debug|x86.Build.0 = Debug|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|Any CPU.Build.0 = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|x64.ActiveCfg = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|x64.Build.0 = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|x86.ActiveCfg = Release|Any CPU + {18EA4C71-A11D-4AB1-8042-418F7559D84F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE