bringing over import export itests to trunk to help me investigate current apparent failures in otest import/export

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@781699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
kelvingoodson 2009-06-04 10:07:24 +00:00
parent 7170098577
commit b921d97c9a
43 changed files with 2175 additions and 0 deletions

View file

@ -0,0 +1,67 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-export-composite</artifactId>
<name>Apache Tuscany SCA iTest Contribution Export</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,30 @@
/*
* 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 hello;
import org.osoa.sca.annotations.Remotable;
/**
* This is the business interface of the Hello service.
*/
@Remotable
public interface Hello {
public String getGreetings(String name);
}

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 hello;
import org.osoa.sca.annotations.Service;
/**
* This class implements the HelloWorld service.
*/
@Service(Hello.class)
public class HelloImpl implements Hello {
public String getGreetings(String name) {
return "Hello " + name;
}
}

View file

@ -0,0 +1,25 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://hello"
xmlns:hello="http://hello">
<deployable composite="hello:hello"/>
<export namespace="http://hello"/>
</contribution>

View file

@ -0,0 +1,31 @@
<?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://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://hello"
xmlns:hello="http://hello"
name="hello">
<service name="HelloService" promote="HelloServiceComponent"/>
<component name="HelloServiceComponent">
<implementation.java class="hello.HelloImpl" />
</component>
</composite>

View file

@ -0,0 +1,91 @@
/*
* 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 org.apache.tuscany.sca.test.contribution;
import hello.Hello;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
* Tests that the helloworld server is available
*/
public class HelloTestCase extends TestCase {
private ClassLoader cl;
private EmbeddedSCADomain domain;
@Override
protected void setUp() throws Exception {
// Create a test embedded SCA domain
cl = getClass().getClassLoader();
domain = new EmbeddedSCADomain(cl, "http://localhost");
// Start the domain
domain.start();
// Contribute the SCA contribution
ContributionService contributionService = domain.getContributionService();
URL helloURL = getContributionURL(Hello.class);
// File helloContrib = new File("./target/classes/");
// URL helloURL = helloContrib.toURL();
Contribution consumerContribution =
contributionService.contribute("http://import-export/hello", helloURL, false);
Composite consumerComposite = consumerContribution.getDeployables().get(0);
domain.getDomainComposite().getIncludes().add(consumerComposite);
domain.buildComposite(consumerComposite);
// Start Components from my composite
domain.getCompositeActivator().activate(consumerComposite);
domain.getCompositeActivator().start(consumerComposite);
}
private URL getContributionURL(Class<?> cls) throws MalformedURLException {
String flag = "/" + cls.getName().replace('.', '/') + ".class";
URL url = cls.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length() + 1);
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
public void testHello() throws IOException {
Hello hello = domain.getService(Hello.class, "HelloServiceComponent");
assertNotNull(hello);
assertEquals(hello.getGreetings("lresende"), "Hello lresende");
}
@Override
public void tearDown() throws Exception {
domain.close();
}
}

View file

@ -0,0 +1,67 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-export-java</artifactId>
<name>Apache Tuscany SCA iTest Contribution Java Export</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,30 @@
/*
* 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 helloworld;
import org.osoa.sca.annotations.Remotable;
/**
* This is the business interface of the HelloWorld greetings service.
*/
@Remotable
public interface HelloWorldService {
public String getGreetings(String name);
}

View file

@ -0,0 +1,24 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld">
<export.java package="helloworld"/>
</contribution>

View file

@ -0,0 +1,30 @@
<?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.
-->
<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<service name="HelloWorldService">
<interface.java interface="helloworld.HelloWorldService" />
</service>
</componentType>

View file

@ -0,0 +1,31 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-export-resource</artifactId>
<name>Apache Tuscany SCA iTest Contribution Resource Export</name>
</project>

View file

@ -0,0 +1,24 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://store"
xmlns:helloworld="http://store">
<export.resource uri="ufservices/store.html"/>
</contribution>

View file

@ -0,0 +1,27 @@
<!--
* 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.
-->
<html>
<head>
<title>Store</TITLE>
</head>
<body>
<h1>Sample Store Page</h1>
</body>
</html>

View file

@ -0,0 +1,31 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-export-wsdl</artifactId>
<name>Apache Tuscany SCA iTest Contribution WSDL Export</name>
</project>

View file

@ -0,0 +1,24 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld">
<export namespace="http://helloworld"/>
</contribution>

View file

@ -0,0 +1,76 @@
<?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.
-->
<wsdl:definitions targetNamespace="http://helloworld"
xmlns:tns="http://helloworld"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="helloworld">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns2="http://helloworld2"
targetNamespace="http://helloworld"
elementFormDefault="qualified">
<xsd:import namespace="http://helloworld2" schemaLocation="helloworld.xsd" />
<element name="getGreetings" type="tns2:getGreetingsType"/>
<element name="getGreetingsResponse" type="tns2:getGreetingsResponseType"/>
</schema>
</wsdl:types>
<wsdl:message name="getGreetingsRequest">
<wsdl:part element="tns:getGreetings" name="parameters"/>
</wsdl:message>
<wsdl:message name="getGreetingsResponse">
<wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="HelloWorld">
<wsdl:operation name="getGreetings">
<wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
<wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getGreetings">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getGreetingsRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getGreetingsResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldService">
<wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
<wsdlsoap:address location="http://localhost:8085/HelloWorldServiceComponent"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View file

@ -0,0 +1,35 @@
<?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.
-->
<schema targetNamespace="http://helloworld2"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ns="http://helloworld2">
<complexType name="getGreetingsType">
<sequence>
<element name="name" type="string"/>
</sequence>
</complexType>
<complexType name="getGreetingsResponseType">
<sequence>
<element name="getGreetingsReturn" type="string"/>
</sequence>
</complexType>
</schema>

View file

@ -0,0 +1,73 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-import-composite</artifactId>
<name>Apache Tuscany SCA iTest Contribution Import</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>itest-contribution-export-composite</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

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 helloworld;
import hello.Hello;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
/**
* This class implements the HelloWorld service.
*/
@Service(HelloWorldService.class)
public class HelloWorldImpl implements HelloWorldService {
@Reference
protected Hello helloServiceRef;
public String getGreetings(String name) {
return helloServiceRef.getGreetings(name);
}
}

View file

@ -0,0 +1,46 @@
/*
* 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 helloworld;
import java.io.IOException;
import org.apache.tuscany.sca.host.embedded.SCADomain;
/**
* This server program shows how to create an SCA runtime, and start it which
* activates the helloworld Web service endpoint.
*/
public class HelloWorldServer {
public static void main(String[] args) {
SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite");
try {
System.out.println("HelloWorld server started (press enter to shutdown)");
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
scaDomain.close();
System.out.println("HelloWorld server stopped");
}
}

View file

@ -0,0 +1,30 @@
/*
* 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 helloworld;
import org.osoa.sca.annotations.Remotable;
/**
* This is the business interface of the HelloWorld greetings service.
*/
@Remotable
public interface HelloWorldService {
public String getGreetings(String name);
}

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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld"
xmlns:hello="http://hello">
<deployable composite="helloworld:helloworldws"/>
<import namespace="http://hello"/>
<!-- import namespace="http://hello" location="http://import-export/contrib-composite"/ -->
</contribution>

View file

@ -0,0 +1,76 @@
<?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.
-->
<wsdl:definitions targetNamespace="http://helloworld"
xmlns:tns="http://helloworld"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="helloworld">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns2="http://helloworld2"
targetNamespace="http://helloworld"
elementFormDefault="qualified">
<xsd:import namespace="http://helloworld2" schemaLocation="helloworld.xsd" />
<element name="getGreetings" type="tns2:getGreetingsType"/>
<element name="getGreetingsResponse" type="tns2:getGreetingsResponseType"/>
</schema>
</wsdl:types>
<wsdl:message name="getGreetingsRequest">
<wsdl:part element="tns:getGreetings" name="parameters"/>
</wsdl:message>
<wsdl:message name="getGreetingsResponse">
<wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="HelloWorld">
<wsdl:operation name="getGreetings">
<wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
<wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getGreetings">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getGreetingsRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getGreetingsResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldService">
<wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
<wsdlsoap:address location="http://localhost:8085/HelloWorldServiceComponent"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View file

@ -0,0 +1,35 @@
<?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.
-->
<schema targetNamespace="http://helloworld2"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ns="http://helloworld2">
<complexType name="getGreetingsType">
<sequence>
<element name="name" type="string"/>
</sequence>
</complexType>
<complexType name="getGreetingsResponseType">
<sequence>
<element name="getGreetingsReturn" type="string"/>
</sequence>
</complexType>
</schema>

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://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld"
xmlns:hello="http://hello"
name="helloworldws">
<component name="SourceHelloServiceComponent">
<implementation.composite name="hello:hello"/>
</component>
<component name="HelloWorldServiceComponent">
<service name="HelloWorldService">
<interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
<binding.ws uri="http://localhost:8085/HelloWorldService"/>
</service>
<implementation.java class="helloworld.HelloWorldImpl" />
<reference name="helloServiceRef" target="SourceHelloServiceComponent/HelloService"/>
</component>
</composite>

View file

@ -0,0 +1,126 @@
/*
* 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 org.apache.tuscany.test.contribution;
import hello.Hello;
import helloworld.HelloWorldService;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
* Tests that the helloworld server is available
*/
public class HelloWorldServerTestCase extends TestCase {
private ClassLoader cl;
private EmbeddedSCADomain domain;
private Contribution helloWorldContribution;
private Contribution compositeContribution;
@Override
protected void setUp() throws Exception {
//Create a test embedded SCA domain
cl = getClass().getClassLoader();
domain = new EmbeddedSCADomain(cl, "http://localhost");
//Start the domain
domain.start();
// Contribute the SCA contribution
ContributionService contributionService = domain.getContributionService();
// File compositeContribLocation = new File("../export-composite/target/classes");
// URL compositeContribURL = compositeContribLocation.toURL();
URL compositeContribURL = getContributionURL(Hello.class);
compositeContribution =
contributionService.contribute("http://import-export/export-composite", compositeContribURL, false);
for (Composite deployable : compositeContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// File helloWorldContribLocation = new File("./target/classes/");
// URL helloWorldContribURL = helloWorldContribLocation.toURL();
URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
helloWorldContribution =
contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// Start Components from my composite
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getCompositeActivator().activate(deployable);
domain.getCompositeActivator().start(deployable);
}
}
private URL getContributionURL(Class<?> cls) throws MalformedURLException {
String flag = "/" + cls.getName().replace('.', '/') + ".class";
URL url = cls.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length() + 1);
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
public void testPing() throws IOException {
new Socket("127.0.0.1", 8085);
}
public void testServiceCall() throws IOException {
HelloWorldService helloWorldService =
domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
assertNotNull(helloWorldService);
assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
}
@Override
public void tearDown() throws Exception {
ContributionService contributionService = domain.getContributionService();
// Remove the contribution from the in-memory repository
contributionService.remove("http://import-export/helloworld");
contributionService.remove("http://import-export/export-composite");
//Stop Components from my composite
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getCompositeActivator().stop(deployable);
domain.getCompositeActivator().deactivate(deployable);
}
domain.stop();
domain.close();
}
}

View file

@ -0,0 +1,73 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-import-java</artifactId>
<name>Apache Tuscany SCA iTest Contribution Java Import</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>itest-contribution-export-java</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

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 helloworld;
import org.osoa.sca.annotations.Service;
/**
* This class implements the HelloWorld service.
*/
@Service(HelloWorldService.class)
public class HelloWorldImpl implements HelloWorldService {
public String getGreetings(String name) {
return "Hello " + name;
}
}

View file

@ -0,0 +1,25 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld">
<deployable composite="helloworld:helloworldws"/>
<import.java package="helloworld"/>
</contribution>

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://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld"
name="helloworldws">
<component name="HelloWorldServiceComponent">
<implementation.java class="helloworld.HelloWorldImpl" />
</component>
</composite>

View file

@ -0,0 +1,127 @@
/*
* 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 org.apache.tuscany.sca.test.contribution;
import helloworld.HelloWorldImpl;
import helloworld.HelloWorldService;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
* Tests that the helloworld server is available
*/
public class HelloWorldServerTestCase extends TestCase {
private ClassLoader cl;
private EmbeddedSCADomain domain;
private Contribution helloWorldContribution;
private Contribution javaContribution;
@Override
protected void setUp() throws Exception {
//Create a test embedded SCA domain
cl = getClass().getClassLoader();
domain = new EmbeddedSCADomain(cl, "http://localhost");
//Start the domain
domain.start();
// Contribute the SCA contribution
ContributionService contributionService = domain.getContributionService();
//File javaContribLocation = new File("../export-java/target/classes");
//URL javaContribURL = javaContribLocation.toURL();
URL javaContribURL = getContributionURL(HelloWorldService.class);
javaContribution = contributionService.contribute("http://import-export/export-java", javaContribURL, false);
for (Composite deployable : javaContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
//File helloWorldContribLocation = new File("./target/classes/");
//URL helloWorldContribURL = helloWorldContribLocation.toURL();
URL helloWorldContribURL = getContributionURL(HelloWorldImpl.class);
helloWorldContribution = contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// Start Components from my composite
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getCompositeActivator().activate(deployable);
domain.getCompositeActivator().start(deployable);
}
}
private URL getContributionURL(Class<?> cls) throws MalformedURLException {
String flag = "/" + cls.getName().replace('.', '/') + ".class";
URL url = cls.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length() + 1);
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
public void testPing() throws IOException {
HelloWorldService helloWorldService =
domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
assertNotNull(helloWorldService);
assertEquals("Hello test", helloWorldService.getGreetings("test"));
}
public void testServiceCall() throws IOException {
HelloWorldService helloWorldService =
domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
assertNotNull(helloWorldService);
assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
}
@Override
public void tearDown() throws Exception {
ContributionService contributionService = domain.getContributionService();
// Remove the contribution from the in-memory repository
contributionService.remove("http://import-export/helloworld");
contributionService.remove("http://import-export/export-java");
// Stop Components from my composite
for (Composite deployable : helloWorldContribution.getDeployables()) {
domain.getCompositeActivator().stop(deployable);
domain.getCompositeActivator().deactivate(deployable);
}
domain.stop();
domain.close();
}
}

View file

@ -0,0 +1,102 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-import-resource</artifactId>
<name>Apache Tuscany SCA iTest Contribution Resource Import</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>itest-contribution-export-resource</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-http</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-http-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-resource-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-resource</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,25 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://store"
xmlns:store="http://store">
<deployable composite="store:store"/>
<import.resource uri="ufservices/store.html"/>
</contribution>

View file

@ -0,0 +1,33 @@
<?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://www.osoa.org/xmlns/sca/1.0"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://store"
xmlns:helloworld="http://store"
name="store">
<component name="store">
<tuscany:implementation.resource location="ufservices/store.html"/>
<service name="Resource">
<tuscany:binding.http uri="http://127.0.0.1:8085"/>
</service>
</component>
</composite>

View file

@ -0,0 +1,129 @@
/*
* 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 org.apache.tuscany.sca.test.contribution;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
* Tests that the helloworld server is available
*/
public class StoreTestCase extends TestCase {
private ClassLoader cl;
private EmbeddedSCADomain domain;
private Contribution storeContribution;
private Contribution resourceContribution;
@Override
protected void setUp() throws Exception {
//Create a test embedded SCA domain
cl = getClass().getClassLoader();
domain = new EmbeddedSCADomain(cl, "http://localhost");
//Start the domain
domain.start();
// Contribute the SCA contribution
ContributionService contributionService = domain.getContributionService();
URL javaContribURL = getContributionURL(cl, "ufservices/store.html");
resourceContribution = contributionService.contribute("http://import-export/export-resource", javaContribURL, false);
for (Composite deployable : resourceContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
URL storeContributionURL = getContributionURL(cl, "store.composite");
storeContribution =
contributionService.contribute("http://import-export/store", storeContributionURL, false);
for (Composite deployable : storeContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// Start Components from my composite
for (Composite deployable : storeContribution.getDeployables()) {
domain.getCompositeActivator().activate(deployable);
domain.getCompositeActivator().start(deployable);
}
}
public void testPing() throws IOException {
new Socket("127.0.0.1", 8085);
}
@Override
public void tearDown() throws Exception {
ContributionService contributionService = domain.getContributionService();
// Remove the contribution from the in-memory repository
contributionService.remove("http://import-export/store");
contributionService.remove("http://import-export/export-resource");
// Stop Components from my composite
for (Composite deployable : storeContribution.getDeployables()) {
domain.getCompositeActivator().stop(deployable);
domain.getCompositeActivator().deactivate(deployable);
}
domain.stop();
domain.close();
}
/**
* Utility methods
*/
private URL getContributionURL(ClassLoader cl, Class<?> cls) throws MalformedURLException {
String flag = "/" + cls.getName().replace('.', '/') + ".class";
URL url = cl.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length() + 1);
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
private URL getContributionURL(ClassLoader cl, String uri) throws MalformedURLException {
URL url = cl.getResource(uri);
String root = url.toExternalForm();
root = root.substring(0, root.length() - uri.length());
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
}

View file

@ -0,0 +1,73 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-import-wsdl</artifactId>
<name>Apache Tuscany SCA iTest Contribution WSDL Import</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>itest-contribution-export-wsdl</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-tomcat</artifactId>
<version>1.6-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

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 helloworld;
import org.osoa.sca.annotations.Service;
/**
* This class implements the HelloWorld service.
*/
@Service(HelloWorldService.class)
public class HelloWorldImpl implements HelloWorldService {
public String getGreetings(String name) {
return "Hello " + name;
}
}

View file

@ -0,0 +1,46 @@
/*
* 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 helloworld;
import java.io.IOException;
import org.apache.tuscany.sca.host.embedded.SCADomain;
/**
* This server program shows how to create an SCA runtime, and start it which
* activates the helloworld Web service endpoint.
*/
public class HelloWorldServer {
public static void main(String[] args) {
SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite");
try {
System.out.println("HelloWorld server started (press enter to shutdown)");
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
scaDomain.close();
System.out.println("HelloWorld server stopped");
}
}

View file

@ -0,0 +1,30 @@
/*
* 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 helloworld;
import org.osoa.sca.annotations.Remotable;
/**
* This is the business interface of the HelloWorld greetings service.
*/
@Remotable
public interface HelloWorldService {
public String getGreetings(String name);
}

View file

@ -0,0 +1,25 @@
<?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.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:helloworld="http://helloworld">
<deployable composite="helloworld:helloworldws"/>
<import namespace="http://helloworld" location="http://import-export/export-wsdl"/>
</contribution>

View file

@ -0,0 +1,33 @@
<?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://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld"
xmlns:hw="http://helloworld"
name="helloworldws">
<component name="HelloWorldServiceComponent">
<service name="HelloWorldService">
<interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
<binding.ws uri="http://localhost:8085/HelloWorldService"/>
</service>
<implementation.java class="helloworld.HelloWorldImpl" />
</component>
</composite>

View file

@ -0,0 +1,137 @@
/*
* 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 org.apache.tuscany.sca.test.contribution;
import helloworld.HelloWorldService;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
* Tests that the helloworld server is available
*/
public class HelloWorldServerTestCase extends TestCase {
private ClassLoader cl;
private EmbeddedSCADomain domain;
private Contribution wsdlContribution;
private Contribution consumerContribution;
@Override
protected void setUp() throws Exception {
// Create a test embedded SCA domain
cl = getClass().getClassLoader();
domain = new EmbeddedSCADomain(cl, "http://localhost");
//Start the domain
domain.start();
// Contribute the SCA contribution
ContributionService contributionService = domain.getContributionService();
// File wsdlContribLocation = new File("../export-wsdl/target/classes");
// URL wsdlContribURL = wsdlContribLocation.toURL();
URL wsdlContribURL = getContributionURL(getClass().getClassLoader(), "helloworld.wsdl");
wsdlContribution = contributionService.contribute("http://import-export/export-wsdl", wsdlContribURL, false);
for (Composite deployable : wsdlContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// File helloWorldContribLocation = new File("./target/classes/");
// URL helloWorldContribURL = helloWorldContribLocation.toURL();
URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
consumerContribution =
contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
for (Composite deployable : consumerContribution.getDeployables()) {
domain.getDomainComposite().getIncludes().add(deployable);
domain.buildComposite(deployable);
}
// Start Components from my composite
for (Composite deployable : consumerContribution.getDeployables()) {
domain.getCompositeActivator().activate(deployable);
domain.getCompositeActivator().start(deployable);
}
}
public void testPing() throws IOException {
new Socket("127.0.0.1", 8085);
}
private URL getContributionURL(Class<?> cls) throws MalformedURLException {
String flag = "/" + cls.getName().replace('.', '/') + ".class";
URL url = cls.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length() + 1);
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
return url;
}
private URL getContributionURL(ClassLoader cl, String flag) throws MalformedURLException {
URL url = cl.getResource(flag);
String root = url.toExternalForm();
root = root.substring(0, root.length() - flag.length());
if (root.startsWith("jar:") && root.endsWith("!/")) {
root = root.substring(4, root.length() - 2);
}
url = new URL(root);
// System.out.println(url);
return url;
}
public void testServiceCall() throws IOException {
HelloWorldService helloWorldService =
domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
assertNotNull(helloWorldService);
assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
}
@Override
public void tearDown() throws Exception {
ContributionService contributionService = domain.getContributionService();
// Remove the contribution from the in-memory repository
contributionService.remove("http://import-export/helloworld");
contributionService.remove("http://import-export/export-wsdl");
// Stop Components from my composite
for (Composite deployable : consumerContribution.getDeployables()) {
domain.getCompositeActivator().stop(deployable);
domain.getCompositeActivator().deactivate(deployable);
}
domain.stop();
domain.close();
}
}

View file

@ -0,0 +1,56 @@
<?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>1.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>itest-contribution-import-export</artifactId>
<packaging>pom</packaging>
<name>Apache Tuscany SCA Contribution Import/Export Integration Tests</name>
<modules>
<module>export-composite</module>
<module>export-java</module>
<module>export-resource</module>
<module>export-wsdl</module>
<module>import-composite</module>
<module>import-java</module>
<module>import-resource</module>
<module>import-wsdl</module>
</modules>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-impl</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>