TUSCANY-3907 - Fix up and appropriate what was the recursive-ws to become an implementation-composite test. Initially I needed a test to look into the problem described by TUSCANY-3907 and found that recursive-ws want actually in the build and hadn't been ported properly to 2.x. It seems more widely useful that just ws testing hence the name change.

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1154191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
slaws 2011-08-05 12:49:16 +00:00
commit 2cbfd9f776
21 changed files with 885 additions and 0 deletions

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-itest</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-implementation-composite</artifactId>
<name>Apache Tuscany SCA iTest implementation-composite</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-base-runtime-pom</artifactId>
<type>pom</type>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.19</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package policy;
import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface Target {
String hello(String arg);
}

View file

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package policy;
import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Service;
@Service(Target.class)
public class TargetClientImpl implements Target {
@Reference
protected Target targetService;
public String hello(String arg) {
return "Target: Hello " + targetService.hello(arg) + "!";
}
}

View file

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package policy;
import org.oasisopen.sca.annotation.Service;
@Service(Target.class)
public class TargetServiceImpl implements Target {
public String hello(String arg) {
return "Target: Hello " + arg + "!";
}
}

View file

@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface Composer {
public String Compose(String s);
}

View file

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import java.io.File;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.Contribution;
/**
* For testing purpose
*/
public class ComposerClient {
public final static void main(String[] args) throws Exception {
NodeFactory factory = NodeFactory.newInstance();
Node node = factory.createNode(new File("src/main/resources/Client.composite").toURI().toURL().toString(),
new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
node.start();
Composer composer = node.getService(Composer.class, "ClientComponent/Composer");
System.out.println(composer.Compose("ABC"));
node.stop();
}
}

View file

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import org.oasisopen.sca.annotation.Reference;
/**
* @version $Rev: 905603 $ $Date: 2010-02-02 12:18:47 +0000 (Tue, 02 Feb 2010) $
*/
public class ComposerClientImpl implements Composer {
@Reference
protected Composer composerWS;
/**
* @see recursive.Composer#Compose(java.lang.String)
*/
public String Compose(String s) {
return composerWS.Compose(s);
}
}

View file

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
/**
* Composer Component Implementation
*
*/
public class ComposerImpl implements Composer {
public String Compose(String s) {
System.out.println("Composing " + s + "...");
return "Composed: " + s;
}
}

View file

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import java.io.File;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.Contribution;
/**
* For testing purpose
*/
public class ComposerServer {
public final static void main(String[] args) throws Exception {
NodeFactory factory = NodeFactory.newInstance();
Node node = factory.createNode(new File("src/main/resources/Outer.composite").toURI().toURL().toString(),
new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
node.start();
System.out.println("Press Enter to exit...");
System.in.read();
node.stop();
}
}

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://bindingoverride"
xmlns:bindingoverride="http://bindingoverride"
name="BindingOverrideInnerComposite">
<service name="InnerService" promote="InnerServiceComponent">
<interface.java interface="policy.Target"/>
</service>
<component name="InnerServiceComponent">
<implementation.java class="policy.TargetServiceImpl"/>
<service name="Target">
<interface.java interface="policy.Target"/>
</service>
</component>
</composite>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://bindingoverride"
xmlns:bindingoverride="http://bindingoverride"
name="BindingOverrideOuterComposite">
<component name="OuterClientComponent">
<implementation.java class="policy.TargetClientImpl"/>
<reference name="targetService" target="OuterServiceComponent"/>
</component>
<component name="OuterServiceComponent">
<implementation.composite name="bindingoverride:BindingOverrideInnerComposite"/>
<service name="InnerService">
<interface.java interface="policy.Target"/>
<binding.ws uri="http://localhost:8085/OuterTargetServiceComponent"/>
</service>
</component>
</composite>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://policy"
xmlns:policy="http://policy"
name="PolicyInnerComposite">
<service name="TargetService" promote="TargetServiceComponent">
<interface.java interface="policy.Target"/>
</service>
<component name="TargetServiceComponent">
<implementation.java class="policy.TargetServiceImpl"/>
<service name="Target">
<interface.java interface="policy.Target"/>
<binding.ws uri="http://localhost:8085/TargetServiceComponent"/>
</service>
</component>
</composite>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://policy"
xmlns:policy="http://policy"
name="PolicyOuterComposite"
requires="policy:TestIntent_1">
<component name="TargetClientComponent">
<implementation.java class="policy.TargetClientImpl"/>
<reference name="targetService" target="OuterTargetServiceComponent"/>
</component>
<component name="OuterTargetServiceComponent">
<implementation.composite name="policy:PolicyInnerComposite"/>
<service name="TargetService">
<interface.java interface="policy.Target"/>
<binding.ws uri="http://localhost:8085/OuterTargetServiceComponent"/>
</service>
</component>
</composite>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="ASCII"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://policy"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:ip="http://policy" >
<!-- Policy Intents -->
<sca:intent name="TestIntent_1" constrains="sca:binding.ws">
<description>Test Intent One</description>
</sca:intent>
<!-- Policy Sets -->
<sca:policySet name="TestPolicySet_1_binding"
provides="ip:TestIntent_1"
appliesTo="sca:binding.ws"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:Policy />
</sca:policySet>
</definitions>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://client" name="Client">
<component name="ClientComponent">
<implementation.java class="recursive.ComposerClientImpl" />
<reference name="composerWS">
<binding.ws uri="http://localhost:8085/OuterService"/>
</reference>
</component>
</composite>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://inner" name="Inner">
<component name="InnerComponent">
<implementation.java class="recursive.ComposerImpl" />
</component>
<service name="OuterService" promote="InnerComponent"/>
</composite>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://outer" xmlns:inner="http://inner"
name="Outer">
<component name="OuterComponent">
<implementation.composite name="inner:Inner" />
<service name="OuterService">
<interface.java interface="recursive.Composer" />
<binding.ws uri="http://localhost:8085/OuterService" />
</service>
</component>
</composite>

View file

@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package bindingoverride;
import java.io.File;
import junit.framework.Assert;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.Contribution;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import policy.Target;
public class BindingOverrideTestCase{
private Node node;
private Target targetClient;
@Before
public void setUp() throws Exception {
try {
NodeFactory factory = NodeFactory.newInstance();
node = factory.createNode(new File("src/main/resources/bindingoverride/OuterComposite.composite").toURI().toURL().toString(),
new Contribution("TestContribution", new File("src/main/resources/bindingoverride/").toURI().toURL().toString()));
node.start();
targetClient = node.getService(Target.class, "OuterClientComponent");
} catch(Exception ex) {
System.out.println(ex.toString());
}
}
@After
public void tearDown() throws Exception {
node.stop();
}
@Test
public void test() throws Exception {
Assert.assertEquals("Target: Hello Target: Hello Fred!!", targetClient.hello("Fred"));
}
}

View file

@ -0,0 +1,82 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package policy;
import java.io.File;
import junit.framework.Assert;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.impl.CompositeImpl;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.policy.PolicySet;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@Ignore("Doesn't work after porting")
public class PolicyTestCase{
private Node node;
private Target targetClient;
@Before
public void setUp() throws Exception {
try {
NodeFactory factory = NodeFactory.newInstance();
node = factory.createNode(new File("src/main/resources/policy/PolicyOuterComposite.composite").toURI().toURL().toString(),
new Contribution("TestContribution", new File("src/main/resources/policy/").toURI().toURL().toString()));
node.start();
targetClient = node.getService(Target.class, "TargetClientComponent");
} catch(Exception ex) {
System.out.println(ex.toString());
}
}
@After
public void tearDown() throws Exception {
node.stop();
}
@Test
public void test() throws Exception {
//Check that the binding policy sets do flow down to the component but not down to the
//component inside implementation.composite
Component outerComponent = ((NodeImpl)node).getDomainComposite().getComponent("OuterTargetServiceComponent");
// The outer component service bindings should have policy sets attached
Assert.assertEquals(1, outerComponent.getServices().get(0).getPolicySets().size());
Component component = ((CompositeImpl)outerComponent.getImplementation()).getComponents().get(0);
// The original inner component service binding should not have policy sets attached
Assert.assertEquals(0, ((PolicySet)component.getServices().get(0).getBindings().get(0)).getReferencedPolicySets().size());
// The promoted inner component service binding should have policy sets attached
Assert.assertEquals(1, ((PolicySet)component.getServices().get(1).getBindings().get(0)).getReferencedPolicySets().size());
String result = targetClient.hello("Fred");
System.out.println(result);
}
}

View file

@ -0,0 +1,68 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import junit.framework.Assert;
import org.apache.tuscany.sca.Node;
import org.apache.tuscany.sca.TuscanyRuntime;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import recursive.Composer;
/**
* Test case for hweb service client
*/
public class ComposerClientTestCase {
private Node node;
private Composer composer;
@Before
public void startClient() throws Exception {
try {
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
node = tuscanyRuntime.createNode("myDomain");
node.installContribution("contrib1", "src/main/resources/recursive", null, null);
node.startComposite("contrib1", "Outer.composite");
node.startComposite("contrib1", "Client.composite");
composer = node.getService(Composer.class, "ClientComponent/Composer");
} catch (Throwable e) {
e.printStackTrace();
}
}
@Test
public void testWSClient() throws Exception {
String msg = composer.Compose("ABC");
Assert.assertEquals("Composed: ABC", msg);
}
@After
public void stopClient() throws Exception {
node.stop();
}
}

View file

@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package recursive;
import junit.framework.Assert;
import org.apache.tuscany.sca.Node;
import org.apache.tuscany.sca.TuscanyRuntime;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import recursive.Composer;
/**
* TUSCANY-3907
* Tests that a composite can be started at the top level and as a nested composite without
* have the fact the the composite will be built twice mess things up
*/
public class CompositeMulitStartTestCase {
private Node node;
private Composer composer;
@Before
public void startClient() throws Exception {
try {
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
node = tuscanyRuntime.createNode("myDomain");
node.installContribution("contrib1", "src/main/resources/recursive", null, null);
node.startComposite("contrib1", "Inner.composite");
node.startComposite("contrib1", "Outer.composite");
node.startComposite("contrib1", "Client.composite");
composer = node.getService(Composer.class, "ClientComponent/Composer");
} catch (Throwable e) {
e.printStackTrace();
}
}
@Test
public void testWSClient() throws Exception {
String msg = composer.Compose("ABC");
Assert.assertEquals("Composed: ABC", msg);
}
@After
public void stopClient() throws Exception {
node.stop();
}
}