Exemplo n.º 1
0
        public virtual void testBig()
        {
            hf = new HotFolder(theHF, null, new MyListener(true));
            FileInfo file = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);

            FileStream fos = new FileStream(file.FullName, FileMode.Open);

            byte[] ba = new byte[1];
            for (int i = 0; i < 20; i++) // incrementally fill file
            {
                ba[0] = (byte)i;
                fos.Write(ba, 0, 1);
                fos.Flush();

                StatusCounter.sleep(10);
            }
            file.Refresh();
            Assert.IsTrue(file.Exists);
            fos.Close();

            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsFalse(file.Exists);
        }
Exemplo n.º 2
0
        public virtual void testExtension()
        {
            hf = new HotFolder(theHF, ".txt,.xml", new MyListener(true));
            StatusCounter.sleep(1000); // time to start up
            FileInfo file  = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");
            FileInfo file1 = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.xml");
            FileInfo file2 = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.foo");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            SupportClass.FileSupport.CreateNewFile(file1);
            file1.Refresh();
            Assert.IsTrue(file1.Exists);
            SupportClass.FileSupport.CreateNewFile(file2);
            file2.Refresh();
            Assert.IsTrue(file2.Exists);
            StatusCounter.sleep(4000);
            file.Refresh();
            file1.Refresh();
            file2.Refresh();
            Assert.IsFalse(file.Exists);
            Assert.IsFalse(file1.Exists);
            Assert.IsTrue(file2.Exists);
        }
Exemplo n.º 3
0
        public virtual void testStopStart()
        {
            hf = new HotFolder(theHF, null, new MyListener(true));
            FileInfo file = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsFalse(file.Exists, "First delete attempt.");
            hf.Stop();
            hf.Stop();
            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            hf.restart();
            hf.restart();
            hf.restart();
            StatusCounter.sleep(5000);
            file.Refresh();
            Assert.IsFalse(file.Exists, "Second delete attempt.");
        }
Exemplo n.º 4
0
        public virtual void testStartNull()
        {
            hf = new HotFolder(theHF, null, new MyListener(false));
            FileInfo file = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsTrue(file.Exists);
        }
Exemplo n.º 5
0
 public virtual void testRestartMany()
 {
     hf = new HotFolder(theHF, null, new MyListener(true));
     for (int i = 0; i < 10; i++)
     {
         // Java to C# Conversion - TODO: What is .NET Equivalent to activeCount()?
         //Assert.AreEqual(3, Thread.activeCount());
         hf.restart();
     }
     for (int i = 0; i < 3; i++)
     {
         Thread.Sleep(1);
         hf.Stop();
         // Java to C# Conversion - TODO: What is .NET Equivalent to activeCount()?
         //Assert.AreEqual(2, Thread.activeCount());
     }
 }
Exemplo n.º 6
0
        private readonly JDFCommand queueCommand;     // the jdf command template that is used to generate a new message for each dropped file

        ///
        ///     <summary> *
        ///     * constructor for a simple queue based hotfolder watcher that is automagically started in its own thread
        ///     *  </summary>
        ///     * <param name="_hotFolderDir"> the hot folder directory to watch </param>
        ///     * <param name="_storageDir"> the storage directory wher hot files are moved to </param>
        ///     * <param name="ext"> the file extensions that are moved - if null no filtering </param>
        ///     * <param name="hfListener"> callback that receives the generated JMF - the location of the stored file will be found in the standard command parameters </param>
        ///     * <param name="_queueCommand"> the jmf template that will be used to generate a new message, null creates an empty SubmitQueueEntry template </param>
        ///
        public QueueHotFolder(DirectoryInfo _hotFolderDir, DirectoryInfo _storageDir, string ext, QueueHotFolderListener hfListener, JDFJMF _queueCommand)
        {
            JDFJMF _queueCommandLocal = _queueCommand;

            storageDir = _storageDir;
            if (!storageDir.Exists)
            {
                storageDir.Create(); // just in case
            }
            qhfl = hfListener;
            if (_queueCommandLocal == null)
            {
                _queueCommandLocal = JDFJMF.createJMF(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);
            }

            queueCommand = _queueCommandLocal.getCommand(0);
            hf           = new HotFolder(_hotFolderDir, ext, this);
        }
Exemplo n.º 7
0
        public virtual void testDir()
        {
            hf = new HotFolder(theHF, ".txt,.xml", new MyListener(true));
            FileInfo file  = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");
            FileInfo file1 = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f2.xml"
                                          + Path.DirectorySeparatorChar.ToString() + "f1.xml");
            DirectoryInfo file2 = new DirectoryInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f2.xml");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            file2.Create();
            file2.Refresh();
            SupportClass.FileSupport.CreateNewFile(file1);
            file1.Refresh();
            Assert.IsTrue(file.Exists);
            StatusCounter.sleep(5000);
            file.Refresh();
            file1.Refresh();
            file2.Refresh();
            Assert.IsFalse(file.Exists);
            Assert.IsTrue(file1.Exists, "in subdir");
            Assert.IsTrue(file2.Exists);
        }