示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBlockIfTheWrappedStartIsUnsuccessful() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBlockIfTheWrappedStartIsUnsuccessful()
        {
            AtomicInteger status = new AtomicInteger();
            AtomicBoolean exited = new AtomicBoolean(false);

            BlockingBootstrapper bootstrapper = new BlockingBootstrapper(new BootstrapperAnonymousInnerClass2(this));

            (new Thread(() =>
            {
                status.set(bootstrapper.Start(HomeDir.directory("home-dir"), null, java.util.Collections.emptyMap()));
                exited.set(true);
            })).Start();

            assertEventually("Blocked unexpectedly", exited.get, @is(true), 10, TimeUnit.SECONDS);
            assertThat("Bootstrapper did not propagate exit status", status.get(), @is(1));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBlockUntilStoppedIfTheWrappedStartIsSuccessful() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBlockUntilStoppedIfTheWrappedStartIsSuccessful()
        {
            AtomicInteger status  = new AtomicInteger();
            AtomicBoolean exited  = new AtomicBoolean(false);
            AtomicBoolean running = new AtomicBoolean(false);

            BlockingBootstrapper bootstrapper = new BlockingBootstrapper(new BootstrapperAnonymousInnerClass(this, running));

            (new Thread(() =>
            {
                status.set(bootstrapper.Start(HomeDir.directory("home-dir"), null, java.util.Collections.emptyMap()));
                exited.set(true);
            })).Start();

            assertEventually("Wrapped was not started", running.get, @is(true), 10, TimeUnit.SECONDS);
            assertThat("Bootstrapper exited early", exited.get(), @is(false));

            bootstrapper.Stop();

            assertEventually("Wrapped was not stopped", running.get, @is(false), 10, TimeUnit.SECONDS);
            assertEventually("Bootstrapper did not exit", exited.get, @is(true), 10, TimeUnit.SECONDS);
            assertThat("Bootstrapper did not propagate exit status", status.get(), @is(0));
        }