Source Code Cross Referenced for TestChannelRegistry.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: TestChannelRegistry.java,v 1.12 2004/03/09 23:42:19 niko_schmuck Exp $
027:
028:        package de.nava.informa.utils;
029:
030:        import java.io.File;
031:        import java.util.Date;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:
036:        import de.nava.informa.core.ChannelIF;
037:        import de.nava.informa.impl.basic.ChannelBuilder;
038:
039:        public class TestChannelRegistry extends InformaTestCase {
040:
041:            private static Log logger = LogFactory
042:                    .getLog(InformaTestCase.class);
043:
044:            public TestChannelRegistry(String name) {
045:                super ("TestChannelRegistry", name);
046:            }
047:
048:            public void XXXtestCreate() throws Exception {
049:                ChannelRegistry reg = new ChannelRegistry(new ChannelBuilder());
050:                // first channel
051:                File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
052:                ChannelIF chA = reg.addChannel(inpFile.toURL(), 2, true);
053:                Date dateA = chA.getLastUpdated();
054:                assertNull("channel shouldn't be parsed now", dateA);
055:                // second channel
056:                inpFile = new File(getDataDir(), "pro-linux.rdf");
057:                ChannelIF chB = reg.addChannel(inpFile.toURL(), 2, true);
058:                // third channel
059:                inpFile = new File(getDataDir(), "snipsnap-org.rss");
060:                ChannelIF chC = reg.addChannel(inpFile.toURL(), 2, true);
061:                // some basic assertions
062:                assertEquals("channel exists", 3, reg.getChannels().size());
063:                assertTrue("channel A", reg.getChannels().contains(chA));
064:                assertTrue("channel B", reg.getChannels().contains(chB));
065:                assertTrue("channel C", reg.getChannels().contains(chC));
066:                logger.info("starting to sleep ...");
067:                try {
068:                    Thread.sleep(5000);
069:                } catch (InterruptedException e) {
070:                    logger.warn("Interrupted waiting thread");
071:                }
072:                logger.info("... stopped sleeping");
073:                // check that they are still active
074:                assertTrue("channel A active", reg.isActiveChannel(chA));
075:                assertTrue("channel B active", reg.isActiveChannel(chB));
076:                assertTrue("channel C active", reg.isActiveChannel(chC));
077:                // verify update
078:                assertNotNull(
079:                        "channel should have been updated in the meantime", chA
080:                                .getLastUpdated());
081:            }
082:
083:            public void testParseProblem() throws Exception {
084:                ChannelRegistry reg = new ChannelRegistry(new ChannelBuilder());
085:                reg.setAcceptNrOfErrors(1);
086:                // first channel
087:                File inpFile = new File(getDataDir(), "xmlhack-0.91.xml");
088:                File chFile = new File(getOutputDir(), "xmlhack-0.91.xml");
089:                synchronized (chFile) {
090:                    FileUtils.copyFile(inpFile, chFile);
091:                }
092:                ChannelIF chA = reg.addChannel(chFile.toURL(), 2 /* secs */,
093:                        true);
094:                // be sure channel is read in
095:                try {
096:                    Thread.sleep(2500);
097:                } catch (InterruptedException e) {
098:                    logger.warn("Interrupted waiting thread");
099:                }
100:                // some basic assertions
101:                assertEquals("channel exists", 1, reg.getChannels().size());
102:                assertTrue("channel A", reg.getChannels().contains(chA));
103:                UpdateChannelInfo info = reg.getUpdateInfo(chA);
104:                assertTrue("channel A active", reg.isActiveChannel(chA));
105:                assertNull("no exception", info.getLastException());
106:                assertEquals("NrProblems", 0, info.getNrProblemsOccurred());
107:                logger.info("deleting channel file");
108:                // simulate defect by deleting channel file
109:                synchronized (chFile) {
110:                    chFile.delete();
111:                }
112:                logger.info("starting to sleep ...");
113:                try {
114:                    // while we are sleep a new update should detect the lack of the file
115:                    Thread.sleep(2500);
116:                } catch (InterruptedException e) {
117:                    logger.warn("Interrupted waiting thread");
118:                }
119:                logger.info("... stopped sleeping");
120:                // check that it's not any longer active
121:                info = reg.getUpdateInfo(chA);
122:                assertTrue("channel A should be deactive", !reg
123:                        .isActiveChannel(chA));
124:                logger.debug("exception: " + info.getLastException());
125:                assertNotNull("Exception", info.getLastException());
126:                assertEquals("NrProblems", 1, info.getNrProblemsOccurred());
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.