tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r720215 - in /tuscany/branches/sca-java-1.x/itest: ./ references-collection/ references-collection/src/ references-collection/src/main/ references-collection/src/main/java/ references-collection/src/main/java/crawler/ references-collection/...
Date Mon, 24 Nov 2008 15:56:22 GMT
Author: slaws
Date: Mon Nov 24 07:56:21 2008
New Revision: 720215

URL: http://svn.apache.org/viewvc?rev=720215&view=rev
Log:
TUSCANY-2281 - test case for getting reference collections. Thanks for the test case Daniel

Added:
    tuscany/branches/sca-java-1.x/itest/references-collection/
    tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml   (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
  (with props)
    tuscany/branches/sca-java-1.x/itest/references-collection/src/test/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/
    tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
  (with props)
Modified:
    tuscany/branches/sca-java-1.x/itest/pom.xml

Modified: tuscany/branches/sca-java-1.x/itest/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/pom.xml?rev=720215&r1=720214&r2=720215&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/pom.xml (original)
+++ tuscany/branches/sca-java-1.x/itest/pom.xml Mon Nov 24 07:56:21 2008
@@ -113,6 +113,7 @@
                 <module>recursive</module>
                 <module>recursive-multi-level</module>
                 <module>recursive-ws</module>
+                <module>references-collection</module>
                 <module>references</module>
                 <module>serialization</module>
                 <module>services</module>

Added: tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml (added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml Mon Nov 24 07:56:21
2008
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-itest</artifactId>
+        <version>1.4-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>itest-references-collection</artifactId>
+    <name>Apache Tuscany SCA iTest References Collection</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-ws-axis2</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>        
+
+    </dependencies>
+</project>

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
Mon Nov 24 07:56:21 2008
@@ -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 crawler;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+@Conversational
+public interface Crawler
+{
+    /**
+     * Returns the crawler Id.
+     * @return a String containing the CrawlerId
+     */
+    String getCrawlerId();
+
+    /**
+     * Starts a crawl process.
+     * @return a message that the crawl was started
+     */
+    String crawl();
+    
+    /**
+     * Closes the conversation.
+     */
+    @EndsConversation
+    String close();   
+}

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/Crawler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,41 @@
+/*
+ * 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 crawler;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface CrawlerController
+{
+    /**
+     * Tries to return a Crawler with the given Id in the list of crawlers.
+     * It uses the getServiceReference() method which should throw an exception because of
multiplicity 0..n
+     * @param crawlerId the id of the Crawler
+     * @return the Crawler
+     */
+    Crawler getCrawler(String crawlerId);
+
+    /**
+     * Tries to return a Crawler with the given Id in the list of crawlers.
+     * It uses the getServiceReferences() method which shoulkd work properly with multiplicity
0..n
+     * @param crawlerId the id of the Crawler
+     * @return the Crawler
+     */
+    Crawler findCrawler(String crawlerId);
+}

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/CrawlerController.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,79 @@
+/*
+ * 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 crawler.impl;
+
+import crawler.Crawler;
+import crawler.CrawlerController;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.AllowsPassByReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(CrawlerController.class)
+@Scope("COMPOSITE")
+@AllowsPassByReference
+public class CrawlerControllerImpl implements CrawlerController
+{
+    @Context
+    protected ComponentContext componentContext;
+
+    @Reference
+    public List<Crawler> crawlers;
+
+    /**
+     * @see CrawlerController#getCrawler(String)
+     */
+    public Crawler getCrawler(String crawlerId)
+    {
+        for (int i = 0; i < crawlers.size(); i++)
+        {
+            Crawler crawler = crawlers.get(i);
+            String id = crawler.getCrawlerId();
+            if (crawlerId.equals(id))
+            {
+                Crawler newCrawler = componentContext.getService(Crawler.class, "crawlers");
+                return newCrawler;
+            }
+        }
+        throw new RuntimeException("No crawler with id " + crawlerId + " found");
+    }
+
+    /**
+     * @see CrawlerController#findCrawler(String)
+     */
+    public Crawler findCrawler(String crawlerId)
+    {
+        Collection<Crawler> crawlers = componentContext.getServices(Crawler.class,
"crawlers");
+        for (Crawler crawler : crawlers)
+        {
+            String id = crawler.getCrawlerId();
+            if (crawlerId.equals(id))
+            {
+                return crawler;
+            }
+        }
+        throw new RuntimeException("No crawler with id " + crawlerId + " found");
+    }
+}

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerControllerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,69 @@
+/*
+ * 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 crawler.impl;
+
+import crawler.Crawler;
+
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.AllowsPassByReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Crawler.class)
+@AllowsPassByReference
+@Scope("CONVERSATION")
+public class CrawlerImpl implements Crawler
+{
+    @ConversationID
+    protected String conversationId;
+    
+    @Property
+    protected String crawlerId;
+
+    @Context
+    protected ComponentContext componentContext;
+
+    /**
+     * @see Crawler#getCrawlerId()
+     */
+    public String getCrawlerId()
+    {
+        return crawlerId;
+    }
+
+    /**
+     * @see Crawler#crawl()
+     */
+    public String crawl()
+    {
+        System.out.println("started crawl with conversation " + conversationId);
+        return "started crawl with id " + getCrawlerId();
+    }
+    
+    /**
+     * @see Crawler#close()
+     */
+    public String close()
+    {
+        return "ended conversation with id " + getCrawlerId();
+    }
+}
\ No newline at end of file

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/CrawlerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,69 @@
+/*
+ * 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 crawler.impl;
+
+import crawler.Crawler;
+
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.AllowsPassByReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Crawler.class)
+@AllowsPassByReference
+@Scope("CONVERSATION")
+public class SpecialCrawlerImpl implements Crawler
+{
+    @ConversationID
+    protected String conversationId;
+
+    @Property
+    protected String crawlerId;
+
+    @Context
+    protected ComponentContext componentContext;
+
+    /**
+     * @see Crawler#getCrawlerId()
+     */
+    public String getCrawlerId()
+    {
+        return crawlerId;
+    }
+
+    /**
+     * @see Crawler#crawl()
+     */
+    public String crawl()
+    {
+        System.out.println("started crawl with conversation " + conversationId);
+        return "started crawl with id " + getCrawlerId();
+    }
+    
+    /**
+     * @see Crawler#close()
+     */
+    public String close()
+    {
+        return "ended conversation with id " + getCrawlerId();
+    }
+}
\ No newline at end of file

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/java/crawler/impl/SpecialCrawlerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,51 @@
+<?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:t="http://tuscany.apache.org/xmlns/sca/1.0"
+           targetNamespace="http://crawler"
+           xmlns:crawler="http://crawler"
+           name="crawler">
+
+    <component name="CrawlerControllerComponent">
+        <implementation.java class="crawler.impl.CrawlerControllerImpl"/>
+            <service name="CrawlerController">
+                <interface.java interface="crawler.CrawlerController" />
+            </service>
+        <reference name="crawlers" multiplicity="1..n" target="CrawlerComponent SpecialCrawlerComponent"
/>
+    </component>
+	       
+    <component name="CrawlerComponent">
+        <implementation.java class="crawler.impl.CrawlerImpl"/>
+        <property name="crawlerId">normalcrawler</property>  
+        <service name="Crawler">
+            <interface.java interface="crawler.Crawler" />									
+        </service>	
+    </component>	
+	
+    <component name="SpecialCrawlerComponent">
+        <implementation.java class="crawler.impl.SpecialCrawlerImpl"/>
+        <property name="crawlerId">specialcrawler</property>
+        <service name="Crawler">
+            <interface.java interface="crawler.Crawler" />			
+        </service>
+    </component>
+
+</composite>
\ No newline at end of file

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/main/resources/test.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java?rev=720215&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
(added)
+++ tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
Mon Nov 24 07:56:21 2008
@@ -0,0 +1,134 @@
+/*
+ * 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 crawler;
+
+import crawler.Crawler;
+import crawler.CrawlerController;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCAContribution;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.osoa.sca.ServiceRuntimeException;
+
+import junit.framework.TestCase;
+
+public class ReferenceMultiplicityTestCase extends TestCase
+{
+    private final String CRAWLER_ID = "normalcrawler";
+    private final String SPECIAL_CRAWLER_ID = "specialcrawler";
+
+    private static SCANode _scaDomain;
+    private CrawlerController _controller;
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+        _scaDomain = nodeFactory.createSCANode("test.composite", 
+                                               new SCAContribution("crawler", "./target/classes"));
+        assertNotNull(_scaDomain);
+        _scaDomain.start();
+        _controller = ((SCAClient)_scaDomain).getService(CrawlerController.class, "CrawlerControllerComponent");
+        assertNotNull(_controller);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        _controller = null;
+        if (_scaDomain != null)
+        {
+            _scaDomain.stop();
+            _scaDomain = null;
+        }
+    }
+
+    public void testGetCrawler() throws Exception
+    {
+        try
+        {
+            _controller.getCrawler(CRAWLER_ID);
+            fail("Expected exception");
+        }
+        catch (ServiceRuntimeException e)
+        {
+            assertEquals("Unexpected error message", "Reference crawlers has multiplicity
ONE_N", e.getMessage());
+        }
+        catch (Exception e)
+        {
+            fail("Expected ServiceRuntimeException, not a " + e.getClass());
+        }
+
+        try
+        {
+            _controller.getCrawler(SPECIAL_CRAWLER_ID);
+            fail("Expected exception");
+        }
+        catch (ServiceRuntimeException e)
+        {
+            assertEquals("Unexpected error message", "Reference crawlers has multiplicity
ONE_N", e.getMessage());
+        }
+        catch (Exception e)
+        {
+            fail("Expected ServiceRuntimeException, not a " + e.getClass());
+        }
+    }
+/*
+    public void testFindCrawler() throws Exception
+    {
+        try
+        {
+            Crawler crawler = _controller.findCrawler(CRAWLER_ID);
+            assertNotNull(crawler);
+            String msg = crawler.crawl();
+            assertEquals("Received unexpected msg", "started crawl with id " + CRAWLER_ID,
msg);
+            msg = crawler.close();
+            assertEquals("Received unexpected msg", "ended conversation with id " + CRAWLER_ID,
msg);
+        }        
+        catch (Exception e)
+        {
+            fail("Unexpected Exception " + e.getClass());
+        }
+
+        try
+        {
+            Crawler crawler = _controller.findCrawler(SPECIAL_CRAWLER_ID);
+            assertNotNull(crawler);
+            String msg = crawler.crawl();
+            assertEquals("Received unexpected msg", "started crawl with id " + SPECIAL_CRAWLER_ID,
msg);
+            msg = crawler.close();
+            assertEquals("Received unexpected msg", "ended conversation with id " + SPECIAL_CRAWLER_ID,
msg);
+        }
+        catch (Exception e)
+        {
+            fail("Unexpected Exception " + e.getClass());
+        }
+    }
+*/
+}

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/itest/references-collection/src/test/java/crawler/ReferenceMultiplicityTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message