removed deprecated usage

This commit is contained in:
Adrian Cole 2011-03-05 21:08:55 -05:00
parent a988b47627
commit 2c5e97627d
2 changed files with 35 additions and 39 deletions

View File

@ -35,8 +35,8 @@ import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplet
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith;
import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
import static org.jclouds.compute.predicates.NodePredicates.all;
import static org.jclouds.compute.predicates.NodePredicates.runningWithTag;
import static org.jclouds.compute.predicates.NodePredicates.withTag;
import static org.jclouds.compute.predicates.NodePredicates.runningInGroup;
import static org.jclouds.compute.predicates.NodePredicates.inGroup;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@ -207,7 +207,7 @@ public abstract class BaseComputeServiceLiveTest {
@Test(enabled = true, expectedExceptions = NoSuchElementException.class)
public void testCorrectExceptionRunningNodesNotFound() throws Exception {
client.runScriptOnNodesMatching(runningWithTag("zebras-are-awesome"), buildScript(new OperatingSystemBuilder()
client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), buildScript(new OperatingSystemBuilder()
.family(OsFamily.UBUNTU).description("ffoo").build()));
}
@ -215,23 +215,23 @@ public abstract class BaseComputeServiceLiveTest {
// starting this one alphabetically before create2nodes..
@Test(enabled = true, dependsOnMethods = { "testCompareSizes" })
public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
String tag = this.group + "r";
String group = this.group + "r";
try {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
} catch (Exception e) {
}
TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
try {
Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
Credentials good = nodes.iterator().next().getCredentials();
assert good.identity != null : nodes;
assert good.credential != null : nodes;
OperatingSystem os = get(nodes, 0).getOperatingSystem();
try {
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, os, new Credentials(
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(group, os, new Credentials(
good.identity, "romeo"));
assert false : "shouldn't pass with a bad password\n" + responses;
} catch (RunScriptOnNodesException e) {
@ -239,17 +239,17 @@ public abstract class BaseComputeServiceLiveTest {
}
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
runningWithTag(tag), Statements.exec("echo hello"),
runningInGroup(group), Statements.exec("echo hello"),
overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet())
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": "
+ response.getValue();
runScriptWithCreds(tag, os, good);
runScriptWithCreds(group, os, good);
checkNodes(nodes, tag);
checkNodes(nodes, group);
} finally {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
}
}
@ -267,13 +267,13 @@ public abstract class BaseComputeServiceLiveTest {
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
public void testCreateTwoNodesWithRunScript() throws Exception {
try {
client.destroyNodesMatching(withTag(group));
client.destroyNodesMatching(inGroup(group));
} catch (NoSuchElementException e) {
}
refreshTemplate();
try {
nodes = newTreeSet(client.runNodesWithTag(group, 2, template));
nodes = newTreeSet(client.createNodesInGroup(group, 2, template));
} catch (RunNodesException e) {
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
throw e;
@ -324,7 +324,7 @@ public abstract class BaseComputeServiceLiveTest {
public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception {
initializeContextAndClient();
refreshTemplate();
TreeSet<NodeMetadata> nodes = newTreeSet(client.runNodesWithTag(group, 1, template));
TreeSet<NodeMetadata> nodes = newTreeSet(client.createNodesInGroup(group, 1, template));
checkNodes(nodes, group);
NodeMetadata node = nodes.first();
this.nodes.add(node);
@ -340,21 +340,21 @@ public abstract class BaseComputeServiceLiveTest {
assert (context.getCredentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId();
}
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
Credentials creds) throws RunScriptOnNodesException {
try {
return client.runScriptOnNodesMatching(runningWithTag(tag), buildScript(os), overrideCredentialsWith(creds)
return client.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), overrideCredentialsWith(creds)
.nameTask("runScriptWithCreds"));
} catch (SshException e) {
throw e;
}
}
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String tag) throws IOException {
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group) throws IOException {
for (NodeMetadata node : nodes) {
assertNotNull(node.getProviderId());
assertNotNull(node.getTag());
assertEquals(node.getTag(), tag);
assertNotNull(node.getGroup());
assertEquals(node.getGroup(), group);
assertEquals(node.getState(), NodeState.RUNNING);
Credentials fromStore = context.getCredentialStore().get("node#" + node.getId());
assertEquals(fromStore, node.getCredentials());
@ -375,7 +375,7 @@ public abstract class BaseComputeServiceLiveTest {
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
public void testGet() throws Exception {
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client
.listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))),
.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))),
new Function<NodeMetadata, String>() {
@Override
@ -388,7 +388,7 @@ public abstract class BaseComputeServiceLiveTest {
metadataMap.remove(node.getId());
NodeMetadata metadata = client.getNodeMetadata(node.getId());
assertEquals(metadata.getProviderId(), node.getProviderId());
assertEquals(metadata.getTag(), node.getTag());
assertEquals(metadata.getGroup(), node.getGroup());
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
checkImageIdMatchesTemplate(metadata);
checkOsMatchesTemplate(metadata);
@ -407,14 +407,14 @@ public abstract class BaseComputeServiceLiveTest {
@Test(enabled = true, dependsOnMethods = "testGet")
public void testReboot() throws Exception {
client.rebootNodesMatching(withTag(group));// TODO test
client.rebootNodesMatching(inGroup(group));// TODO test
// validation
testGet();
}
@Test(enabled = true, dependsOnMethods = "testReboot")
public void testSuspendResume() throws Exception {
client.suspendNodesMatching(withTag(group));
client.suspendNodesMatching(inGroup(group));
Set<? extends NodeMetadata> stoppedNodes = refreshNodes();
@ -430,7 +430,7 @@ public abstract class BaseComputeServiceLiveTest {
}) : stoppedNodes;
client.resumeNodesMatching(withTag(group));
client.resumeNodesMatching(inGroup(group));
testGet();
}
@ -467,24 +467,24 @@ public abstract class BaseComputeServiceLiveTest {
@Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
public void testDestroyNodes() {
int toDestroy = refreshNodes().size();
Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(withTag(group));
Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group));
assertEquals(toDestroy, destroyed.size());
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), withTag(group))) {
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
assert node.getState() == NodeState.TERMINATED : node;
assertEquals(context.getCredentialStore().get("node#" + node.getId()), null);
}
}
private Set<? extends NodeMetadata> refreshNodes() {
return filter(client.listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED)));
return filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED)));
}
@Test(enabled = true)
public void testCreateAndRunAService() throws Exception {
String tag = this.group + "s";
String group = this.group + "s";
try {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
} catch (Exception e) {
}
@ -497,11 +497,11 @@ public abstract class BaseComputeServiceLiveTest {
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
.getOperatingSystem()));
try {
NodeMetadata node = getOnlyElement(client.runNodesWithTag(tag, 1, template));
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template));
checkHttpGet(node);
} finally {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
}
}
@ -554,9 +554,9 @@ public abstract class BaseComputeServiceLiveTest {
}
public void testOptionToNotBlock() throws Exception {
String tag = this.group + "block";
String group = this.group + "block";
try {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
} catch (Exception e) {
}
@ -564,13 +564,13 @@ public abstract class BaseComputeServiceLiveTest {
TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts();
try {
long time = System.currentTimeMillis();
Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
NodeMetadata node = getOnlyElement(nodes);
assert node.getState() != NodeState.RUNNING;
long duration = System.currentTimeMillis() - time;
assert duration < 30 * 1000 : "duration longer than 30 seconds!: " + duration / 1000;
} finally {
client.destroyNodesMatching(withTag(tag));
client.destroyNodesMatching(inGroup(group));
}
}

View File

@ -67,7 +67,6 @@ public class Utils {
* @see Lists2#multiMax
*/
@Deprecated
@SuppressWarnings("unchecked")
public static <T, E extends T> List<E> multiMax(Comparator<T> ordering, Iterable<E> iterable) {
return Lists2.<T, E> multiMax(ordering, iterable);
}
@ -86,7 +85,6 @@ public class Utils {
* @see Throwables2#getFirstThrowableOfType(Throwable, Class)
*/
@Deprecated
@SuppressWarnings("unchecked")
public static <T extends Throwable> T getFirstThrowableOfType(Throwable from, Class<T> clazz) {
return Throwables2.<T> getFirstThrowableOfType(from, clazz);
}
@ -253,7 +251,6 @@ public class Utils {
* @see Providers#resolveContextBuilderClass
*/
@Deprecated
@SuppressWarnings("unchecked")
public static <S, A> Class<RestContextBuilder<S, A>> resolveContextBuilderClass(String provider,
Properties properties) throws ClassNotFoundException, IllegalArgumentException, SecurityException,
InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
@ -277,7 +274,6 @@ public class Utils {
* @see Providers#resolvePropertiesBuilderClass
*/
@Deprecated
@SuppressWarnings("unchecked")
public static Class<PropertiesBuilder> resolvePropertiesBuilderClass(String providerName, Properties props)
throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException,
NoSuchMethodException {