Source Code Cross Referenced for JobManagerTest.java in  » Net » DrFTPD » net » sf » drftpd » mirroring » 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 » Net » DrFTPD » net.sf.drftpd.mirroring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of DrFTPD, Distributed FTP Daemon.
003:         *
004:         * DrFTPD is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * DrFTPD is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU General Public License
015:         * along with DrFTPD; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package net.sf.drftpd.mirroring;
019:
020:        import java.io.IOException;
021:        import java.rmi.RemoteException;
022:        import java.util.ArrayList;
023:        import java.util.Collection;
024:        import java.util.HashSet;
025:        import java.util.Iterator;
026:        import java.util.Properties;
027:        import java.util.Set;
028:
029:        import junit.framework.TestCase;
030:        import net.sf.drftpd.NoAvailableSlaveException;
031:        import net.sf.drftpd.master.SlaveFileException;
032:
033:        import org.drftpd.master.ConnectionManager;
034:        import org.drftpd.master.RemoteSlave;
035:        import org.drftpd.remotefile.AbstractLinkedRemoteFile;
036:        import org.drftpd.remotefile.CaseInsensitiveHashtable;
037:        import org.drftpd.tests.DummyGlobalContext;
038:        import org.drftpd.tests.DummyRemoteSlave;
039:        import org.drftpd.tests.DummySlaveManager;
040:        import org.drftpd.tests.DummySlaveSelectionManager;
041:
042:        /**
043:         * @author zubov
044:         * @version $Id: JobManagerTest.java 1312 2005-10-14 18:38:37Z zubov $
045:         */
046:        public class JobManagerTest extends TestCase {
047:            private Properties p;
048:            LinkedRemoteFilePath file2;
049:            LinkedRemoteFilePath file;
050:
051:            /**
052:             * Constructor for JobManagerTest.
053:             * @param arg0
054:             */
055:            ConnectionManager _cm;
056:            JobManager _jm;
057:            private ArrayList<RemoteSlave> _slaveList;
058:
059:            public JobManagerTest(String arg0) throws IOException {
060:                super (arg0);
061:            }
062:
063:            public void setUp() throws RemoteException, SlaveFileException {
064:                DummyGlobalContext dgc = new DummyGlobalContext();
065:                //dgc.setSlaveManager(new DummySlaveManager(dgc));
066:
067:                DummyRemoteSlave rslave1 = new DummyRemoteSlave("slave1", dgc);
068:                DummyRemoteSlave rslave2 = new DummyRemoteSlave("slave2", dgc);
069:                DummyRemoteSlave rslave3 = new DummyRemoteSlave("slave3", dgc);
070:                _slaveList = new ArrayList<RemoteSlave>();
071:                _slaveList.add(rslave1);
072:                _slaveList.add(rslave2);
073:                _slaveList.add(rslave3);
074:                p = new Properties();
075:                _cm = new CM(p);
076:
077:                _cm.setGlobalContext(dgc);
078:                dgc.setConnectionManager(_cm);
079:
080:                DummySlaveManager dsm = null;
081:
082:                dsm = new DummySlaveManager(dgc);
083:
084:                dgc.setSlaveManager(dsm);
085:
086:                DummySlaveSelectionManager dssm = new DummySlaveSelectionManager();
087:                dgc.setSlaveSelectionManager(dssm);
088:                _jm = _cm.getGlobalContext().getJobManager();
089:                file = new LinkedRemoteFilePath("/path/file1.txt");
090:                file.addSlave(rslave1);
091:                file2 = new LinkedRemoteFilePath("/path/file2.txt");
092:                file2.addSlave(rslave2);
093:            }
094:
095:            public static void main(String[] args) {
096:                junit.textui.TestRunner.run(JobManagerTest.class);
097:            }
098:
099:            /*
100:             * Test for Job getNextJob(List)
101:             */
102:            public void testGetNextJobList() {
103:                HashSet slaveSet = new HashSet(_slaveList);
104:                Job job = new Job(file, slaveSet, 0, slaveSet.size());
105:                _jm.addJobToQueue(job);
106:
107:                Set usedSlaveList = new HashSet();
108:                Set skipJobs = new HashSet();
109:                assertSame(job, _jm.getNextJob(usedSlaveList, skipJobs));
110:                skipJobs.add(job);
111:                assertNull(_jm.getNextJob(usedSlaveList, skipJobs));
112:
113:                Job job2 = new Job(file2, slaveSet, 5, 2);
114:                _jm.addJobToQueue(job2);
115:                assertSame(job2, _jm.getNextJob(usedSlaveList, skipJobs));
116:                skipJobs.add(job2);
117:                assertNull(_jm.getNextJob(usedSlaveList, skipJobs));
118:                skipJobs.clear();
119:                usedSlaveList.addAll(_slaveList);
120:                assertNull(_jm.getNextJob(usedSlaveList, skipJobs));
121:            }
122:
123:            class CM extends ConnectionManager {
124:                CM(Properties p) {
125:                    p.put("master.bindname", "slavemanager");
126:                    p.put("master.bindport", "1099");
127:                    p.put("master.port", "2121");
128:                    p.put("master.localslave", "false");
129:                    p
130:                            .put("master.usermanager",
131:                                    "net.sf.drftpd.master.usermanager.jsx.JSXUserManager");
132:                    p
133:                            .put("slaveselection",
134:                                    "org.drftpd.slaveselection.def.SlaveSelectionManager");
135:                    p.put("sectionmanager",
136:                            "org.drftpd.sections.conf.SectionManager");
137:                    p.put("use.ident", "true");
138:                }
139:            }
140:
141:            public static class LinkedRemoteFilePath extends
142:                    AbstractLinkedRemoteFile {
143:                private String _path;
144:                private boolean isDeleted = false;
145:                private ArrayList slaves = new ArrayList();
146:
147:                public LinkedRemoteFilePath(String path) {
148:                    _path = path;
149:                }
150:
151:                public String getPath() {
152:                    return _path;
153:                }
154:
155:                public void addSlave(DummyRemoteSlave slave) {
156:                    slaves.add(slave);
157:                }
158:
159:                public void delete() {
160:                    isDeleted = true;
161:                }
162:
163:                public Collection getAvailableSlaves()
164:                        throws NoAvailableSlaveException {
165:                    if (getSlaves().isEmpty()) {
166:                        throw new NoAvailableSlaveException();
167:                    }
168:
169:                    return getSlaves();
170:                }
171:
172:                public Collection getSlaves() {
173:                    return slaves;
174:                }
175:
176:                public boolean isAvailable() {
177:                    return true;
178:                }
179:
180:                public boolean isDeleted() {
181:                    return isDeleted;
182:                }
183:
184:                public boolean removeSlave(DummyRemoteSlave slave) {
185:                    return slaves.remove(slave);
186:                }
187:
188:                public String toString() {
189:                    String string = "[file=" + getPath() + "][availableSlaves[";
190:
191:                    for (Iterator iter = this .getSlaves().iterator(); iter
192:                            .hasNext();) {
193:                        DummyRemoteSlave rslave = (DummyRemoteSlave) iter
194:                                .next();
195:                        string = string + rslave + ",";
196:                    }
197:
198:                    return string + "]]";
199:                }
200:
201:                public String getName() {
202:                    return _path;
203:                }
204:
205:                public void deleteOthers(Set destSlaves) {
206:                    // TODO Auto-generated method stub
207:                }
208:
209:                public void remerge(CaseInsensitiveHashtable lightRemoteFiles,
210:                        RemoteSlave rslave) throws IOException {
211:                    // TODO Auto-generated method stub
212:                }
213:
214:                public boolean isValid() {
215:                    return true;
216:                }
217:            }
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.