Inheritance: DefaultTraceListener
        public void Run(params string[] args)
        {
            PhoneSystem ps     = PhoneSystem.Root;
            String      filter = null;

            if (args.Length > 1)
            {
                filter = args[1];
            }
            MyListener a = new MyListener(filter);

            ps.Updated  += new NotificationEventHandler(a.ps_Updated);
            ps.Inserted += new NotificationEventHandler(a.ps_Inserted);
            ps.Deleted  += new NotificationEventHandler(a.ps_Deleted);
            Statistics[] myStat;
            myStat = ps.InitializeStatistics(args[1]);
            foreach (Statistics s in myStat)
            {
                Console.WriteLine(s.ToString());
            }

            while (true)
            {
                Thread.Sleep(5000);
            }
        }
        public void TestConfigAvailable()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType(typeof(SupportBean));

            // add service (not serializable, transient configuration)
            Dictionary <string, object> transients = new Dictionary <string, object>();

            transients.Put(SERVICE_NAME, new MyLocalService(SECRET_VALUE));
            configuration.TransientConfiguration = transients;

            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(configuration);

            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, this.GetType(), this.GetType().FullName);
            }

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from SupportBean");
            MyListener  listener = new MyListener();

            stmt.Events += (sender, e) => listener.Update(e.NewEvents, e.OldEvents, e.Statement, e.ServiceProvider);

            epService.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(SECRET_VALUE, listener.SecretValue);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Beispiel #3
0
        public virtual void TestRemoveChemObjectIOListener()
        {
            MyListener listener = new MyListener();

            ChemObjectIOToTest.Listeners.Add(listener);
            ChemObjectIOToTest.Listeners.Remove(listener);
        }
Beispiel #4
0
        private void frmDebugOutput_Load(object sender, EventArgs e)
        {
            _Listener     = new MyListener();
            _Listener.frm = this;

            this.EnableListenDebugOutput = true;
        }
Beispiel #5
0
        private void Parse_Click(object sender, RoutedEventArgs e)
        {
            AntlrInputStream  stream   = new AntlrInputStream(this._tbInput.Text);
            QSLexer           lex      = new QSLexer(stream);
            CommonTokenStream tokens   = new CommonTokenStream(lex);
            QSParser          parser   = new QSParser(tokens);
            IParseTree        tree     = parser.form();
            MyListener        listener = new MyListener(parser);
            ParseTreeWalker   walker   = new ParseTreeWalker();

            walker.Walk(listener, tree);
            IVisitor <bool> check = TypeChecker.StartVisit(listener.Root);

            if (check.Result)
            {
                GUIBuilder            builder = GUIBuilder.BuildGUI(listener.Root);
                System.Windows.Window wind    = new Window();
                wind.Width   = 500;
                wind.Content = builder.Result;
                wind.Show();
            }
            else
            {
                this._tbOutput.Text = ((TypeChecker)check).Output.ToString();
            }
        }
Beispiel #6
0
    void Awake()
    {
#if UNITY_IOS
        FTDSdk.initIos(android_appId, android_appKey, android_signWay);
#elif UNITY_ANDROID
        FTDSdk.initAndroid(android_appId, android_appKey, android_signWay);
#else
#endif
        //FTDSdk.init(android_appId, android_appKey, android_signWay);

        //以下设置回调接口,若不需要则可以忽略不设置
        FtOnattributeChangedListener myListener = new MyListener();
        FtHttpCallback      myCallback          = new MyHttpCallback();
        FtPayVerifyCallback payVerifyCallback   = new MyPayVerifyCallback();
        FTDSdk.getInstance().setOnAttributeListener(myListener);
        FTDSdk.getInstance().setHttpCallback(myCallback);
        FTDSdk.getInstance().setPayVerifyCallback(payVerifyCallback);
        Dictionary <String, String> onlineTimeParams = new Dictionary <String, String>();
        onlineTimeParams.Add("Awake", "aaa");

        if (FTDSdk.getInstance() == null)
        {
            return;
        }
        FTDSdk.getInstance().setOnlineTimeParams(onlineTimeParams);
    }
Beispiel #7
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            var eplStatement = "create context MyContext start PayloadEvent end after 0.5 seconds";
            env.CompileDeploy(eplStatement, path);

            var aggStatement = "@Name('select') context MyContext " +
                               "select count(*) as theCount " +
                               "from PayloadEvent " +
                               "output snapshot when terminated";
            env.CompileDeploy(aggStatement, path);
            var listener = new MyListener();
            env.Statement("select").AddListener(listener);

            // start thread
            long numEvents = 10000000;
            var myRunnable = new MyRunnable(env.Runtime, numEvents);
            var thread = new Thread(myRunnable.Run);
            thread.Name = typeof(MultithreadContextStartedBySameEvent).Name;
            thread.Start();
            SupportCompileDeployUtil.ThreadJoin(thread);

            SupportCompileDeployUtil.ThreadSleep(1000);

            // assert
            Assert.IsNull(myRunnable.exception);
            Assert.AreEqual(numEvents, listener.total);

            env.UndeployAll();
        }
Beispiel #8
0
        public void Run(params string[] args)
        {
            PhoneSystem ps  = PhoneSystem.Root;
            MyListener  the = new MyListener(null);

            ps.Updated  += new NotificationEventHandler(the.ps_Updated);
            ps.Inserted += new NotificationEventHandler(the.ps_Inserted);
            ps.Deleted  += new NotificationEventHandler(the.ps_Deleted);
            bool audioopt = true;

            while (true)
            {
                audioopt = !audioopt;
                try
                {
                    foreach (Extension a in ps.GetTenants()[0].GetExtensions())
                    {
                        a.DeliverAudio = audioopt;
                        a.Save();
                    }
                }
                catch (Exception)
                {
                    System.Console.WriteLine("Exception in updatetest");
                }
                Thread.Sleep(10000);
            }
        }
Beispiel #9
0
        public void PreStartStatus()
        {
            MyListener listener = new MyListener();

            Assert.AreEqual(false, listener.IsActive, "#01");
            Assert.IsTrue(null != listener.GetSocket(), "#02");
            try {
                listener.AcceptSocket();
                Assert.Fail("Exception not thrown");
            } catch (InvalidOperationException) {
            }

            try {
                listener.AcceptTcpClient();
                Assert.Fail("Exception not thrown");
            } catch (InvalidOperationException) {
            }

            try {
                listener.Pending();
                Assert.Fail("Exception not thrown");
            } catch (InvalidOperationException) {
            }

            listener.Stop();
        }
Beispiel #10
0
        void TestVideoCapture_Load(object sender, EventArgs e)
        {
            workingFolderTextBox.Text = Settings.Default.WorkingFolder;

            listener = new MyListener(this.TraceMessageTextBox);
            Trace.Listeners.Add(listener);
        }
        private static void TryThreadSafetyHistoricalJoin(
            RegressionEnvironment env,
            int numThreads,
            int numRepeats)
        {
            var listener = new MyListener();
            env.Statement("select").AddListener(listener);

            var events = new IList<object>[numThreads];
            for (var threadNum = 0; threadNum < numThreads; threadNum++) {
                events[threadNum] = new List<object>();
                for (var eventNum = 0; eventNum < numRepeats; eventNum++) {
                    // range: 1 to 1000
                    var partition = eventNum + 1;
                    events[threadNum].Add(new SupportBean(new int?(partition).ToString(), 0));
                }
            }

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadContextDBAccess)).ThreadFactory);
            var futures = new IFuture<bool>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new SendEventCallable(i, env.Runtime, events[i].GetEnumerator());
                futures[i] = threadPool.Submit(callable);
            }

            SupportCompileDeployUtil.AssertFutures(futures);
            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);

            Assert.AreEqual(numRepeats * numThreads, listener.Count);
        }
Beispiel #12
0
        public override void Run(EPServiceProvider epService)
        {
            var eplStatement = "create context MyContext start PayloadEvent end after 0.5 seconds";

            epService.EPAdministrator.CreateEPL(eplStatement);

            var aggStatement = "@Name('select') context MyContext " +
                               "select count(*) as theCount " +
                               "from PayloadEvent " +
                               "output snapshot when terminated";
            var epAggStatement = epService.EPAdministrator.CreateEPL(aggStatement);
            var listener       = new MyListener();

            epAggStatement.Events += listener.Update;

            // start thread
            long numEvents  = 10000000;
            var  myRunnable = new MyRunnable(epService, numEvents);
            var  thread     = new Thread(myRunnable.Run);

            thread.Start();
            thread.Join();

            Thread.Sleep(1000);

            // assert
            Assert.IsNull(myRunnable.Exception);
            Assert.AreEqual(numEvents, listener.Total);
        }
Beispiel #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            root_view = FindViewById <View>(Resource.Id.root_view);

            persona_chip_example_basic   = FindViewById <PersonaChipView>(Resource.Id.persona_chip_example_basic);
            persona_chip_example_no_icon = FindViewById <PersonaChipView>(Resource.Id.persona_chip_example_no_icon);
            persona_chip_example_error   = FindViewById <PersonaChipView>(Resource.Id.persona_chip_example_error);

            persona_chip_layout = FindViewById <ViewGroup>(Resource.Id.persona_chip_layout);

            var listener = new MyListener
            {
                ClickHandler = () =>
                {
                    Snackbar.Make(root_view, GetString(Resource.String.persona_chip_example_click), Snackbar.LengthShort, Snackbar.Style.Regular).Show();
                }
            };

            CreateDisabledPersonaChip();
            persona_chip_example_basic.Listener   = listener;
            persona_chip_example_no_icon.Listener = listener;
            persona_chip_example_error.Listener   = listener;
            persona_chip_example_error.HasError   = true;
        }
Beispiel #14
0
        public virtual void teststopStart()
        {
            MyListener myListener = new MyListener();
            FileInfo   file       = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");
            FileInfo   stFile     = new FileInfo(theStorage + Path.DirectorySeparatorChar.ToString() + "f1.txt");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            Assert.IsFalse(stFile.Exists);
            hf = new QueueHotFolder(theHF, theStorage, null, myListener, null);
            hf.stop();
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            stFile.Refresh();
            Assert.IsFalse(stFile.Exists, "FileInfo is still there after stop");
            Assert.AreEqual(0, myListener.vJMF.Count);
            hf.restart();
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsFalse(file.Exists, "FileInfo is gone after stop");
            stFile.Refresh();
            Assert.IsTrue(stFile.Exists);
            Assert.AreEqual(1, myListener.vJMF.Count);
            JDFJMF elementAt = (JDFJMF)myListener.vJMF[0];

            Assert.AreEqual(JDFMessage.EnumType.SubmitQueueEntry, elementAt.getCommand(0).getEnumType());
            Assert.AreEqual(UrlUtil.fileToUrl(stFile, false), elementAt.getCommand(0).getQueueSubmissionParams(0).getURL());
        }
        public void TracingErrorInformation()
        {
            var factory = new TraceLoggerFactory();
            var logger  = factory.Create(typeof(TraceLoggerTests), LoggerLevel.Debug);

            try
            {
                try
                {
                    var fakearg = "Thisisavalue";
                    throw new ArgumentOutOfRangeException("fakearg", fakearg, "Thisisamessage");
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Inner error is " + ex.Message, ex);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Problem handled", ex);
            }

            MyListener.AssertContains("testsrule", "Castle.Core.Test.Main.TraceLoggerTests");
            MyListener.AssertContains("testsrule", "Problem handled");
            MyListener.AssertContains("testsrule", "ApplicationException");
            MyListener.AssertContains("testsrule", "Inner error is");
            MyListener.AssertContains("testsrule", "ArgumentOutOfRangeException");
            MyListener.AssertContains("testsrule", "fakearg");
            MyListener.AssertContains("testsrule", "Thisisavalue");
            MyListener.AssertContains("testsrule", "Thisisamessage");
        }
Beispiel #16
0
        private void Listen()
        {
            while (Running)
            {
                //Accept a new connection
                if (!MyListener.Pending())
                {
                    Thread.Sleep(500);
                    continue;
                }
                TcpClient client = MyListener.AcceptTcpClient();
                Trace.WriteLine(MESSAGE_SOCKET_TYPE + client.Client.SocketType);
                if (client.Connected == false)
                {
                    continue;
                }

                Trace.WriteLine(MESSAGE_CLIENT_CONNECTED + client.Client.RemoteEndPoint);
                try
                {
                    ServeClient(client.GetStream());
                }
                catch (IOException)
                {
                    Trace.WriteLine(MESSAGE_LOST_CONNECTION);
                }
                catch (ObjectDisposedException)
                {
                    Trace.WriteLine(MESSAGE_LOST_CONNECTION);
                }
                client.Close();
            }
            MyListener.Stop();
            Trace.WriteLine(MESSAGE_LISTENING_STOP);
        }
Beispiel #17
0
        public override void RunExample(string[] args)
        {
            base.RunExample(args);

            DomainParticipantFactory factory = DomainParticipantFactory.GetInstance(Bootstrap.CreateInstance());
            DomainParticipant        dp      = factory.CreateParticipant();

            // Implicitly create TypeSupport and register type:
            Topic <Greeting> tp = dp.CreateTopic <Greeting>("Greetings Topic");

            // Create the publisher
            Publisher pub = dp.CreatePublisher();

            /* DataWriter<Greeting> dw = pub.CreateDataWriter(tp);
             *
             */

            DataWriter <Greeting> dw = pub.CreateDataWriter <Greeting>(tp,
                                                                       pub.GetDefaultDataWriterQos(), null, null);
            // Create the subscriber
            Subscriber sub = dp.CreateSubscriber();
            DataReaderListener <Greeting> ls = new MyListener();
            /*DataReader<Greeting> dr = sub.CreateDataReader(tp);*/

            DataReader <Greeting> dr = sub.CreateDataReader <Greeting>(tp,
                                                                       sub.GetDefaultDataReaderQos(),
                                                                       ls,
                                                                       null);

            /*
             * // Now Publish some piece of data
             * Greeting data = new Greeting("Hello, World with DDS.");
             * Console.WriteLine("Sending data:\"{0}\"", data.Value);
             * dw.Write(data);
             * //and check that the reader has this data
             * dr.WaitForHistoricalData(10, TimeUnit.SECONDS);
             *
             */
            int i = 0;

            // Now Publish some piece of data
            //Greeting data = new Greeting("Hola Mundo"+ i.ToString());


            for (i = 0; i < 1; i++)
            {
                Greeting data = new Greeting("Hola Mundo" + i.ToString());

                Console.WriteLine("Sending data:\"{0}\"", data.Value);
                dw.Write(data);
                dr.WaitForHistoricalData(1500, TimeUnit.MILLISECONDS);
            }


            //and check that the reader has this data
            //dr.WaitForHistoricalData(10000, TimeUnit.SECONDS);

            dp.Close();
        }
 public OptionItemPresenter()
 {
     weakEventListener        = new MyListener(this);
     ChildItems               = new IOptionItem[0];
     this.Loaded             += OnLoaded;
     this.LocalizingConverter = new XamlLocalizingConverter();
     CommandManager.RegisterClassCommandBinding(typeof(OptionItemPresenter), new CommandBinding(ResetValueCommand, OnResetValueExecuted, OnCanExecuteResetValue));
 }
        public void UnexpectedExceptionThrown2()
        {
            var myListener = new MyListener();
            var tc         = new TestFixture(typeof(ThrowsUnExpectedException2));

            tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
            Assert.Equals(1, myListener.ErrorCount);
        }
        public void ExpectedExceptionIsNotThrown()
        {
            var myListener = new MyListener();
            var tc         = new TestFixture(typeof(ExpectedExceptionNotThrown));

            tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
            Assert.Equals(1, myListener.FailureCount);
        }
Beispiel #21
0
        private void TryPerformanceDispatch(int numThreads, int numRepeats)
        {
            var listener = new MyListener();

            _engine.EPAdministrator.GetStatement("select").Events += listener.Update;

            var random  = new Random();
            var eventId = 0;
            var events  = new IList <object> [numThreads];

            for (int threadNum = 0; threadNum < numThreads; threadNum++)
            {
                events[threadNum] = new List <Object>();
                for (int eventNum = 0; eventNum < numRepeats; eventNum++)
                {
                    // range: 1 to 1000
                    int partition = random.Next(0, 51);
                    eventId++;
                    events[threadNum].Add(new SupportBean(partition.ToString(CultureInfo.InvariantCulture), eventId));
                }
            }

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var futures    = new Future <object> [numThreads];

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < numThreads; i++)
                {
                    var callable = new SendEventCallable(i, _engine, events[i].GetEnumerator());
                    futures[i]   = threadPool.Submit(callable);
                }

                threadPool.Shutdown();
                threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

                foreach (var future in futures)
                {
                    Assert.AreEqual(true, future.GetValueOrDefault());
                }
            });

            // print those events not received
            foreach (var eventList in events)
            {
                foreach (var theEvent in eventList.Cast <SupportBean>())
                {
                    if (!listener.Beans.Contains(theEvent))
                    {
                        Log.Info("Expected event was not received, event " + theEvent);
                    }
                }
            }

            Assert.That(listener.Beans.Count, Is.EqualTo(numRepeats * numThreads));
            Assert.That(delta, Is.LessThan(500), "delta=" + delta);
        }
        void TestVideoCapture_Load(object sender, EventArgs e)
        {
            sourceFilenameTextBox.Text = "";

            listener = new MyListener(this.TraceMessageTextBox);
            Trace.Listeners.Add(listener);

            sourceFilenameTextBox_TextChanged(null, null);
        }
        public void ExpectedTargetInvocationExceptionThrown()
        {
            var myListener = new MyListener();
            var tc         = new TestFixture(typeof(ThrowsExpectedArgumentException));

            tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
            Assert.Equals(0, myListener.ErrorCount);
            Assert.Equals("ThrowsException", myListener.NameOfExecutedTest);
        }
        public void FallUpToShorterSourceName()
        {
            var factory = new TraceLoggerFactory();
            var logger  = factory.Create(typeof(Configuration.Xml.XmlConfigurationDeserializer), LoggerLevel.Debug);

            logger.Info("Logging to config namespace");

            MyListener.AssertContains("configrule", "Castle.Core.Configuration.Xml.XmlConfigurationDeserializer");
            MyListener.AssertContains("configrule", "Logging to config namespace");
        }
Beispiel #25
0
 public void IgnoredMethod() {
    MyListener myListener = new MyListener();
    TestFixture tc = new TestFixture(typeof(HasIgnoredMethod));
    TestSpec ts = new TestSpec();
    ts.AddTest("csUnit.Core.Tests", typeof(HasIgnoredMethod).FullName, string.Empty);
    tc.Execute(ts, myListener);
    Assert.Equals(1, myListener.SkipCount);
    // Skipped tests do not 'start'
    Assert.Equals(1, myListener.TestCount);
 }
        public void UnexpectedExceptionThrown1()
        {
            var myListener = new MyListener();
            var tc         = new TestFixture(typeof(ThrowsUnExpectedException1));

            tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
            Assert.Equals(1, myListener.ErrorCount);
            Assert.StartsWith("Unexpected System.ArithmeticException: Message of actual exception",
                              myListener.Reason);
        }
        public void FallUpToDefaultSource()
        {
            var factory = new TraceLoggerFactory();
            var logger  = factory.Create("System.Xml.XmlDocument", LoggerLevel.Debug);

            logger.Info("Logging to non-configured namespace namespace");
            Assert.IsNotNull(logger);

            MyListener.AssertContains("defaultrule", "System.Xml.XmlDocument");
            MyListener.AssertContains("defaultrule", "Logging to non-configured namespace namespace");
        }
Beispiel #28
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("@Name('s0') select * from SupportBean");
                var listener = new MyListener();
                env.Statement("s0").AddListener(listener);

                env.SendEventBean(new SupportBean());
                Assert.AreEqual(TEST_SECRET_VALUE, listener.SecretValue);

                env.UndeployAll();
            }
Beispiel #29
0
        public void IgnoredMethod()
        {
            MyListener  myListener = new MyListener();
            TestFixture tc         = new TestFixture(typeof(HasIgnoredMethod));
            TestSpec    ts         = new TestSpec();

            ts.AddTest("csUnit.Core.Tests", typeof(HasIgnoredMethod).FullName, string.Empty);
            tc.Execute(ts, myListener);
            Assert.Equals(1, myListener.SkipCount);
            // Skipped tests do not 'start'
            Assert.Equals(1, myListener.TestCount);
        }
        public void Run(params string[] args)
        {
            PhoneSystem ps = PhoneSystem.Root;

            using (var listener = new MyListener(new HashSet <string>(args.Skip(1))))
            {
                while (!Program.Stop)
                {
                    Thread.Sleep(5000);
                }
            }
        }
        public void WritingToLoggerByType()
        {
            var factory = new TraceLoggerFactory();
            var logger  = factory.Create(typeof(TraceLoggerTests), LoggerLevel.Debug);

            logger.Debug("this is a tracing message");
            Assert.IsTrue(logger is LevelFilteredLogger);
            Assert.AreEqual((logger as LevelFilteredLogger).Name, "Castle.Core.Test.Main.TraceLoggerTests");

            MyListener.AssertContains("testsrule", "Castle.Core.Test.Main.TraceLoggerTests");
            MyListener.AssertContains("testsrule", "this is a tracing message");
        }
Beispiel #32
0
        public void Rcv1Test()
        {
            using (var gz = new GZipStream(File.OpenRead(@"D:\Data\rcv1.train.vw.gz"), CompressionMode.Decompress))
            using (var reader = new StreamReader(gz))
            {
                MyListener listener;
                using (var vw = new VowpalWabbit<Data>("-k -f rcv1.model -c rcv1.cache"))
                {
                    listener = new MyListener(vw);
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        VWTestHelper.ParseInput(line, listener);
                    }
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            SetContentView(Resource.Layout.FragmentList);

            var footer = FindViewById<TextView> (Resource.Id.footer);
            adapter = new MyAdapter(SupportFragmentManager);

            pager = FindViewById<ViewPager>(Resource.Id.pager);
            pager.Adapter = adapter;
            var mpag = new MyListener (footer);
            pager.SetOnPageChangeListener (mpag);
            /*
            var button = FindViewById<Button>(Resource.Id.goto_first);
            button.Click += (sender, e) => {
                pager.CurrentItem = 0;
            };
            button = FindViewById<Button>(Resource.Id.goto_last);
            button.Click += (sender, e) => {
                pager.CurrentItem = NUM_ITEMS - 1;
            };
            */
        }
Beispiel #34
0
        private void sendAndReceive(byte[] messageBody, int count)
        {           
            IClientSession ssn = Client.CreateSession(0);
            ssn.Sync();
            ssn.QueueDeclare("queue1", null, null);
            ssn.QueueDelete("queue1");           
            QueueQueryResult result = (QueueQueryResult) ssn.QueueQuery("queue1").Result;            
            Assert.IsNull(result.GetQueue());
            ssn.QueueDeclare("queue1", null, null);
            ssn.ExchangeBind("queue1", "amq.direct", "queue1", null);
            Object myLock = new Object();
            MyListener myListener = new MyListener(myLock, count);
            ssn.AttachMessageListener(myListener, "myDest");

            ssn.MessageSubscribe("queue1", "myDest", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED, null,
                                 0, null);


            // issue credits     
            ssn.MessageSetFlowMode("myDest", MessageFlowMode.WINDOW);
            ssn.MessageFlow("myDest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            ssn.MessageFlow("myDest", MessageCreditUnit.MESSAGE, 10000);
            ssn.Sync();

            for (int i = 0; i < count; i++)
            {
                ssn.MessageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED,
                                    new Header(new DeliveryProperties().SetRoutingKey("queue1"),
                                               new MessageProperties().SetMessageId(UUID.RandomUuid())),
                                    messageBody);
            }
            ssn.Sync();
           
            lock (myLock)
            {
                if (myListener.Count != 0)
                {
                    Monitor.Wait(myLock, 10000000);
                }
            }
            Assert.IsTrue(myListener.Count == 0);
            ssn.MessageAccept(myListener.UnAck);
            ssn.Sync();
            // the queue should be empty 
            result = (QueueQueryResult)ssn.QueueQuery("queue1").Result;
            Assert.IsTrue(result.GetMessageCount() == 0);
            ssn.Close();        
        }
Beispiel #35
0
		public void PostStartStatus ()
		{
			MyListener listener = new MyListener ();
			listener.Start ();
			Assert.AreEqual (true, listener.IsActive, "#01");
			Assert.IsTrue (null != listener.GetSocket (), "#02");
			
			Socket sock = listener.GetSocket ();
			listener.Start (); // Start called twice
			Assert.AreEqual (true, listener.IsActive, "#03");
			Assert.IsTrue (null != listener.GetSocket (), "#04");

			Assert.AreEqual (false, listener.Pending (), "#05");

			listener.Stop ();
			Assert.AreEqual (false, listener.IsActive, "#06");
			Assert.IsTrue (null != listener.GetSocket (), "#07");
			Assert.IsTrue (sock != listener.GetSocket (), "#08");
		}
Beispiel #36
0
		public void PreStartStatus ()
		{
			MyListener listener = new MyListener ();
			Assert.AreEqual (false, listener.IsActive, "#01");
			Assert.IsTrue (null != listener.GetSocket (), "#02");
			try {
				listener.AcceptSocket ();
				Assert.Fail ("Exception not thrown");
			} catch (InvalidOperationException) {
			}

			try {
				listener.AcceptTcpClient ();
				Assert.Fail ("Exception not thrown");
			} catch (InvalidOperationException) {
			}

			try {
				listener.Pending ();
				Assert.Fail ("Exception not thrown");
			} catch (InvalidOperationException) {
			}

			listener.Stop ();
		}
 public void UnexpectedExceptionThrown1() {
    var myListener = new MyListener();
    var tc = new TestFixture(typeof(ThrowsUnExpectedException1));
    tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
    Assert.Equals(1, myListener.ErrorCount);
    Assert.StartsWith("Unexpected System.ArithmeticException: Message of actual exception",
       myListener.Reason);
 }
Beispiel #38
0
 public void ResetVariables() {
    _listener = new MyListener();
    _sequence = string.Empty;
 }
 public void UnexpectedExceptionThrown2() {
    var myListener = new MyListener();
    var tc = new TestFixture(typeof(ThrowsUnExpectedException2));
    tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
    Assert.Equals(1, myListener.ErrorCount);
 }
 public void ExpectedExceptionIsNotThrown() {
    var myListener = new MyListener();
    var tc = new TestFixture(typeof(ExpectedExceptionNotThrown));
    tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
    Assert.Equals(1, myListener.FailureCount);
 }
      public void ExpectedExceptionThrown() {
         var myListener = new MyListener();
         var tc = new TestFixture(typeof(ThrowsExpectedException));

         tc.Execute(new TestRun(new AllTestsCriterion()), myListener);
         
         Assert.Equals(0, myListener.ErrorCount);
         Assert.Equals("ThrowsException", myListener.NameOfExecutedTest);
      }
Beispiel #42
0
        private void StartUpload(FileStatus a)
        {
            a.UploadStartTime = DateTime.Now;
            Aspera.Transfer.Environment.setFaspScpPath("C:\\AsperaTest\\Aspera\\ascp.exe");
            /*
             * Set the local management port to be used by Fasp manager.
             * If not set, Fasp Manager will pick a random port and use it.
             * It is best to not set this port.
             */
            Aspera.Transfer.Environment.setManagementPort(54002);
            FaspManager manager = FaspManager.getInstance();
            MyListener myListener = new MyListener();

            /* Uncomment the following two lines to receive
             * notifications about transfers not initiated by fasp manager
             */
            manager.listenForServerSessions(true);
            manager.addListener(myListener);
            LocalFileLocation uploadSource = new LocalFileLocation();
            uploadSource.addPath(a.FilePath);
            RemoteFileLocation uploadDestination = new RemoteFileLocation("hack2.aspera.us", "xfer", "aspera");
            uploadDestination.addPath(".");
            XferParams uploadXferParams = getDefaultXferParams();
            JobOrder uploadOrder = new JobOrder(uploadSource, uploadDestination, uploadXferParams);
            String uploadJobId = manager.startTransfer(uploadOrder, myListener);
            a.IsUploaded = true;
        }
		public void PostStartStatus ()
		{
			MyListener listener = new MyListener ();
			listener.Start ();
			AssertEquals ("#01", true, listener.IsActive);
			Assert ("#02", null != listener.GetSocket ());
			
			Socket sock = listener.GetSocket ();
			listener.Start (); // Start called twice
			AssertEquals ("#03", true, listener.IsActive);
			Assert ("#04", null != listener.GetSocket ());

			AssertEquals ("#05", false, listener.Pending ());

			listener.Stop ();
			AssertEquals ("#06", false, listener.IsActive);
			Assert ("#07", null != listener.GetSocket ());
			Assert ("#08", sock != listener.GetSocket ());
		}