Add some more sca clinet api tests

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@943891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
antelder 2010-05-13 14:06:05 +00:00
commit 576a612ac8

View file

@ -29,6 +29,8 @@ import junit.framework.TestCase;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.client.SCAClientFactory;
/**
@ -69,7 +71,48 @@ public class SCAClientTestCase extends TestCase {
assertEquals("Hello petra", service.sayHello("petra"));
}
// @Test @Ignore
// @Test
// public void testWithoutServiceName() throws Exception {
// node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
// node.start();
//
// SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain"));
// HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent");
// assertEquals("Hello petra", service.sayHello("petra"));
// }
@Test
public void testWithBadServiceName() throws Exception {
node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
node.start();
SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain"));
try {
clientFactory.getService(HelloworldService.class, "HelloworldComponent/foo");
fail();
} catch (NoSuchServiceException e) {
// expected
}
}
@Test
public void testWithBadDomainName() throws Exception {
node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
node.start();
SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("someBadDomainName"));
try {
HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent/foo");
service.sayHello("petra");
fail();
} catch (Exception e) {
if (!(e.getCause() instanceof NoSuchDomainException)) {
throw e;
}
}
}
// @Test @Ignore
// public void testHTTPURI() throws Exception {
// node = NodeFactory.getInstance().createNode(URI.create("http://defaultDomain"), new String[] {"target/classes"});
// node.start();