TestUtils.checkProblems(customBuilder);
checkScenario2and3Results("http://scenario2", true);
}
private void checkScenario2and3Results(String namespace, boolean nonWiring) {
Composite domainComposite = customBuilder.getDomainComposite();
// Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
// No other services on ComponentB should have <binding.ws>
Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
WebServiceBinding wsBinding = null;
for (ComponentService service : componentB.getServices()) {
WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
if ("Service2".equals(service.getName())) {
wsBinding = wsb;
} else {
assert wsb == null;
}
}
Definition def = wsBinding.getWSDLDocument();
javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
Port port = svc.getPort("Service3Port");
assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
if (!nonWiring) {
// Should create component service $promoted$.ComponentB.Service2 on innermost component
// ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
wsBinding = null;
for (ComponentService service : componentD.getServices()) {
if ("$promoted$.ComponentB.Service2".equals(service.getName())) {
wsBinding = service.getBinding(WebServiceBinding.class);
}
}
assert "/ComponentB/Service2".equals(wsBinding.getURI());
// Should create WSDL document for ComponentD/$promoted$.ComponentB.Service2 with endpoint uri="/ComponentB/Service2"
def = wsBinding.getWSDLDocument();
svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
port = svc.getPort("Service3Port");
assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
} else {
// Should not create component service $promoted$.ComponentB.Service2 on innermost component ComponentD
for (ComponentService service : componentD.getServices()) {
assert !"$promoted$.ComponentB.Service2".equals(service.getName());
}
}
// Should add <binding.ws> to outer composite service CompositeA/Service1
wsBinding = null;
for (Service service : domainComposite.getServices()) {
if ("Service1".equals(service.getName())) {
wsBinding = service.getBinding(WebServiceBinding.class);
}
}
assert wsBinding != null;
if (nonWiring) {
// Should not add a WSDL document to domain composite service Service1
assert wsBinding.getWSDLDocument() == null;
}
if (!nonWiring) {
// Should create component service $promoted$.Service1 on innermost component
// ComponentD, with <binding.ws> and uri="/Service1"
wsBinding = null;
for (ComponentService service : componentD.getServices()) {
if ("$promoted$.Service1".equals(service.getName())) {
wsBinding = service.getBinding(WebServiceBinding.class);
}
}
assert "/Service1".equals(wsBinding.getURI());
// Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
def = wsBinding.getWSDLDocument();
svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
port = svc.getPort("Service3Port");
assert "/Service1".equals(TestUtils.getPortAddress(port));
} else {
// Should not create component service $promoted$.Service1 on innermost component ComponentD
for (ComponentService service : componentD.getServices()) {
assert !"$promoted$.Service1".equals(service.getName());
}
}
// No services on ComponentD should have <binding.ws>, except for $promoted$.Service1
// and $promoted$.ComponentB.Service2
for (ComponentService service : componentD.getServices()) {
if (!"$promoted$.Service1".equals(service.getName()) &&
!"$promoted$.ComponentB.Service2".equals(service.getName())) {
assert service.getBinding(WebServiceBinding.class) == null;
}
}
// No services on CompositeC should have <binding.ws>, except for Service2 in Scenario 3
Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
for (Service service : compositeC.getServices()) {
if ("http://scenario3".equals(namespace) && "Service2".equals(service.getName())) {
assert service.getBinding(WebServiceBinding.class) != null;
} else {
assert service.getBinding(WebServiceBinding.class) == null;
}