Skip to content

Commit

Permalink
[AS7-1179] add test case for JDCB driver read-resource-description op…
Browse files Browse the repository at this point in the history
…eration
  • Loading branch information
Jeff Zhang authored and kabir committed Jul 6, 2011
1 parent 3486023 commit 618bd25
Showing 1 changed file with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;

Expand All @@ -44,7 +44,6 @@
import org.jboss.as.protocol.old.StreamUtils;
import org.jboss.as.test.modular.utils.ShrinkWrapUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.shrinkwrap.api.Archive;
import org.junit.After;
import org.junit.Test;
Expand Down Expand Up @@ -93,7 +92,7 @@ public void testReadChildrenResources() throws IOException {
final ModelNode result = getModelControllerClient().execute(operation);
Assert.assertTrue(result.hasDefined(RESULT));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
final Map<String, ModelNode> children = getChildren(result.get(RESULT));
final Map<String, ModelNode> children = DataSourceOperationTestUtil.getChildren(result.get(RESULT));
Assert.assertFalse(children.isEmpty());
for (final Entry<String, ModelNode> child : children.entrySet()) {
Assert.assertTrue(child.getKey() != null);
Expand All @@ -103,13 +102,32 @@ public void testReadChildrenResources() throws IOException {
}
}

protected static Map<String, ModelNode> getChildren(final ModelNode result) {
Assert.assertTrue(result.isDefined());
final Map<String, ModelNode> steps = new HashMap<String, ModelNode>();
for (final Property property : result.asPropertyList()) {
steps.put(property.getName(), property.getValue());
@Test
public void testReadResourceResources() throws IOException {

final ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.protect();

final ModelNode operation = new ModelNode();
operation.get(OP).set("read-resource-description");

operation.get(OP_ADDR).set(address);

final ModelNode result = getModelControllerClient().execute(operation);
Assert.assertTrue(result.hasDefined(RESULT));
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
final Map<String, ModelNode> children = DataSourceOperationTestUtil.getChildren(
result.get(RESULT).get("attributes").get("installed-drivers").get("value-type"));
Assert.assertFalse(children.isEmpty());

HashSet<String> keys = new HashSet<String>();
for (final Entry<String, ModelNode> child : children.entrySet()) {
Assert.assertTrue(child.getKey() != null);
keys.add(child.getKey());
}
return steps;
Assert.assertTrue(keys.contains("driver-xa-datasource-class-name"));
Assert.assertTrue(keys.contains("module-slot"));
Assert.assertTrue(keys.contains("driver-name"));
}

}

0 comments on commit 618bd25

Please sign in to comment.