@Test public void testBackgroundExecutorSetsEnvironmentCorrectly() throws InterruptedException { InterProcessCommunication outgoing = new MessageQueue(); ConcurrentMap<AccessToken, RemoteMethodResponse> responses = Maps .newConcurrentMap(); String environment1 = Random.getSimpleString(); String environment2 = Random.getSimpleString(); MockConcourseRuntime runtime = new MockConcourseRuntime(); BackgroundExecutor executor = PluginExecutors .newCachedBackgroundExecutor(outgoing, responses); CountDownLatch latch = new CountDownLatch(2); final AtomicBoolean passed = new AtomicBoolean(true); executor.execute(environment1, () -> { try { Assert.assertEquals(environment1, runtime.environment()); latch.countDown(); } catch (AssertionError e) { passed.set(false); e.printStackTrace(); } }); executor.execute(environment2, () -> { try { Assert.assertEquals(environment2, runtime.environment()); latch.countDown(); } catch (AssertionError e) { passed.set(false); e.printStackTrace(); } }); latch.await(); Assert.assertTrue(passed.get()); }
@Override public String environment() { return environment; }
BackgroundThread extends Thread implements
        ConcourseRuntimeAuthorized { @Override public String environment() { return environment; } }
BackgroundThread extends Thread implements
        ConcourseRuntimeAuthorized { @Override public String environment() { return environment; } BackgroundThread(Runnable runnable, String environment,
            InterProcessCommunication outgoing,
            ConcurrentMap<AccessToken, RemoteMethodResponse> responses); }
BackgroundThread extends Thread implements
        ConcourseRuntimeAuthorized { @Override public String environment() { return environment; } BackgroundThread(Runnable runnable, String environment,
            InterProcessCommunication outgoing,
            ConcurrentMap<AccessToken, RemoteMethodResponse> responses); @Override AccessToken accessToken(); @Override String environment(); void environment(String environment); @Override InterProcessCommunication outgoing(); @Override ConcurrentMap<AccessToken, RemoteMethodResponse> responses(); @Override final TransactionToken transactionToken(); }
BackgroundThread extends Thread implements
        ConcourseRuntimeAuthorized { @Override public String environment() { return environment; } BackgroundThread(Runnable runnable, String environment,
            InterProcessCommunication outgoing,
            ConcurrentMap<AccessToken, RemoteMethodResponse> responses); @Override AccessToken accessToken(); @Override String environment(); void environment(String environment); @Override InterProcessCommunication outgoing(); @Override ConcurrentMap<AccessToken, RemoteMethodResponse> responses(); @Override final TransactionToken transactionToken();  }