lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1099279 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core: PartiallyTrustedAppDomain.cs TestSupportClass.cs
Date Tue, 03 May 2011 22:06:26 GMT
Author: digy
Date: Tue May  3 22:06:25 2011
New Revision: 1099279

URL: http://svn.apache.org/viewvc?rev=1099279&view=rev
Log:
[LUCENENET-412] [LUCENENET-413] 
Lucene.Net 2.9.4g
Test cases for "Medium trust security issue"

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs?rev=1099279&r1=1099278&r2=1099279&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
Tue May  3 22:06:25 2011
@@ -38,7 +38,7 @@ namespace Lucene.Net.Test
         /// <param name="methodName">method to invoke</param>
         /// <param name="constructorArgs">constructor's parameters</param>
         /// <param name="methodArgs">method's parameters</param>
-        public static void Run(Type clazz, string methodName, object[] constructorArgs, object[]
methodArgs)
+        public static object Run(Type clazz, string methodName, object[] constructorArgs,
object[] methodArgs)
         {
             try
             {
@@ -49,8 +49,8 @@ namespace Lucene.Net.Test
                 permissions.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess));
 
                 AppDomain appDomain = AppDomain.CreateDomain("PartiallyTrustedAppDomain",
null, setup, permissions);
-
-                object p = appDomain.CreateInstanceAndUnwrap(
+                                
+                object obj = appDomain.CreateInstanceAndUnwrap(
                     clazz.Assembly.FullName,
                     clazz.FullName,
                     false,
@@ -59,7 +59,9 @@ namespace Lucene.Net.Test
                     constructorArgs,
                     System.Globalization.CultureInfo.CurrentCulture,
                     null);
-                p.GetType().InvokeMember(methodName, BindingFlags.InvokeMethod, null, p,
methodArgs);
+                
+                object ret =  clazz.InvokeMember(methodName, BindingFlags.InvokeMethod, null,
obj, methodArgs);
+                return ret;
             }
             catch (TypeLoadException tlex)
             {

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs?rev=1099279&r1=1099278&r2=1099279&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs Tue May
 3 22:06:25 2011
@@ -1206,6 +1206,85 @@ namespace Lucene.Net._SupportClass
         }
     }
 
+    [TestFixture]
+    [Serializable]
+    public class TestMediumTrust
+    {
+        [Test]
+        public void Test_Index_Term()
+        {
+            //invoke any method
+            Assert.AreEqual("field:text",Lucene.Net.Test.PartiallyTrustedAppDomain.Run(typeof(Lucene.Net.Index.Term),
"ToString", new object[] { "field", "text" }, null));
+        }
+
+
+
+        [Test]
+        public void Test_Search_NumericRangeQuery()
+        {
+            //invoking this static method is enough
+            Lucene.Net.Test.PartiallyTrustedAppDomain.Run(this.GetType(), "CreateNumericRangeQuery",
null, null);
+        }
+
+        public NumericRangeQuery CreateNumericRangeQuery()
+        {
+            return NumericRangeQuery.NewIntRange("field", 0, 10, true, true);
+        }
+
+
+
+        [Test]
+        public void Test_Search_SortField()
+        {
+            //invoke any method
+            Lucene.Net.Test.PartiallyTrustedAppDomain.Run(typeof(Lucene.Net.Search.SortField),
"GetUseLegacySearch", new object[]{"field"}, null);
+        }
+
+
+
+        [Test]
+        public void Test_Util_Parameter()
+        {
+            //invoke any method
+            Assert.AreEqual("sometext", Lucene.Net.Test.PartiallyTrustedAppDomain.Run(typeof(PARAM),
"ToString", new object[] { "sometext" }, null));
+        }
+        
+        [Serializable]
+        public class PARAM : Lucene.Net.Util.Parameter
+        {
+            public PARAM(string field) : base(field)
+            {
+            }
+        }
+
+        [Test]
+        public void TestThisTest()
+        {
+            try
+            {
+                Lucene.Net.Test.PartiallyTrustedAppDomain.Run(typeof(TestDummyClass), "DummyMethod",
null, null);
+                Assert.Fail("This call must fail");
+            }
+            catch(TypeLoadException)
+            {
+            }
+        }
+
+        public class TestDummyClass: System.Runtime.Serialization.IObjectReference
+        {
+            public void DummyMethod()
+            {
+            }
+
+            public object GetRealObject(System.Runtime.Serialization.StreamingContext context)
+            {
+                return this;
+            }
+        }
+
+        
+    }
+
 }
 
 



Mime
View raw message