ensure templatebuilder tests pass when image-id and login-user properties are set

This commit is contained in:
Adrian Cole 2011-11-15 18:28:38 +02:00
parent 1bf930db66
commit 90dfed8583
2 changed files with 18 additions and 8 deletions

View File

@ -50,7 +50,9 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.inject.Guice;
import com.google.inject.Module;
@ -255,17 +257,20 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi
@Test
public void testTemplateBuilderWithLoginUserSpecified() throws IOException {
ComputeServiceContext context = null;
try {
Properties overrides = setupProperties();
overrides.setProperty("jclouds.login-user", "foo:bar");
String login = loginUser != null ? loginUser : "foo:bar";
overrides.setProperty("jclouds.login-user", login);
context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);
Iterable<String> userPass = Splitter.on(':').split(login);
String user = Iterables.get(userPass, 0);
String pass = Iterables.get(userPass, 1);
assertEquals(context.getComputeService().templateBuilder().build().getImage().getDefaultCredentials(),
new Credentials("foo", "bar"));
new Credentials(user, pass));
} finally {
if (context != null)
context.close();

View File

@ -71,11 +71,16 @@ public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderL
@Test
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = this.context.getComputeService().templateBuilder().build();
if (imageId == null) {
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getLocation().getId(), "1");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
} else {
assertEquals(defaultTemplate.getImage(), this.context.getComputeService().templateBuilder().imageId(imageId)
.build().getImage());
}
}
@Override