public void TestEmptyTitle()
        {
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, false, typeof(NoTitleDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            wldt.DoLogic();
            wldt.Dispose();


            doReadTest(file, FileType.PLAIN, "", "date", "body");
        }
        public void TestRegularFile()
        {
            // Create a document in regular format.
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, false, typeof(WriteLineDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            wldt.DoLogic();
            wldt.Dispose();


            doReadTest(file, FileType.PLAIN, "title", "date", "body");
        }
예제 #3
0
        public void TestMultiThreaded()
        {
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, false, typeof(ThreadingDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            ThreadClass[] threads = new ThreadClass[10];
            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new ThreadAnonymousHelper("t" + i, wldt);
            }

            foreach (ThreadClass t in threads)
            {
                t.Start();
            }
            foreach (ThreadClass t in threads)
            {
                t.Join();
            }

            wldt.Dispose();

            ISet <String> ids = new HashSet <string>();
            TextReader    br  = new StreamReader(new FileStream(file.FullName, FileMode.Open, FileAccess.Read), Encoding.UTF8);

            try
            {
                String line = br.ReadLine();
                assertHeaderLine(line); // header line is written once, no matter how many threads there are
                for (int i = 0; i < threads.Length; i++)
                {
                    line = br.ReadLine();
                    String[] parts = line.Split(WriteLineDocTask.SEP).TrimEnd();
                    assertEquals(3, parts.Length);
                    // check that all thread names written are the same in the same line
                    String tname = parts[0].Substring(parts[0].IndexOf('_'));
                    ids.add(tname);
                    assertEquals(tname, parts[1].Substring(parts[1].IndexOf('_')));
                    assertEquals(tname, parts[2].Substring(parts[2].IndexOf('_')));
                }
                // only threads.length lines should exist
                assertNull(br.ReadLine());
                assertEquals(threads.Length, ids.size());
            }
            finally
            {
                br.Dispose();
            }
        }
        public void TestEmptyBody()
        {
            // WriteLineDocTask threw away documents w/ no BODY element, even if they
            // had a TITLE element (LUCENE-1755). It should throw away documents if they
            // don't have BODY nor TITLE
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, false, typeof(NoBodyDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            wldt.DoLogic();
            wldt.Dispose();


            doReadTest(file, FileType.PLAIN, "title", "date", null);
        }
        public void TestCharsReplace()
        {
            // WriteLineDocTask replaced only \t characters w/ a space, since that's its
            // separator char. However, it didn't replace newline characters, which
            // resulted in errors in LineDocSource.
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, false, typeof(NewLinesDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            wldt.DoLogic();
            wldt.Dispose();


            doReadTest(file, FileType.PLAIN, "title text", "date text", "body text two");
        }
        public void TestEmptyDoc()
        {
            FileInfo         file    = new FileInfo(Path.Combine(getWorkDir().FullName, "one-line"));
            PerfRunData      runData = createPerfRunData(file, true, typeof(EmptyDocMaker).AssemblyQualifiedName);
            WriteLineDocTask wldt    = new WriteLineDocTask(runData);

            wldt.DoLogic();
            wldt.Dispose();

            TextReader br = new StreamReader(new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);

            try
            {
                String line = br.ReadLine();
                assertHeaderLine(line);
                line = br.ReadLine();
                assertNotNull(line);
            }
            finally
            {
                br.Dispose();
            }
        }