projectB.getBuildersList().add(builder);
projectB.setQuietPeriod(1);
hudson.rebuildDependencyGraph();
String log = getLog((Run)projectA.scheduleBuild2(0, new UserCause(),
new ParametersAction(new StringParameterValue("KEY3", "value3"))).get());
Queue.Item q = hudson.getQueue().getItem(projectB);
assertNotNull("projectB should be triggered: " + log, q);
q.getFuture().get();
assertNotNull("builder should record environment", builder.getEnvVars());
assertEquals("value1", builder.getEnvVars().get("KEY1"));
assertEquals("value2", builder.getEnvVars().get("KEY2"));
assertEquals("value3", builder.getEnvVars().get("KEY3"));
projectA.scheduleBuild2(0, new UserCause(), new ParametersAction(new StringParameterValue("key1", "value3"))).get();
hudson.getQueue().getItem(projectB).getFuture().get();
assertEquals("value3", builder.getEnvVars().get("KEY1"));
assertEquals("value2", builder.getEnvVars().get("KEY2"));
}