Source Code Cross Referenced for EnterpriseUnixFTPEntryParserTest.java in  » Net » Apache-commons-net-1.4.1 » org » apache » commons » net » ftp » parser » 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 » Apache commons net 1.4.1 » org.apache.commons.net.ftp.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2005 The Apache Software Foundation
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.commons.net.ftp.parser;
017:
018:        import java.util.Calendar;
019:
020:        import junit.framework.TestSuite;
021:
022:        import org.apache.commons.net.ftp.FTPFile;
023:        import org.apache.commons.net.ftp.FTPFileEntryParser;
024:
025:        /**
026:         * Tests the EnterpriseUnixFTPEntryParser
027:         *
028:         * @version $Id: EnterpriseUnixFTPEntryParserTest.java 165675 2005-05-02 20:09:55Z rwinston $
029:         * @author <a href="mailto:Winston.Ojeda@qg.com">Winston Ojeda</a>
030:         */
031:        public class EnterpriseUnixFTPEntryParserTest extends
032:                FTPParseTestFramework {
033:
034:            private static final String[] BADSAMPLES = {
035:                    "zrwxr-xr-x   2 root     root         4096 Mar  2 15:13 zxbox",
036:                    "dxrwr-xr-x   2 root     root         4096 Aug 24  2001 zxjdbc",
037:                    "drwxr-xr-x   2 root     root         4096 Jam  4 00:03 zziplib",
038:                    "drwxr-xr-x   2 root     99           4096 Feb 23 30:01 zzplayer",
039:                    "drwxr-xr-x   2 root     root         4096 Aug 36  2001 zztpp",
040:                    "-rw-r--r--   1 14       staff       80284 Aug 22  zxJDBC-1.2.3.tar.gz",
041:                    "-rw-r--r--   1 14       staff      119:26 Aug 22  2000 zxJDBC-1.2.3.zip",
042:                    "-rw-r--r--   1 ftp      no group    83853 Jan 22  2001 zxJDBC-1.2.4.tar.gz",
043:                    "-rw-r--r--   1ftp       nogroup    126552 Jan 22  2001 zxJDBC-1.2.4.zip",
044:                    "-rw-r--r--   1 root     root       111325 Apr -7 18:79 zxJDBC-2.0.1b1.tar.gz",
045:                    "drwxr-xr-x   2 root     root         4096 Mar  2 15:13 zxbox",
046:                    "drwxr-xr-x 1 usernameftp 512 Jan 29 23:32 prog",
047:                    "drwxr-xr-x   2 root     root         4096 Aug 24  2001 zxjdbc",
048:                    "drwxr-xr-x   2 root     root         4096 Jan  4 00:03 zziplib",
049:                    "drwxr-xr-x   2 root     99           4096 Feb 23  2001 zzplayer",
050:                    "drwxr-xr-x   2 root     root         4096 Aug  6  2001 zztpp",
051:                    "-rw-r--r--   1 14       staff       80284 Aug 22  2000 zxJDBC-1.2.3.tar.gz",
052:                    "-rw-r--r--   1 14       staff      119926 Aug 22  2000 zxJDBC-1.2.3.zip",
053:                    "-rw-r--r--   1 ftp      nogroup     83853 Jan 22  2001 zxJDBC-1.2.4.tar.gz",
054:                    "-rw-r--r--   1 ftp      nogroup    126552 Jan 22  2001 zxJDBC-1.2.4.zip",
055:                    "-rw-r--r--   1 root     root       111325 Apr 27  2001 zxJDBC-2.0.1b1.tar.gz",
056:                    "-rw-r--r--   1 root     root       190144 Apr 27  2001 zxJDBC-2.0.1b1.zip" };
057:            private static final String[] GOODSAMPLES = {
058:                    "-C--E-----FTP B QUA1I1      18128       41 Aug 12 13:56 QUADTEST",
059:                    "-C--E-----FTP A QUA1I1      18128       41 Aug 12 13:56 QUADTEST2" };
060:
061:            /**
062:             * Creates a new EnterpriseUnixFTPEntryParserTest object.
063:             *
064:             * @param name Test name.
065:             */
066:            public EnterpriseUnixFTPEntryParserTest(String name) {
067:                super (name);
068:            }
069:
070:            /**
071:             * Method suite.
072:             *
073:             * @return TestSuite
074:             */
075:            public static TestSuite suite() {
076:
077:                return (new TestSuite(EnterpriseUnixFTPEntryParserTest.class));
078:            }
079:
080:            /**
081:             * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
082:             */
083:            public void testParseFieldsOnDirectory() throws Exception {
084:                // Everything is a File for now.
085:            }
086:
087:            /**
088:             * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
089:             */
090:            public void testParseFieldsOnFile() throws Exception {
091:                FTPFile file = getParser()
092:                        .parseFTPEntry(
093:                                "-C--E-----FTP B QUA1I1      18128       5000000000 Aug 12 13:56 QUADTEST");
094:                Calendar today = Calendar.getInstance();
095:                int year = today.get(Calendar.YEAR);
096:
097:                assertTrue("Should be a file.", file.isFile());
098:                assertEquals("QUADTEST", file.getName());
099:                assertEquals(5000000000L, file.getSize());
100:                assertEquals("QUA1I1", file.getUser());
101:                assertEquals("18128", file.getGroup());
102:
103:                if (today.get(Calendar.MONTH) < Calendar.AUGUST)
104:                    --year;
105:
106:                Calendar timestamp = file.getTimestamp();
107:                assertEquals(year, timestamp.get(Calendar.YEAR));
108:                assertEquals(Calendar.AUGUST, timestamp.get(Calendar.MONTH));
109:                assertEquals(12, timestamp.get(Calendar.DAY_OF_MONTH));
110:                assertEquals(13, timestamp.get(Calendar.HOUR_OF_DAY));
111:                assertEquals(56, timestamp.get(Calendar.MINUTE));
112:                assertEquals(0, timestamp.get(Calendar.SECOND));
113:
114:                checkPermisions(file);
115:            }
116:
117:            /**
118:             * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
119:             */
120:            protected String[] getBadListing() {
121:
122:                return (BADSAMPLES);
123:            }
124:
125:            /**
126:             * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
127:             */
128:            protected String[] getGoodListing() {
129:
130:                return (GOODSAMPLES);
131:            }
132:
133:            /**
134:             * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
135:             */
136:            protected FTPFileEntryParser getParser() {
137:
138:                return (new EnterpriseUnixFTPEntryParser());
139:            }
140:
141:            /**
142:             * Method checkPermisions. Verify that the parser does NOT  set the
143:             * permissions.
144:             *
145:             * @param dir
146:             */
147:            private void checkPermisions(FTPFile dir) {
148:                assertTrue("Owner should not have read permission.", !dir
149:                        .hasPermission(FTPFile.USER_ACCESS,
150:                                FTPFile.READ_PERMISSION));
151:                assertTrue("Owner should not have write permission.", !dir
152:                        .hasPermission(FTPFile.USER_ACCESS,
153:                                FTPFile.WRITE_PERMISSION));
154:                assertTrue("Owner should not have execute permission.", !dir
155:                        .hasPermission(FTPFile.USER_ACCESS,
156:                                FTPFile.EXECUTE_PERMISSION));
157:                assertTrue("Group should not have read permission.", !dir
158:                        .hasPermission(FTPFile.GROUP_ACCESS,
159:                                FTPFile.READ_PERMISSION));
160:                assertTrue("Group should not have write permission.", !dir
161:                        .hasPermission(FTPFile.GROUP_ACCESS,
162:                                FTPFile.WRITE_PERMISSION));
163:                assertTrue("Group should not have execute permission.", !dir
164:                        .hasPermission(FTPFile.GROUP_ACCESS,
165:                                FTPFile.EXECUTE_PERMISSION));
166:                assertTrue("World should not have read permission.", !dir
167:                        .hasPermission(FTPFile.WORLD_ACCESS,
168:                                FTPFile.READ_PERMISSION));
169:                assertTrue("World should not have write permission.", !dir
170:                        .hasPermission(FTPFile.WORLD_ACCESS,
171:                                FTPFile.WRITE_PERMISSION));
172:                assertTrue("World should not have execute permission.", !dir
173:                        .hasPermission(FTPFile.WORLD_ACCESS,
174:                                FTPFile.EXECUTE_PERMISSION));
175:            }
176:        }
177:
178:        /* Emacs configuration
179:         * Local variables:        **
180:         * mode:             java  **
181:         * c-basic-offset:   4     **
182:         * indent-tabs-mode: nil   **
183:         * End:                    **
184:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.