Exemplo n.º 1
0
        public virtual void  TestRAMDirectoryNoLocking()
        {
            Directory dir = new RAMDirectory();

            dir.SetLockFactory(NoLockFactory.GetNoLockFactory());

            Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory.setLockFactory did not take");

            IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);

            // Create a 2nd IndexWriter.  This is normally not allowed but it should run through since we're not
            // using any locks:
            IndexWriter writer2 = null;

            try
            {
                writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
            }
            catch (System.Exception e)
            {
                System.Console.Out.WriteLine(e.StackTrace);
                Assert.Fail("Should not have hit an IOException with no locking");
            }

            writer.Close();
            if (writer2 != null)
            {
                writer2.Close();
            }
        }
Exemplo n.º 2
0
		public virtual void  TestRAMDirectoryNoLocking()
		{
			Directory dir = new RAMDirectory();
			dir.SetLockFactory(NoLockFactory.GetNoLockFactory());
			
			Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory.setLockFactory did not take");
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			
			// Create a 2nd IndexWriter.  This is normally not allowed but it should run through since we're not
			// using any locks:
			IndexWriter writer2 = null;
			try
			{
				writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
			}
			catch (System.Exception e)
			{
				System.Console.Out.WriteLine(e.StackTrace);
				Assert.Fail("Should not have hit an IOException with no locking");
			}
			
			writer.Close();
			if (writer2 != null)
			{
				writer2.Close();
			}
		}
Exemplo n.º 3
0
        public virtual void  TestDefaultRAMDirectory()
        {
            Directory dir = new RAMDirectory();

            Assert.IsTrue(typeof(SingleInstanceLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory did not use correct LockFactory: got " + dir.GetLockFactory());

            IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);

            // Create a 2nd IndexWriter.  This should fail:
            IndexWriter writer2 = null;

            try
            {
                writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
                Assert.Fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
            }
            catch (System.IO.IOException e)
            {
            }

            writer.Close();
            if (writer2 != null)
            {
                writer2.Close();
            }
        }
Exemplo n.º 4
0
		public virtual void  TestDefaultRAMDirectory()
		{
			Directory dir = new RAMDirectory();
			
			Assert.IsTrue(typeof(SingleInstanceLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory did not use correct LockFactory: got " + dir.GetLockFactory());
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			
			// Create a 2nd IndexWriter.  This should fail:
			IndexWriter writer2 = null;
			try
			{
				writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
				Assert.Fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
			}
			catch (System.IO.IOException e)
			{
			}
			
			writer.Close();
			if (writer2 != null)
			{
				writer2.Close();
			}
		}