From ace7daceb0d0e7e555d401751b567faf41114cdf Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 24 May 2011 11:08:30 +0000 Subject: TUSCANY-3867 - start of a test to check various lifecycle events. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1126977 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml | 43 +++++++++++ .../java/binding/lifecycle/LifecycleBinding.java | 49 ++++++++++++ .../binding/lifecycle/LifecycleBindingFactory.java | 32 ++++++++ .../lifecycle/LifecycleBindingProviderFactory.java | 47 ++++++++++++ .../LifecycleReferenceBindingProvider.java | 59 +++++++++++++++ .../lifecycle/LifecycleReferenceInvoker.java | 48 ++++++++++++ .../lifecycle/LifecycleServiceBindingProvider.java | 52 +++++++++++++ .../binding/lifecycle/LifecycleServiceInvoker.java | 40 ++++++++++ .../src/main/java/helloworld/Helloworld.java | 29 ++++++++ .../main/java/helloworld/HelloworldClientImpl.java | 50 +++++++++++++ .../java/helloworld/HelloworldServiceImpl.java | 30 ++++++++ .../src/main/java/helloworld/StatusImpl.java | 26 +++++++ .../services/binding.lifecycle.BindingFactory | 20 +++++ ...ca.contribution.processor.StAXArtifactProcessor | 20 +++++ ...any.sca.contribution.processor.ValidationSchema | 19 +++++ ...che.tuscany.sca.provider.BindingProviderFactory | 20 +++++ .../src/main/resources/binding-lifecycle.xsd | 37 ++++++++++ .../src/main/resources/lifecycle.composite | 37 ++++++++++ .../sca/itest/lifecycle/LifecycleTestCase.java | 86 ++++++++++++++++++++++ 19 files changed, 744 insertions(+) create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite create mode 100644 sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java (limited to 'sca-java-2.x/trunk/testing/itest') diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml b/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml new file mode 100644 index 0000000000..618c25a031 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-SNAPSHOT + ../pom.xml + + itest-lifecycle + Apache Tuscany SCA iTest Lifecycle + 2.0-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-base-runtime-pom + pom + 2.0-SNAPSHOT + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java new file mode 100644 index 0000000000..ecd4393e4d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBinding.java @@ -0,0 +1,49 @@ +/* + * 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 binding.lifecycle; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.provider.BaseBindingImpl; + +/** + * Represents a binding to a Sample service. + */ +public class LifecycleBinding extends BaseBindingImpl { + + public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.lifecycle"); + + private String someAttr; + + public LifecycleBinding() { + } + + public QName getType() { + return TYPE; + } + + public String getSomeAttr() { + return someAttr; + } + + public void setSomeAttr(String someAttr) { + this.someAttr = someAttr; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java new file mode 100644 index 0000000000..4fdf09bdf0 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingFactory.java @@ -0,0 +1,32 @@ +/* + * 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 binding.lifecycle; + + +/** + * Factory implementation to create Sample Models + */ +public class LifecycleBindingFactory { + + public LifecycleBinding createLifecycleBinding() { + return new LifecycleBinding(); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java new file mode 100644 index 0000000000..f197578e84 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleBindingProviderFactory.java @@ -0,0 +1,47 @@ +/* + * 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 binding.lifecycle; + +import binding.lifecycle.LifecycleBinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; + +public class LifecycleBindingProviderFactory implements BindingProviderFactory { + + public LifecycleBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public Class getModelType() { + return LifecycleBinding.class; + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) { + return new LifecycleReferenceBindingProvider(endpoint); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { + return new LifecycleServiceBindingProvider(endpoint); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java new file mode 100644 index 0000000000..5709de7747 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceBindingProvider.java @@ -0,0 +1,59 @@ +/* + * 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 binding.lifecycle; + +import helloworld.StatusImpl; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; + +public class LifecycleReferenceBindingProvider implements ReferenceBindingProvider { + + private EndpointReference endpoint; + private InterfaceContract contract; + + public LifecycleReferenceBindingProvider(EndpointReference endpoint) { + this.endpoint = endpoint; + } + + public Invoker createInvoker(Operation operation) { + return new LifecycleReferenceInvoker(operation, endpoint); + } + + public void start() { + StatusImpl.statusString += "Reference binding start "; + } + + public void stop() { + StatusImpl.statusString += "Reference binding stop "; + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java new file mode 100644 index 0000000000..023be8613b --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleReferenceInvoker.java @@ -0,0 +1,48 @@ +/* + * 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 binding.lifecycle; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +public class LifecycleReferenceInvoker implements Invoker { + + protected Operation operation; + protected EndpointReference endpoint; + + public LifecycleReferenceInvoker(Operation operation, EndpointReference endpoint) { + this.operation = operation; + this.endpoint = endpoint; + } + + public Message invoke(Message msg) { + try { + Object[] body = msg.getBody(); + msg.setBody(body[0]); + return msg; + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java new file mode 100644 index 0000000000..0f62e13aed --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceBindingProvider.java @@ -0,0 +1,52 @@ +/* + * 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 binding.lifecycle; + +import helloworld.StatusImpl; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +public class LifecycleServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeEndpoint endpoint; + private InterfaceContract contract; + + public LifecycleServiceBindingProvider(RuntimeEndpoint endpoint) { + this.endpoint = endpoint; + } + + public void start() { + StatusImpl.statusString += "Service binding start "; + } + + public void stop() { + StatusImpl.statusString += "Service binding stop "; + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java new file mode 100644 index 0000000000..09ca7a051e --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/binding/lifecycle/LifecycleServiceInvoker.java @@ -0,0 +1,40 @@ +/* + * 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 binding.lifecycle; + +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +public class LifecycleServiceInvoker { + + private RuntimeEndpoint wire; + + public LifecycleServiceInvoker(RuntimeEndpoint wire) { + this.wire = wire; + } + + /** + * Send the request down the wire to invoke the service + */ + public Message invokeService(Message msg) { + return wire.invoke(msg); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java new file mode 100644 index 0000000000..73030e16d3 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/Helloworld.java @@ -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 helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name) throws Exception; + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java new file mode 100644 index 0000000000..a1c06afbb5 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldClientImpl.java @@ -0,0 +1,50 @@ +/* + * 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.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +@EagerInit +@Scope("COMPOSITE") +public class HelloworldClientImpl implements Helloworld { + + @Reference + public Helloworld service; + + @Init + public void initialize() throws Exception{ + StatusImpl.statusString += "HelloworldClientImpl init "; + System.out.println(">>>>>> " + sayHello("init")); + } + + @Destroy + public void destroy() throws Exception{ + StatusImpl.statusString += "HelloworldClientImpl destroy "; + } + + public String sayHello(String name) throws Exception { + return "Hi " + service.sayHello(name); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java new file mode 100644 index 0000000000..d761dd4350 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/HelloworldServiceImpl.java @@ -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; + +public class HelloworldServiceImpl implements Helloworld { + + public String sayHello(String name) { + String response = "Hello " + name; + System.out.println("At service - " + response); + return response; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java new file mode 100644 index 0000000000..a18633ca74 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/java/helloworld/StatusImpl.java @@ -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 helloworld; + +public class StatusImpl { + + public static String statusString = ""; + +} diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory new file mode 100644 index 0000000000..357cf65727 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/binding.lifecycle.BindingFactory @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for model factory +binding.lifecycle.LifecycleBindingFactory + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..6536e872e1 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.lifecycle,model=binding.lifecycle.LifecycleBinding,factory=binding.lifecycle.LifecycleBindingFactory + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..4e577c2728 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# 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. +# +binding-lifecycle.xsd + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..9a814793b2 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for the binding extension +binding.lifecycle.LifecycleBindingProviderFactory;model=binding.lifecycle.LifecycleBinding + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd new file mode 100644 index 0000000000..b798446c26 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/binding-lifecycle.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite new file mode 100644 index 0000000000..2284d0920f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/main/resources/lifecycle.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java new file mode 100644 index 0000000000..4342dd63bd --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/lifecycle/src/test/java/org/apache/tuscany/sca/itest/lifecycle/LifecycleTestCase.java @@ -0,0 +1,86 @@ +/* + * 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.itest.lifecycle; + + +import helloworld.StatusImpl; +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; + + +public class LifecycleTestCase { + + public Node node = null; + + + @Before + public void setUp() throws Exception { + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void test1() throws Exception{ + + TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); + + // create a Tuscany node + node = tuscanyRuntime.createNode(); + + // install a contribution + node.installContribution("HelloworldContrib", "target/classes", null, null); + + // start a composite + node.startComposite("HelloworldContrib", "lifecycle.composite"); + + // stop a composite + node.stopComposite("HelloworldContrib", "lifecycle.composite"); + + // uninstall a constribution + node.uninstallContribution("HelloworldContrib"); + + // stop a Tuscany node + node.stop(); + + // stop the runtime + tuscanyRuntime.stop(); + + // see what happened + System.out.println(StatusImpl.statusString); + Assert.assertEquals("Service binding start " + + "HelloworldClientImpl init " + + "Reference binding start " + + "Service binding stop " + + "Reference binding stop " + + "HelloworldClientImpl destroy ", + StatusImpl.statusString); + + } + +} -- cgit v1.2.3