Source Code Cross Referenced for InformaTestCase.java in  » RSS-RDF » informa » de » nava » informa » utils » 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 » RSS RDF » informa » de.nava.informa.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Informa -- RSS Library for Java
003:        // Copyright (c) 2002-2003 by Niko Schmuck
004:        //
005:        // Niko Schmuck
006:        // http://sourceforge.net/projects/informa
007:        // mailto:niko_schmuck@users.sourceforge.net
008:        //
009:        // This library is free software.
010:        //
011:        // You may redistribute it and/or modify it under the terms of the GNU
012:        // Lesser General Public License as published by the Free Software Foundation.
013:        //
014:        // Version 2.1 of the license should be included with this distribution in
015:        // the file LICENSE. If the license is not included with this distribution,
016:        // you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
017:        // or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge, 
018:        // MA 02139 USA.
019:        //
020:        // This library is distributed in the hope that it will be useful,
021:        // but WITHOUT ANY WARRANTY; without even the implied waranty of
022:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023:        // Lesser General Public License for more details.
024:        //
025:
026:        // $Id: InformaTestCase.java,v 1.14 2004/05/21 11:26:54 niko_schmuck Exp $
027:
028:        package de.nava.informa.utils;
029:
030:        import java.io.File;
031:        import java.util.Iterator;
032:
033:        import junit.framework.TestCase;
034:
035:        import org.apache.commons.logging.Log;
036:        import org.apache.commons.logging.LogFactory;
037:
038:        import de.nava.informa.core.ChannelIF;
039:        import de.nava.informa.core.ItemIF;
040:
041:        /**
042:         * Base class for unit tests of the informa library. It provides some 
043:         * convenience methods for easy data file retrieval.
044:         * 
045:         * @author Niko Schmuck
046:         */
047:        public class InformaTestCase extends TestCase {
048:
049:            private static Log logger = LogFactory
050:                    .getLog(InformaTestCase.class);
051:
052:            protected final static String FS = System
053:                    .getProperty("file.separator");
054:            protected static String dataDir;
055:            protected static String indexDir;
056:            protected static String outputDir;
057:            protected static String baselineDir;
058:
059:            protected String testcase_name;
060:            protected String method_name;
061:
062:            static {
063:                // fall-back mechanism to get the base directory
064:                String baseDir = System.getProperty("INFORMA_HOME");
065:                logger.debug("retrieving property INFORMA_HOME: " + baseDir);
066:                if (baseDir == null) {
067:                    baseDir = System.getProperty("basedir");
068:                    logger.debug("retrieving property basedir: " + baseDir);
069:                }
070:                if (baseDir == null) {
071:                    baseDir = System.getProperty("user.dir");
072:                    logger.debug("retrieving property user.dir: " + baseDir);
073:                }
074:                // calculate other dirs from this
075:                String writeDir = baseDir + FS + "build" + FS + "test" + FS
076:                        + "data";
077:                indexDir = writeDir + FS + "index";
078:                outputDir = writeDir + FS + "out";
079:                // the output directory is only used to write files generated by test
080:                // cases and may therefore not exist yet
081:                File out = new File(outputDir);
082:                if (!out.exists()) {
083:                    out.mkdirs();
084:                }
085:                // Those directories are only used in read-only mode
086:                String refDir = baseDir + FS + "test";
087:                dataDir = refDir + FS + "data";
088:                baselineDir = refDir + FS + "baseline";
089:            }
090:
091:            /**
092:             * Constructor for a new informa specific test case. The base directory
093:             * is calculated from one of the following system properties (order matters):
094:             * <code>INFORMA_HOME, basedir, user.dir</code>
095:             * 
096:             * @param name the name of the test case (read method, thanks JUnit)
097:             */
098:            public InformaTestCase(String testcase_name, String method_name) {
099:                super (method_name);
100:                this .method_name = method_name;
101:                this .testcase_name = testcase_name;
102:            }
103:
104:            /**
105:             * @return The directory from which we can retrieve test relevant data.
106:             */
107:            public static String getDataDir() {
108:                return dataDir;
109:            }
110:
111:            /**
112:             * @return The directory to store the full-text index in.
113:             */
114:            public static String getIndexDir() {
115:                return indexDir;
116:            }
117:
118:            /**
119:             * @return The directory where our test might want to write a produced
120:             *         file to.
121:             */
122:            public static String getOutputDir() {
123:                return outputDir;
124:            }
125:
126:            /**
127:             * @return The directory containing the gold files to compare the 
128:             *         files generated by the current test runs with.
129:             */
130:            public static String getBaselineDir() {
131:                return baselineDir;
132:            }
133:
134:            /**
135:             * Returns the name of the testcase inclusive the class.
136:             */
137:            public String getName() {
138:                return testcase_name + "." + method_name;
139:            }
140:
141:            // =====================================================================
142:            // internal helper methods
143:            // =====================================================================
144:
145:            protected ItemIF searchForItem(ChannelIF chn, String itmTitle) {
146:                ItemIF lookup_item = null;
147:                Iterator it = chn.getItems().iterator();
148:                while (it.hasNext()) {
149:                    ItemIF item = (ItemIF) it.next();
150:                    assertNotNull("Item has no title", item.getTitle());
151:                    assertNotNull("Item has no link", item.getLink());
152:                    // logger.debug("title: <" + item.getTitle() + ">");
153:                    if (item.getTitle().startsWith(itmTitle)) {
154:                        lookup_item = item;
155:                        break;
156:                    }
157:                }
158:                return lookup_item;
159:            }
160:
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.