From 704be128887dcfa5963110985d14d939484cbc66 Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 1 Aug 2009 00:05:24 +0000 Subject: TUSCANY-3166 - Adding testcase to reproduce the problem described git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@799774 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/test/abdera/impl/NewsServiceImpl.java | 58 +++++++ .../test/java/test/abdera/NewsServiceTestCase.java | 74 +++++++++ .../atom/src/test/resources/news/news.composite | 34 +++++ .../itest/atom/src/test/resources/news/news.wsdl | 167 +++++++++++++++++++++ .../itest/atom/src/test/resources/news/news.xsd | 137 +++++++++++++++++ 5 files changed, 470 insertions(+) create mode 100644 branches/sca-java-1.x/itest/atom/src/main/java/test/abdera/impl/NewsServiceImpl.java create mode 100644 branches/sca-java-1.x/itest/atom/src/test/java/test/abdera/NewsServiceTestCase.java create mode 100644 branches/sca-java-1.x/itest/atom/src/test/resources/news/news.composite create mode 100644 branches/sca-java-1.x/itest/atom/src/test/resources/news/news.wsdl create mode 100644 branches/sca-java-1.x/itest/atom/src/test/resources/news/news.xsd (limited to 'branches/sca-java-1.x/itest/atom/src') diff --git a/branches/sca-java-1.x/itest/atom/src/main/java/test/abdera/impl/NewsServiceImpl.java b/branches/sca-java-1.x/itest/atom/src/main/java/test/abdera/impl/NewsServiceImpl.java new file mode 100644 index 0000000000..7d1b6e4347 --- /dev/null +++ b/branches/sca-java-1.x/itest/atom/src/main/java/test/abdera/impl/NewsServiceImpl.java @@ -0,0 +1,58 @@ +package test.abdera.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.osoa.sca.annotations.Init; + +import test.abdera.Entry; +import test.abdera.Item; +import test.abdera.NewsService; +import test.abdera.NotFoundException_Exception; + +public class NewsServiceImpl implements NewsService { + private static Map collection = new HashMap(); + + @Init + public void init() { + Item item = new Item(); + item.setName("Item Name 01"); + item.setTitle("Item title 01"); + + Entry entry = new Entry(); + entry.setKey("1"); + entry.setData(item); + + collection.put((String)entry.getKey(), entry); + } + + public List getAll() { + return (List) collection.values(); + } + + public Item get(String arg0) throws NotFoundException_Exception { + return (Item) collection.get(arg0).getData(); + } + + public String post(String arg0, Item arg1) { + // TODO Auto-generated method stub + return null; + } + + public void put(String arg0, Item arg1) throws NotFoundException_Exception { + // TODO Auto-generated method stub + + } + + public void delete(String arg0) throws NotFoundException_Exception { + // TODO Auto-generated method stub + + } + + public List query(String arg0) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/branches/sca-java-1.x/itest/atom/src/test/java/test/abdera/NewsServiceTestCase.java b/branches/sca-java-1.x/itest/atom/src/test/java/test/abdera/NewsServiceTestCase.java new file mode 100644 index 0000000000..0d9c1c11b3 --- /dev/null +++ b/branches/sca-java-1.x/itest/atom/src/test/java/test/abdera/NewsServiceTestCase.java @@ -0,0 +1,74 @@ +/* + * 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 test.abdera; + +import java.net.Socket; +import java.util.List; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class NewsServiceTestCase { + private static SCADomain domain; + private static NewsService newsService; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("news/news.composite"); + Assert.assertNotNull(domain); + newsService = domain.getService(NewsService.class, "NewsServiceComponent"); + Assert.assertNotNull(newsService); + } + + @AfterClass + public static void destroy() throws Exception { + if(domain != null) { + domain.close(); + } + } + + @Test + public void testPing() throws Exception { + new Socket("127.0.0.1", 8085); + System.in.read(); + } + + @Test + public void testNewsServicesGetAll() throws Exception { + List entries = newsService.getAll(); + + Assert.assertNotNull(entries); + Assert.assertTrue(entries.size() > 0); + + for(Entry entry : entries) { + System.out.println(">>> Entry - " + ((Item)entry.getData()).getTitle()); + } + } + + @Test + public void testNewsServicesGet() throws Exception { + Item item = newsService.get("1"); + + Assert.assertNotNull(item); + System.out.println(">>> Entry - " + item.getTitle()); + } +} diff --git a/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.composite b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.composite new file mode 100644 index 0000000000..f3a3b165cc --- /dev/null +++ b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.wsdl b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.wsdl new file mode 100644 index 0000000000..62d46e66c9 --- /dev/null +++ b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.wsdl @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.xsd b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.xsd new file mode 100644 index 0000000000..0a59f9311e --- /dev/null +++ b/branches/sca-java-1.x/itest/atom/src/test/resources/news/news.xsd @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3