Source Code Cross Referenced for FeedsMetaDataServiceTest.java in  » Report » openi » org » openi » feeds » ws » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » openi » org.openi.feeds.ws 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*********************************************************************************
002:         * The contents of this file are subject to the OpenI Public License Version 1.0
003:         * ("License"); You may not use this file except in compliance with the
004:         * License. You may obtain a copy of the License at
005:         * http://www.openi.org/docs/LICENSE.txt
006:         *
007:         * Software distributed under the License is distributed on an "AS IS" basis,
008:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009:         * the specific language governing rights and limitations under the License.
010:         *
011:         * The Original Code is: OpenI Open Source
012:         *
013:         * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
014:         * Portions created by Loyalty Matrix, Inc. are
015:         * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
016:         *
017:         * Contributor(s): i18n : Pedro Casals Fradera (2006/05/16)
018:         *
019:         ********************************************************************************/package org.openi.feeds.ws;
020:
021:        import java.util.ArrayList;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:
026:        import junit.framework.TestCase;
027:
028:        import org.apache.log4j.Logger;
029:        import org.openi.feeds.FeedsMetaData;
030:        import org.openi.feeds.ws.FeedsMetaDataService;
031:        import org.openi.feeds.ws.FeedsMetaDataServiceImpl;
032:        import org.openi.feeds.ws.config.FeedsConfig;
033:
034:        /**
035:         * @author Dipendra Pokhrel <br>
036:         *
037:         * test class for org.openi.feeds.ws.FeedsMetaDataService(web service)
038:         *
039:         */
040:        public class FeedsMetaDataServiceTest extends TestCase {
041:            private static Logger logger = Logger
042:                    .getLogger(FeedsMetaDataServiceTest.class);
043:
044:            public static String FEEDS_BASE_DIR = "C:/Tomcat 5.0/webapps/openi-projects";
045:            private FeedsMetaDataService service;
046:
047:            public FeedsMetaDataServiceTest() {
048:                FeedsConfig.getInstance().setBaseDir(FEEDS_BASE_DIR);
049:            }
050:
051:            protected void setUp() throws Exception {
052:                service = new FeedsMetaDataServiceImpl();
053:                super .setUp();
054:            }
055:
056:            protected void tearDown() throws Exception {
057:                super .tearDown();
058:            }
059:
060:            public void testFeedsConfig() throws Exception {
061:                logger.debug("testing config");
062:                assertEquals("Base dir is not equal", FeedsConfig.getInstance()
063:                        .getBaseDir(), FEEDS_BASE_DIR);
064:            }
065:
066:            /**
067:             * tests metadata lister method which resturna array of all metadadata object available under base dir
068:             */
069:            public void testListMetaData() throws Exception {
070:                logger.debug("testing listMetaData()");
071:                FeedsMetaData[] metadatas = service.listMetaData("");
072:                assertNotNull("listMetaData should not return null", metadatas);
073:            }
074:
075:            /**
076:             * tests listAll method which returns the tree map of all 
077:             * available feeds available under basedir filtered with extensions
078:             * 	 
079:             */
080:            public void testListAll() throws Exception {
081:                logger.debug("testing listAll()");
082:                Map treemap = service.listAll("", ".csv,.txt,.text");
083:                assertNotNull("ListAll should not return null", treemap);
084:                List all = new ArrayList();
085:                findFeedsForTesting(treemap, all);
086:                logger.debug("Found " + all.size() + " feeds");
087:            }
088:
089:            /**
090:             * tests listDir method which returns the tree map of all 
091:             * available files/folders available under specfied dir
092:             * 	 
093:             */
094:            public void testListDir() throws Exception {
095:                logger.debug("testing listDir() on root");
096:                Map treemap = service.listDir("", false, "");
097:                assertNotNull("ListAll should not return null", treemap);
098:                List all = new ArrayList();
099:                findFeedsForTesting(treemap, all);
100:                logger.debug("Found " + all.size() + " files");
101:            }
102:
103:            /**
104:             * tests Reparse method which parses the specified feed 
105:             * and  returns the parsed metadata
106:             */
107:            public void testReparse() throws Exception {
108:                logger.debug("testing reparse()");
109:                FeedsMetaData metadata = service.reparse((String) service
110:                        .listMetaData("")[0].getAttributes().get("path"));
111:                assertNotNull("metadata should not be null", metadata);
112:            }
113:
114:            private void findFeedsForTesting(Map treemap, List paths)
115:                    throws Exception {
116:                if (treemap == null)
117:                    return;
118:                for (Iterator iter = treemap.keySet().iterator(); iter
119:                        .hasNext();) {
120:                    String key = (String) iter.next();
121:                    if ("type".equals(key))
122:                        continue;
123:                    Map value = (Map) treemap.get(key);
124:                    if ("file".equals(value.get("type"))) {
125:                        paths.add(key);
126:                    } else if ("dir".equals(value.get("type"))) {
127:                        findFeedsForTesting(value, paths);
128:                    }
129:                }
130:            }
131:
132:            /**
133:             * tests parse method which parses the specified feed based 
134:             * on delimeter and samplesize provided in specified metadata
135:             * and returns parsed metadata object	 
136:             */
137:            public void testParse() throws Exception {
138:                logger.debug("testing parse()");
139:                logger.debug("searching a feed to test");
140:                Map treemap = service.listAll("", ".csv,.txt,.text");
141:                List all = new ArrayList();
142:                findFeedsForTesting(treemap, all);
143:                String afeed = "";
144:                if (all.size() != 0) {
145:                    afeed = (String) all.iterator().next();
146:                    logger.debug("found feed :" + afeed);
147:                } else {
148:                    logger
149:                            .debug("could not find any feed to test under base dir "
150:                                    + FEEDS_BASE_DIR);
151:                    return;
152:                }
153:                FeedsMetaData metadata = new FeedsMetaData();
154:                metadata.setDelimeter(",");
155:                metadata.setSampleSize(-1);
156:                metadata = service.parse(afeed, metadata);
157:                assertNotNull("metadata should not be null", metadata);
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.