You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fm...@apache.org on 2010/07/30 14:09:16 UTC
svn commit: r980746 - in
/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test:
java/org/ java/org/apache/ java/org/apache/tuscany/
java/org/apache/tuscany/sca/ java/org/apache/tuscany/sca/test/ resources/
Author: fmoga
Date: Fri Jul 30 12:09:15 2010
New Revision: 980746
URL: http://svn.apache.org/viewvc?rev=980746&view=rev
Log:
Added unit test.
Added:
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/CometTest.java
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockApp.java
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java
tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/resources/test.composite
Added: tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/CometTest.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/CometTest.java?rev=980746&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/CometTest.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/CometTest.java Fri Jul 30 12:09:15 2010
@@ -0,0 +1,27 @@
+package org.apache.tuscany.sca.test;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import junit.framework.TestCase;
+
+public class CometTest extends TestCase {
+
+ public void testComet() {
+ String location = ContributionLocationHelper.getContributionLocation("test.composite");
+ Node node = NodeFactory.newInstance().createNode("test.composite", new Contribution("c1", location));
+ node.start();
+ try {
+ System.out.println("Press any key to stop the node.");
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ node.stop();
+ }
+
+}
Added: tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockApp.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockApp.java?rev=980746&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockApp.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockApp.java Fri Jul 30 12:09:15 2010
@@ -0,0 +1,15 @@
+package org.apache.tuscany.sca.test;
+
+public class StockApp {
+
+ private StockService service = new StockServiceImpl();
+
+ public StockService getService() {
+ return service;
+ }
+
+ public void setService(StockService service) {
+ this.service = service;
+ }
+
+}
Added: tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java?rev=980746&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java Fri Jul 30 12:09:15 2010
@@ -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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface StockService {
+
+ String getSymbol();
+
+ Double getValue();
+
+}
Added: tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java?rev=980746&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java Fri Jul 30 12:09:15 2010
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.text.DecimalFormat;
+import java.util.Date;
+import java.util.Random;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(StockService.class)
+public class StockServiceImpl implements StockService {
+
+ public static final int MAX_VALUE = 1000;
+ private Random random = new Random(new Date().getTime());
+
+ @Override
+ public String getSymbol() {
+ return "ASF";
+ }
+
+ @Override
+ public Double getValue() {
+ Double value = Math.abs(random.nextDouble() * random.nextInt(MAX_VALUE));
+ return Double.valueOf(new DecimalFormat("#.##").format(value));
+ }
+
+}
Added: tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/resources/test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/resources/test.composite?rev=980746&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/resources/test.composite (added)
+++ tuscany/sca-java-2.x/contrib/modules/binding-comet-runtime/src/test/resources/test.composite Fri Jul 30 12:09:15 2010
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Stock">
+
+ <component name="StockApp">
+ <implementation.java class="org.apache.tuscany.sca.test.StockApp"/>
+ <service name="service">
+ <interface.java interface="org.apache.tuscany.sca.test.StockService"/>
+ <tuscany:binding.comet/>
+ </service>
+ </component>
+
+</composite>
\ No newline at end of file