commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r633028 - in /commons/proper/net/trunk/src: java/org/apache/commons/net/ftp/parser/ java/org/apache/commons/net/tftp/ test/org/apache/commons/net/ftp/parser/ test/org/apache/commons/net/ntp/ test/org/apache/commons/net/tftp/ test/org/
Date Mon, 03 Mar 2008 13:22:50 GMT
On 03/03/2008, Niall Pemberton <niall.pemberton@gmail.com> wrote:
> On Mon, Mar 3, 2008 at 12:43 PM, sebb <sebbaz@gmail.com> wrote:
>  > On 03/03/2008, niallp@apache.org <niallp@apache.org> wrote:
>  >  > Author: niallp
>  >  >  Date: Mon Mar  3 02:22:57 2008
>  >  >  New Revision: 633028
>  >  >
>  >  >  URL: http://svn.apache.org/viewvc?rev=633028&view=rev
>  >  >  Log:
>  >  >  Set svn:eol-style and svn:keywords properties (no actual changes, may produce *noise*)
>  >
>  >  The eol-style noise can be avoided by performing the changes on the
>  >  appropriate OS ...
>
>
> The noise is only in the email message - looking at diffs in svn
>  history shows nothing:
>  http://svn.apache.org/viewvc/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java?view=log

However, the main oversight for commits is people reading the commit e-mails.

>  The real solution though is for people to configure the svn clients
>  properly to set the svn properties when they add artifacts to the repo

Agreed.

>  and using the appropriate OS is not IMO viable. I only have access to
>  one OS (windoze), but even if I had a spare machine with another OS
>  around (and svn installed and projects checked out on both) then

I use my login on p.a.o for fixing such things.

>  working out what line endings each file without the property set has
>  before going to the appropriate machine to committ is not something I
>  want to do or expect others to.

Though one could expect the original committer to fix the problem.

I know it's not ideal.
But nor is the effect it has on commit e-mails.

I'm not sure what the general solution is.

>  Niall
>
>
>  >  >  Modified:
>  >  >     commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java   (props changed)
>  >  >     commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java   (props changed)
>  >  >     commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPServer.java   (props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java   (contents, props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java   (contents, props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java   (contents, props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java   (contents, props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPServerPathTests.java   (props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPTests.java   (props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java   (contents, props changed)
>  >  >     commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java   (contents, props changed)
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPServer.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPServer.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -1,164 +1,164 @@
>  >  >  -/*
>  >  >  - * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  - * contributor license agreements.  See the NOTICE file distributed with
>  >  >  - * this work for additional information regarding copyright ownership.
>  >  >  - * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  - * (the "License"); you may not use this file except in compliance with
>  >  >  - * the License.  You may obtain a copy of the License at
>  >  >  - *
>  >  >  - *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  - *
>  >  >  - * Unless required by applicable law or agreed to in writing, software
>  >  >  - * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  - * See the License for the specific language governing permissions and
>  >  >  - * limitations under the License.
>  >  >  - */
>  >  >  -package org.apache.commons.net.ftp.parser;
>  >  >  -
>  >  >  -import java.text.SimpleDateFormat;
>  >  >  -import java.util.Calendar;
>  >  >  -import java.util.Date;
>  >  >  -
>  >  >  -import junit.framework.TestCase;
>  >  >  -
>  >  >  -import org.apache.commons.net.ftp.FTPClientConfig;
>  >  >  -import org.apache.commons.net.ftp.FTPFile;
>  >  >  -
>  >  >  -/**
>  >  >  - * This is a simple TestCase that tests entry parsing using the new FTPClientConfig
>  >  >  - * mechanism. The normal FTPClient cannot handle the different date formats in these
>  >  >  - * entries, however using a configurable format, we can handle it easily.
>  >  >  - *
>  >  >  - * The original system presenting this issue was an AIX system - see bug #27437 for details.
>  >  >  - *
>  >  >  - *  @version $Id$
>  >  >  - */
>  >  >  -public class FTPConfigEntryParserTest extends TestCase {
>  >  >  -
>  >  >  -       private SimpleDateFormat df = new SimpleDateFormat();
>  >  >  -
>  >  >  -       public void testParseFieldsOnAIX() {
>  >  >  -
>  >  >  -               // Set a date format for this server type
>  >  >  -               FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
>  >  >  -               config.setDefaultDateFormatStr("dd MMM HH:mm");
>  >  >  -
>  >  >  -               UnixFTPEntryParser parser = new UnixFTPEntryParser();
>  >  >  -               parser.configure(config);
>  >  >  -
>  >  >  -               FTPFile f = parser.parseFTPEntry("-rw-r-----   1 ravensm  sca          814 02 Mar 16:27 ZMIR2.m");
>  >  >  -
>  >  >  -               assertNotNull("Could not parse entry.", f);
>  >  >  -               assertFalse("Is not a directory.", f.isDirectory());
>  >  >  -
>  >  >  -               assertTrue("Should have user read permission.", f.hasPermission(
>  >  >  -                               FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertTrue("Should have user write permission.", f.hasPermission(
>  >  >  -                               FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertFalse("Should NOT have user execute permission.", f
>  >  >  -                               .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  -               assertTrue("Should have group read permission.", f.hasPermission(
>  >  >  -                               FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertFalse("Should NOT have group write permission.", f
>  >  >  -                               .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertFalse("Should NOT have group execute permission.",
>  >  >  -                               f.hasPermission(FTPFile.GROUP_ACCESS,
>  >  >  -                                               FTPFile.EXECUTE_PERMISSION));
>  >  >  -               assertFalse("Should NOT have world read permission.", f.hasPermission(
>  >  >  -                               FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertFalse("Should NOT have world write permission.", f
>  >  >  -                               .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertFalse("Should NOT have world execute permission.",
>  >  >  -                               f.hasPermission(FTPFile.WORLD_ACCESS,
>  >  >  -                                               FTPFile.EXECUTE_PERMISSION));
>  >  >  -
>  >  >  -               assertEquals(1, f.getHardLinkCount());
>  >  >  -
>  >  >  -               assertEquals("ravensm", f.getUser());
>  >  >  -               assertEquals("sca", f.getGroup());
>  >  >  -
>  >  >  -               assertEquals("ZMIR2.m", f.getName());
>  >  >  -               assertEquals(814, f.getSize());
>  >  >  -
>  >  >  -               Calendar cal = Calendar.getInstance();
>  >  >  -
>  >  >  -               Date refDate = new Date();
>  >  >  -
>  >  >  -               cal.set(Calendar.MONTH, Calendar.MARCH);
>  >  >  -               cal.set(Calendar.DATE, 2);
>  >  >  -               cal.set(Calendar.HOUR_OF_DAY, 16);
>  >  >  -               cal.set(Calendar.MINUTE, 27);
>  >  >  -               cal.set(Calendar.SECOND, 0);
>  >  >  -
>  >  >  -               // With no year specified, it defaults to 1970
>  >  >  -               // TODO this is probably a bug - it should default to the current year
>  >  >  -               cal.set(Calendar.YEAR, 1970);
>  >  >  -
>  >  >  -               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  -                               .getTime()));
>  >  >  -       }
>  >  >  -
>  >  >  -       /**
>  >  >  -        * This is a new format reported on the mailing lists. Parsing this kind of
>  >  >  -        * entry necessitated changing the regex in the parser.
>  >  >  -        *
>  >  >  -        */
>  >  >  -       public void testParseEntryWithSymlink() {
>  >  >  -
>  >  >  -               FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
>  >  >  -               config.setDefaultDateFormatStr("yyyy-MM-dd HH:mm");
>  >  >  -
>  >  >  -               UnixFTPEntryParser parser = new UnixFTPEntryParser();
>  >  >  -               parser.configure(config);
>  >  >  -
>  >  >  -               FTPFile f = parser.parseFTPEntry("lrwxrwxrwx   1 neeme neeme    23 2005-03-02 18:06 macros");
>  >  >  -
>  >  >  -               assertNotNull("Could not parse entry.", f);
>  >  >  -               assertFalse("Is not a directory.", f.isDirectory());
>  >  >  -               assertTrue("Is a symbolic link", f.isSymbolicLink());
>  >  >  -
>  >  >  -               assertTrue("Should have user read permission.", f.hasPermission(
>  >  >  -                               FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertTrue("Should have user write permission.", f.hasPermission(
>  >  >  -                               FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertTrue("Should have user execute permission.", f
>  >  >  -                               .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  -               assertTrue("Should have group read permission.", f.hasPermission(
>  >  >  -                               FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertTrue("Should have group write permission.", f
>  >  >  -                               .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertTrue("Should have group execute permission.",
>  >  >  -                               f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  -               assertTrue("Should have world read permission.", f.hasPermission(
>  >  >  -                               FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertTrue("Should have world write permission.", f
>  >  >  -                               .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -               assertTrue("Should have world execute permission.",
>  >  >  -                               f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  -
>  >  >  -               assertEquals(1, f.getHardLinkCount());
>  >  >  -
>  >  >  -               assertEquals("neeme", f.getUser());
>  >  >  -               assertEquals("neeme", f.getGroup());
>  >  >  -
>  >  >  -               assertEquals("macros", f.getName());
>  >  >  -               assertEquals(23, f.getSize());
>  >  >  -
>  >  >  -               Calendar cal = Calendar.getInstance();
>  >  >  -
>  >  >  -               Date refDate = new Date();
>  >  >  -
>  >  >  -               cal.set(Calendar.MONTH, Calendar.MARCH);
>  >  >  -               cal.set(Calendar.DATE, 2);
>  >  >  -               cal.set(Calendar.HOUR_OF_DAY, 18);
>  >  >  -               cal.set(Calendar.MINUTE, 06);
>  >  >  -               cal.set(Calendar.SECOND, 0);
>  >  >  -               cal.set(Calendar.YEAR, 2005);
>  >  >  -
>  >  >  -               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  -                               .getTime()));
>  >  >  -
>  >  >  -       }
>  >  >  -
>  >  >  -}
>  >  >  +/*
>  >  >  + * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  + * contributor license agreements.  See the NOTICE file distributed with
>  >  >  + * this work for additional information regarding copyright ownership.
>  >  >  + * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  + * (the "License"); you may not use this file except in compliance with
>  >  >  + * the License.  You may obtain a copy of the License at
>  >  >  + *
>  >  >  + *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  + *
>  >  >  + * Unless required by applicable law or agreed to in writing, software
>  >  >  + * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  + * See the License for the specific language governing permissions and
>  >  >  + * limitations under the License.
>  >  >  + */
>  >  >  +package org.apache.commons.net.ftp.parser;
>  >  >  +
>  >  >  +import java.text.SimpleDateFormat;
>  >  >  +import java.util.Calendar;
>  >  >  +import java.util.Date;
>  >  >  +
>  >  >  +import junit.framework.TestCase;
>  >  >  +
>  >  >  +import org.apache.commons.net.ftp.FTPClientConfig;
>  >  >  +import org.apache.commons.net.ftp.FTPFile;
>  >  >  +
>  >  >  +/**
>  >  >  + * This is a simple TestCase that tests entry parsing using the new FTPClientConfig
>  >  >  + * mechanism. The normal FTPClient cannot handle the different date formats in these
>  >  >  + * entries, however using a configurable format, we can handle it easily.
>  >  >  + *
>  >  >  + * The original system presenting this issue was an AIX system - see bug #27437 for details.
>  >  >  + *
>  >  >  + *  @version $Id$
>  >  >  + */
>  >  >  +public class FTPConfigEntryParserTest extends TestCase {
>  >  >  +
>  >  >  +       private SimpleDateFormat df = new SimpleDateFormat();
>  >  >  +
>  >  >  +       public void testParseFieldsOnAIX() {
>  >  >  +
>  >  >  +               // Set a date format for this server type
>  >  >  +               FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
>  >  >  +               config.setDefaultDateFormatStr("dd MMM HH:mm");
>  >  >  +
>  >  >  +               UnixFTPEntryParser parser = new UnixFTPEntryParser();
>  >  >  +               parser.configure(config);
>  >  >  +
>  >  >  +               FTPFile f = parser.parseFTPEntry("-rw-r-----   1 ravensm  sca          814 02 Mar 16:27 ZMIR2.m");
>  >  >  +
>  >  >  +               assertNotNull("Could not parse entry.", f);
>  >  >  +               assertFalse("Is not a directory.", f.isDirectory());
>  >  >  +
>  >  >  +               assertTrue("Should have user read permission.", f.hasPermission(
>  >  >  +                               FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertTrue("Should have user write permission.", f.hasPermission(
>  >  >  +                               FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertFalse("Should NOT have user execute permission.", f
>  >  >  +                               .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  +               assertTrue("Should have group read permission.", f.hasPermission(
>  >  >  +                               FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertFalse("Should NOT have group write permission.", f
>  >  >  +                               .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertFalse("Should NOT have group execute permission.",
>  >  >  +                               f.hasPermission(FTPFile.GROUP_ACCESS,
>  >  >  +                                               FTPFile.EXECUTE_PERMISSION));
>  >  >  +               assertFalse("Should NOT have world read permission.", f.hasPermission(
>  >  >  +                               FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertFalse("Should NOT have world write permission.", f
>  >  >  +                               .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertFalse("Should NOT have world execute permission.",
>  >  >  +                               f.hasPermission(FTPFile.WORLD_ACCESS,
>  >  >  +                                               FTPFile.EXECUTE_PERMISSION));
>  >  >  +
>  >  >  +               assertEquals(1, f.getHardLinkCount());
>  >  >  +
>  >  >  +               assertEquals("ravensm", f.getUser());
>  >  >  +               assertEquals("sca", f.getGroup());
>  >  >  +
>  >  >  +               assertEquals("ZMIR2.m", f.getName());
>  >  >  +               assertEquals(814, f.getSize());
>  >  >  +
>  >  >  +               Calendar cal = Calendar.getInstance();
>  >  >  +
>  >  >  +               Date refDate = new Date();
>  >  >  +
>  >  >  +               cal.set(Calendar.MONTH, Calendar.MARCH);
>  >  >  +               cal.set(Calendar.DATE, 2);
>  >  >  +               cal.set(Calendar.HOUR_OF_DAY, 16);
>  >  >  +               cal.set(Calendar.MINUTE, 27);
>  >  >  +               cal.set(Calendar.SECOND, 0);
>  >  >  +
>  >  >  +               // With no year specified, it defaults to 1970
>  >  >  +               // TODO this is probably a bug - it should default to the current year
>  >  >  +               cal.set(Calendar.YEAR, 1970);
>  >  >  +
>  >  >  +               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  +                               .getTime()));
>  >  >  +       }
>  >  >  +
>  >  >  +       /**
>  >  >  +        * This is a new format reported on the mailing lists. Parsing this kind of
>  >  >  +        * entry necessitated changing the regex in the parser.
>  >  >  +        *
>  >  >  +        */
>  >  >  +       public void testParseEntryWithSymlink() {
>  >  >  +
>  >  >  +               FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
>  >  >  +               config.setDefaultDateFormatStr("yyyy-MM-dd HH:mm");
>  >  >  +
>  >  >  +               UnixFTPEntryParser parser = new UnixFTPEntryParser();
>  >  >  +               parser.configure(config);
>  >  >  +
>  >  >  +               FTPFile f = parser.parseFTPEntry("lrwxrwxrwx   1 neeme neeme    23 2005-03-02 18:06 macros");
>  >  >  +
>  >  >  +               assertNotNull("Could not parse entry.", f);
>  >  >  +               assertFalse("Is not a directory.", f.isDirectory());
>  >  >  +               assertTrue("Is a symbolic link", f.isSymbolicLink());
>  >  >  +
>  >  >  +               assertTrue("Should have user read permission.", f.hasPermission(
>  >  >  +                               FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertTrue("Should have user write permission.", f.hasPermission(
>  >  >  +                               FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertTrue("Should have user execute permission.", f
>  >  >  +                               .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  +               assertTrue("Should have group read permission.", f.hasPermission(
>  >  >  +                               FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertTrue("Should have group write permission.", f
>  >  >  +                               .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertTrue("Should have group execute permission.",
>  >  >  +                               f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  +               assertTrue("Should have world read permission.", f.hasPermission(
>  >  >  +                               FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertTrue("Should have world write permission.", f
>  >  >  +                               .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +               assertTrue("Should have world execute permission.",
>  >  >  +                               f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
>  >  >  +
>  >  >  +               assertEquals(1, f.getHardLinkCount());
>  >  >  +
>  >  >  +               assertEquals("neeme", f.getUser());
>  >  >  +               assertEquals("neeme", f.getGroup());
>  >  >  +
>  >  >  +               assertEquals("macros", f.getName());
>  >  >  +               assertEquals(23, f.getSize());
>  >  >  +
>  >  >  +               Calendar cal = Calendar.getInstance();
>  >  >  +
>  >  >  +               Date refDate = new Date();
>  >  >  +
>  >  >  +               cal.set(Calendar.MONTH, Calendar.MARCH);
>  >  >  +               cal.set(Calendar.DATE, 2);
>  >  >  +               cal.set(Calendar.HOUR_OF_DAY, 18);
>  >  >  +               cal.set(Calendar.MINUTE, 06);
>  >  >  +               cal.set(Calendar.SECOND, 0);
>  >  >  +               cal.set(Calendar.YEAR, 2005);
>  >  >  +
>  >  >  +               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  +                               .getTime()));
>  >  >  +
>  >  >  +       }
>  >  >  +
>  >  >  +}
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -25,7 +25,7 @@
>  >  >   /**
>  >  >   * Created on Apr 6, 2005<br/>
>  >  >   * @author <a href="mailto:wnoto@openfinance.com">William Noto</a>
>  >  >  - * @version $Id: NTFTPEntryParserTest.java,v 1.16 2005/01/02 03:17:50 scohen Exp $
>  >  >  + * @version $Id$
>  >  >   */
>  >  >   public class MVSFTPEntryParserTest extends FTPParseTestFramework
>  >  >   {
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -1,130 +1,130 @@
>  >  >  -/*
>  >  >  - * Copyright 2001-2006 The Apache Software Foundation
>  >  >  - *
>  >  >  - * Licensed under the Apache License, Version 2.0 (the "License");
>  >  >  - * you may not use this file except in compliance with the License.
>  >  >  - * You may obtain a copy of the License at
>  >  >  - *
>  >  >  - *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  - *
>  >  >  - * Unless required by applicable law or agreed to in writing, software
>  >  >  - * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  - * See the License for the specific language governing permissions and
>  >  >  - * limitations under the License.
>  >  >  - */
>  >  >  -package org.apache.commons.net.ftp.parser;
>  >  >  -
>  >  >  -import java.util.Calendar;
>  >  >  -
>  >  >  -import junit.framework.TestSuite;
>  >  >  -
>  >  >  -import org.apache.commons.net.ftp.FTPFile;
>  >  >  -import org.apache.commons.net.ftp.FTPFileEntryParser;
>  >  >  -
>  >  >  -/**
>  >  >  - * @author <a href="mailto:rwinston@apache.org">Rory Winston</a>
>  >  >  - * @version $Id$
>  >  >  - */
>  >  >  -public class NetwareFTPEntryParserTest extends FTPParseTestFramework {
>  >  >  -
>  >  >  -       private static final String[] badsamples = {
>  >  >  -               "a [-----F--] SCION_SYS                         512 Apr 13 23:52 SYS",
>  >  >  -               "d [----AF--]          0                        512 10-04-2001 _ADMIN"
>  >  >  -       };
>  >  >  -
>  >  >  -       private static final String [] goodsamples = {
>  >  >  -       "d [-----F--] SCION_SYS                         512 Apr 13 23:52 SYS",
>  >  >  -       "d [----AF--]          0                        512 Feb 22 17:32 _ADMIN",
>  >  >  -       "d [-W---F--] SCION_VOL2                        512 Apr 13 23:12 VOL2",
>  >  >  -       "- [RWCEAFMS] rwinston                        19968 Mar 12 15:20 Executive Summary.doc",
>  >  >  -       "d [RWCEAFMS] rwinston                          512 Nov 24  2005 Favorites"
>  >  >  -    };
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see junit.framework.TestCase#TestCase(String)
>  >  >  -        */
>  >  >  -       public NetwareFTPEntryParserTest(String name) {
>  >  >  -               super(name);
>  >  >  -       }
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
>  >  >  -        */
>  >  >  -       protected String[] getBadListing() {
>  >  >  -               return (badsamples);
>  >  >  -       }
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
>  >  >  -        */
>  >  >  -       protected String[] getGoodListing() {
>  >  >  -               return (goodsamples);
>  >  >  -       }
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
>  >  >  -        */
>  >  >  -       protected FTPFileEntryParser getParser() {
>  >  >  -               return (new NetwareFTPEntryParser());
>  >  >  -       }
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
>  >  >  -        */
>  >  >  -
>  >  >  -       public void testParseFieldsOnDirectory() throws Exception {
>  >  >  -               String reply = "d [-W---F--] testUser                        512 Apr 13 23:12 testFile";
>  >  >  -               FTPFile f = getParser().parseFTPEntry(reply);
>  >  >  -
>  >  >  -               assertNotNull("Could not parse file", f);
>  >  >  -               assertEquals("testFile", f.getName());
>  >  >  -               assertEquals(512L, f.getSize());
>  >  >  -               assertEquals("testUser", f.getUser());
>  >  >  -               assertTrue("Directory flag is not set!", f.isDirectory());
>  >  >  -
>  >  >  -               Calendar cal = Calendar.getInstance();
>  >  >  -               cal.set(Calendar.MONTH, 3);
>  >  >  -               cal.set(Calendar.DAY_OF_MONTH, 13);
>  >  >  -               cal.set(Calendar.HOUR_OF_DAY, 23);
>  >  >  -               cal.set(Calendar.MINUTE, 12);
>  >  >  -               cal.set(Calendar.SECOND, 0);
>  >  >  -               cal.set(Calendar.MILLISECOND, 0);
>  >  >  -               cal.set(Calendar.YEAR, f.getTimestamp().get(Calendar.YEAR));
>  >  >  -
>  >  >  -               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  -                               .getTime()));
>  >  >  -
>  >  >  -       }
>  >  >  -
>  >  >  -
>  >  >  -       /**
>  >  >  -        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
>  >  >  -        */
>  >  >  -       public void testParseFieldsOnFile() throws Exception {
>  >  >  -               String reply = "- [R-CEAFMS] rwinston                        19968 Mar 12 15:20 Document name with spaces.doc";
>  >  >  -
>  >  >  -               FTPFile f = getParser().parseFTPEntry(reply);
>  >  >  -
>  >  >  -               assertNotNull("Could not parse file", f);
>  >  >  -               assertEquals("Document name with spaces.doc", f.getName());
>  >  >  -               assertEquals(19968L, f.getSize());
>  >  >  -               assertEquals("rwinston", f.getUser());
>  >  >  -               assertTrue("File flag is not set!", f.isFile());
>  >  >  -
>  >  >  -               assertTrue(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  -               assertFalse(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  -       }
>  >  >  -
>  >  >  -
>  >  >  -       /**
>  >  >  -        * Method suite.
>  >  >  -        * @return TestSuite
>  >  >  -        */
>  >  >  -       public static TestSuite suite() {
>  >  >  -               return (new TestSuite(NetwareFTPEntryParserTest.class));
>  >  >  -       }
>  >  >  -
>  >  >  -
>  >  >  -}
>  >  >  -
>  >  >  +/*
>  >  >  + * Copyright 2001-2006 The Apache Software Foundation
>  >  >  + *
>  >  >  + * Licensed under the Apache License, Version 2.0 (the "License");
>  >  >  + * you may not use this file except in compliance with the License.
>  >  >  + * You may obtain a copy of the License at
>  >  >  + *
>  >  >  + *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  + *
>  >  >  + * Unless required by applicable law or agreed to in writing, software
>  >  >  + * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  + * See the License for the specific language governing permissions and
>  >  >  + * limitations under the License.
>  >  >  + */
>  >  >  +package org.apache.commons.net.ftp.parser;
>  >  >  +
>  >  >  +import java.util.Calendar;
>  >  >  +
>  >  >  +import junit.framework.TestSuite;
>  >  >  +
>  >  >  +import org.apache.commons.net.ftp.FTPFile;
>  >  >  +import org.apache.commons.net.ftp.FTPFileEntryParser;
>  >  >  +
>  >  >  +/**
>  >  >  + * @author <a href="mailto:rwinston@apache.org">Rory Winston</a>
>  >  >  + * @version $Id$
>  >  >  + */
>  >  >  +public class NetwareFTPEntryParserTest extends FTPParseTestFramework {
>  >  >  +
>  >  >  +       private static final String[] badsamples = {
>  >  >  +               "a [-----F--] SCION_SYS                         512 Apr 13 23:52 SYS",
>  >  >  +               "d [----AF--]          0                        512 10-04-2001 _ADMIN"
>  >  >  +       };
>  >  >  +
>  >  >  +       private static final String [] goodsamples = {
>  >  >  +       "d [-----F--] SCION_SYS                         512 Apr 13 23:52 SYS",
>  >  >  +       "d [----AF--]          0                        512 Feb 22 17:32 _ADMIN",
>  >  >  +       "d [-W---F--] SCION_VOL2                        512 Apr 13 23:12 VOL2",
>  >  >  +       "- [RWCEAFMS] rwinston                        19968 Mar 12 15:20 Executive Summary.doc",
>  >  >  +       "d [RWCEAFMS] rwinston                          512 Nov 24  2005 Favorites"
>  >  >  +    };
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see junit.framework.TestCase#TestCase(String)
>  >  >  +        */
>  >  >  +       public NetwareFTPEntryParserTest(String name) {
>  >  >  +               super(name);
>  >  >  +       }
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
>  >  >  +        */
>  >  >  +       protected String[] getBadListing() {
>  >  >  +               return (badsamples);
>  >  >  +       }
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
>  >  >  +        */
>  >  >  +       protected String[] getGoodListing() {
>  >  >  +               return (goodsamples);
>  >  >  +       }
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
>  >  >  +        */
>  >  >  +       protected FTPFileEntryParser getParser() {
>  >  >  +               return (new NetwareFTPEntryParser());
>  >  >  +       }
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
>  >  >  +        */
>  >  >  +
>  >  >  +       public void testParseFieldsOnDirectory() throws Exception {
>  >  >  +               String reply = "d [-W---F--] testUser                        512 Apr 13 23:12 testFile";
>  >  >  +               FTPFile f = getParser().parseFTPEntry(reply);
>  >  >  +
>  >  >  +               assertNotNull("Could not parse file", f);
>  >  >  +               assertEquals("testFile", f.getName());
>  >  >  +               assertEquals(512L, f.getSize());
>  >  >  +               assertEquals("testUser", f.getUser());
>  >  >  +               assertTrue("Directory flag is not set!", f.isDirectory());
>  >  >  +
>  >  >  +               Calendar cal = Calendar.getInstance();
>  >  >  +               cal.set(Calendar.MONTH, 3);
>  >  >  +               cal.set(Calendar.DAY_OF_MONTH, 13);
>  >  >  +               cal.set(Calendar.HOUR_OF_DAY, 23);
>  >  >  +               cal.set(Calendar.MINUTE, 12);
>  >  >  +               cal.set(Calendar.SECOND, 0);
>  >  >  +               cal.set(Calendar.MILLISECOND, 0);
>  >  >  +               cal.set(Calendar.YEAR, f.getTimestamp().get(Calendar.YEAR));
>  >  >  +
>  >  >  +               assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
>  >  >  +                               .getTime()));
>  >  >  +
>  >  >  +       }
>  >  >  +
>  >  >  +
>  >  >  +       /**
>  >  >  +        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
>  >  >  +        */
>  >  >  +       public void testParseFieldsOnFile() throws Exception {
>  >  >  +               String reply = "- [R-CEAFMS] rwinston                        19968 Mar 12 15:20 Document name with spaces.doc";
>  >  >  +
>  >  >  +               FTPFile f = getParser().parseFTPEntry(reply);
>  >  >  +
>  >  >  +               assertNotNull("Could not parse file", f);
>  >  >  +               assertEquals("Document name with spaces.doc", f.getName());
>  >  >  +               assertEquals(19968L, f.getSize());
>  >  >  +               assertEquals("rwinston", f.getUser());
>  >  >  +               assertTrue("File flag is not set!", f.isFile());
>  >  >  +
>  >  >  +               assertTrue(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
>  >  >  +               assertFalse(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
>  >  >  +       }
>  >  >  +
>  >  >  +
>  >  >  +       /**
>  >  >  +        * Method suite.
>  >  >  +        * @return TestSuite
>  >  >  +        */
>  >  >  +       public static TestSuite suite() {
>  >  >  +               return (new TestSuite(NetwareFTPEntryParserTest.class));
>  >  >  +       }
>  >  >  +
>  >  >  +
>  >  >  +}
>  >  >  +
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -1,91 +1,91 @@
>  >  >  -/*
>  >  >  - * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  - * contributor license agreements.  See the NOTICE file distributed with
>  >  >  - * this work for additional information regarding copyright ownership.
>  >  >  - * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  - * (the "License"); you may not use this file except in compliance with
>  >  >  - * the License.  You may obtain a copy of the License at
>  >  >  - *
>  >  >  - *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  - *
>  >  >  - * Unless required by applicable law or agreed to in writing, software
>  >  >  - * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  - * See the License for the specific language governing permissions and
>  >  >  - * limitations under the License.
>  >  >  - */
>  >  >  -package org.apache.commons.net.ntp;
>  >  >  -
>  >  >  -import java.util.Date;
>  >  >  -import java.util.Calendar;
>  >  >  -import junit.framework.TestCase;
>  >  >  -import org.apache.commons.net.ntp.TimeStamp;
>  >  >  -
>  >  >  -/**
>  >  >  - * Test class that validates assertions for the basic TimeStamp operations and comparisons.
>  >  >  - *
>  >  >  - * @author Jason Mathews, MITRE Corp
>  >  >  - */
>  >  >  -public class TimeStampTest extends TestCase {
>  >  >  -
>  >  >  -    private static final String TIME1 = "c1a9ae1c.cf6ac48d";  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  -    private static final String TIME2 = "c1a9ae1c.cf6ac48f";  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  -    private static final String TIME3 = "c1a9ae1d.cf6ac48e";  // Tue, Dec 17 2002 14:07:25.810 UTC
>  >  >  -
>  >  >  -    /***
>  >  >  -     * main for running the test.
>  >  >  -     ***/
>  >  >  -    public static void main(String args[])
>  >  >  -    {
>  >  >  -        junit.textui.TestRunner.run(TimeStampTest.class);
>  >  >  -    }
>  >  >  -
>  >  >  -    public void testCompare() {
>  >  >  -
>  >  >  -        TimeStamp ts1 = new TimeStamp(TIME1);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  -        TimeStamp ts2 = new TimeStamp(TIME1);
>  >  >  -        TimeStamp ts3 = new TimeStamp(TIME2);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  -        TimeStamp ts4 = new TimeStamp(TIME3);  // Tue, Dec 17 2002 14:07:25.810 UTC
>  >  >  -
>  >  >  -        // do assertion tests on TimeStamp class
>  >  >  -        assertEquals("equals(1,2)", ts1, ts2);
>  >  >  -        assertTrue("compareTo(1,2)", ts1.compareTo(ts2) == 0);
>  >  >  -        assertEquals("ntpValue(1,2)", ts1.ntpValue(), ts2.ntpValue());
>  >  >  -        assertEquals("hashCode(1,2)", ts1.hashCode(), ts2.hashCode());
>  >  >  -        assertEquals("ts1==ts1", ts1, ts1);
>  >  >  -
>  >  >  -       // timestamps in ts1 (TIME1) and ts3 (TIME2) are only off by the smallest
>  >  >  -       // fraction of a second (~200 picoseconds) so the times are not equal but
>  >  >  -       // when converted to Java dates (in milliseconds) they will be equal.
>  >  >  -        assertTrue("ts1 != ts3", !ts1.equals(ts3));
>  >  >  -        assertTrue("compareTo(1,3)", ts1.compareTo(ts3) == -1);
>  >  >  -        assertEquals("seconds", ts1.getSeconds(), ts3.getSeconds());
>  >  >  -        assertTrue("fraction", ts1.getFraction() != ts3.getFraction());
>  >  >  -        assertTrue("ntpValue(1,3)", ts1.ntpValue() != ts3.ntpValue());
>  >  >  -        assertTrue("hashCode(1,3)", ts1.hashCode() != ts3.hashCode());
>  >  >  -        long time1 = ts1.getTime();
>  >  >  -        long time3 = ts3.getTime();
>  >  >  -        assertEquals("equals(time1,3)", time1, time3); // ntpTime1 != ntpTime3 but JavaTime(t1) == JavaTime(t3)...
>  >  >  -
>  >  >  -        assertTrue("ts3 != ts4", !ts3.equals(ts4));
>  >  >  -        assertTrue("time3 != ts4.time", time3 != ts4.getTime());
>  >  >  -    }
>  >  >  -
>  >  >  -    public void testUTCString() {
>  >  >  -        TimeStamp ts1 = new TimeStamp(TIME1);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  -       String actual = ts1.toUTCString();
>  >  >  -       assertEquals("Tue, Dec 17 2002 14:07:24.810 UTC", actual);
>  >  >  -    }
>  >  >  -
>  >  >  -    public void testDateConversion() {
>  >  >  -       // convert current date to NtpTimeStamp then compare Java date
>  >  >  -       // computed from NTP timestamp with original Java date.
>  >  >  -       Calendar refCal = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"));
>  >  >  -       Date refDate = refCal.getTime();
>  >  >  -       TimeStamp ts = new TimeStamp(refDate);
>  >  >  -       assertEquals("refDate.getTime()", refDate.getTime(), ts.getTime());
>  >  >  -       Date tsDate = ts.getDate();
>  >  >  -       assertEquals(refDate, tsDate);
>  >  >  -    }
>  >  >  -
>  >  >  -}
>  >  >  +/*
>  >  >  + * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  + * contributor license agreements.  See the NOTICE file distributed with
>  >  >  + * this work for additional information regarding copyright ownership.
>  >  >  + * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  + * (the "License"); you may not use this file except in compliance with
>  >  >  + * the License.  You may obtain a copy of the License at
>  >  >  + *
>  >  >  + *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  + *
>  >  >  + * Unless required by applicable law or agreed to in writing, software
>  >  >  + * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  + * See the License for the specific language governing permissions and
>  >  >  + * limitations under the License.
>  >  >  + */
>  >  >  +package org.apache.commons.net.ntp;
>  >  >  +
>  >  >  +import java.util.Date;
>  >  >  +import java.util.Calendar;
>  >  >  +import junit.framework.TestCase;
>  >  >  +import org.apache.commons.net.ntp.TimeStamp;
>  >  >  +
>  >  >  +/**
>  >  >  + * Test class that validates assertions for the basic TimeStamp operations and comparisons.
>  >  >  + *
>  >  >  + * @author Jason Mathews, MITRE Corp
>  >  >  + */
>  >  >  +public class TimeStampTest extends TestCase {
>  >  >  +
>  >  >  +    private static final String TIME1 = "c1a9ae1c.cf6ac48d";  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  +    private static final String TIME2 = "c1a9ae1c.cf6ac48f";  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  +    private static final String TIME3 = "c1a9ae1d.cf6ac48e";  // Tue, Dec 17 2002 14:07:25.810 UTC
>  >  >  +
>  >  >  +    /***
>  >  >  +     * main for running the test.
>  >  >  +     ***/
>  >  >  +    public static void main(String args[])
>  >  >  +    {
>  >  >  +        junit.textui.TestRunner.run(TimeStampTest.class);
>  >  >  +    }
>  >  >  +
>  >  >  +    public void testCompare() {
>  >  >  +
>  >  >  +        TimeStamp ts1 = new TimeStamp(TIME1);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  +        TimeStamp ts2 = new TimeStamp(TIME1);
>  >  >  +        TimeStamp ts3 = new TimeStamp(TIME2);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  +        TimeStamp ts4 = new TimeStamp(TIME3);  // Tue, Dec 17 2002 14:07:25.810 UTC
>  >  >  +
>  >  >  +        // do assertion tests on TimeStamp class
>  >  >  +        assertEquals("equals(1,2)", ts1, ts2);
>  >  >  +        assertTrue("compareTo(1,2)", ts1.compareTo(ts2) == 0);
>  >  >  +        assertEquals("ntpValue(1,2)", ts1.ntpValue(), ts2.ntpValue());
>  >  >  +        assertEquals("hashCode(1,2)", ts1.hashCode(), ts2.hashCode());
>  >  >  +        assertEquals("ts1==ts1", ts1, ts1);
>  >  >  +
>  >  >  +       // timestamps in ts1 (TIME1) and ts3 (TIME2) are only off by the smallest
>  >  >  +       // fraction of a second (~200 picoseconds) so the times are not equal but
>  >  >  +       // when converted to Java dates (in milliseconds) they will be equal.
>  >  >  +        assertTrue("ts1 != ts3", !ts1.equals(ts3));
>  >  >  +        assertTrue("compareTo(1,3)", ts1.compareTo(ts3) == -1);
>  >  >  +        assertEquals("seconds", ts1.getSeconds(), ts3.getSeconds());
>  >  >  +        assertTrue("fraction", ts1.getFraction() != ts3.getFraction());
>  >  >  +        assertTrue("ntpValue(1,3)", ts1.ntpValue() != ts3.ntpValue());
>  >  >  +        assertTrue("hashCode(1,3)", ts1.hashCode() != ts3.hashCode());
>  >  >  +        long time1 = ts1.getTime();
>  >  >  +        long time3 = ts3.getTime();
>  >  >  +        assertEquals("equals(time1,3)", time1, time3); // ntpTime1 != ntpTime3 but JavaTime(t1) == JavaTime(t3)...
>  >  >  +
>  >  >  +        assertTrue("ts3 != ts4", !ts3.equals(ts4));
>  >  >  +        assertTrue("time3 != ts4.time", time3 != ts4.getTime());
>  >  >  +    }
>  >  >  +
>  >  >  +    public void testUTCString() {
>  >  >  +        TimeStamp ts1 = new TimeStamp(TIME1);  // Tue, Dec 17 2002 14:07:24.810 UTC
>  >  >  +       String actual = ts1.toUTCString();
>  >  >  +       assertEquals("Tue, Dec 17 2002 14:07:24.810 UTC", actual);
>  >  >  +    }
>  >  >  +
>  >  >  +    public void testDateConversion() {
>  >  >  +       // convert current date to NtpTimeStamp then compare Java date
>  >  >  +       // computed from NTP timestamp with original Java date.
>  >  >  +       Calendar refCal = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"));
>  >  >  +       Date refDate = refCal.getTime();
>  >  >  +       TimeStamp ts = new TimeStamp(refDate);
>  >  >  +       assertEquals("refDate.getTime()", refDate.getTime(), ts.getTime());
>  >  >  +       Date tsDate = ts.getDate();
>  >  >  +       assertEquals(refDate, tsDate);
>  >  >  +    }
>  >  >  +
>  >  >  +}
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPServerPathTests.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPServerPathTests.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPTests.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/tftp/TFTPTests.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -1,135 +1,135 @@
>  >  >  -/*
>  >  >  - * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  - * contributor license agreements.  See the NOTICE file distributed with
>  >  >  - * this work for additional information regarding copyright ownership.
>  >  >  - * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  - * (the "License"); you may not use this file except in compliance with
>  >  >  - * the License.  You may obtain a copy of the License at
>  >  >  - *
>  >  >  - *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  - *
>  >  >  - * Unless required by applicable law or agreed to in writing, software
>  >  >  - * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  - * See the License for the specific language governing permissions and
>  >  >  - * limitations under the License.
>  >  >  - */
>  >  >  -package org.apache.commons.net.time;
>  >  >  -
>  >  >  -import java.net.InetAddress;
>  >  >  -import java.util.Calendar;
>  >  >  -import java.io.IOException;
>  >  >  -import java.util.TimeZone;
>  >  >  -
>  >  >  -import junit.framework.TestCase;
>  >  >  -import org.apache.commons.net.TimeTCPClient;
>  >  >  -
>  >  >  -public class TimeTCPClientTest extends TestCase
>  >  >  -{
>  >  >  -    private TimeTestSimpleServer server1;
>  >  >  -
>  >  >  -    private int _port = 3333; // default test port
>  >  >  -
>  >  >  -    /***
>  >  >  -     * main for running the test.
>  >  >  -     ***/
>  >  >  -    public static void main(String[] args)
>  >  >  -    {
>  >  >  -        junit.textui.TestRunner.run(TimeTCPClientTest.class);
>  >  >  -    }
>  >  >  -
>  >  >  -    /***
>  >  >  -     * open connections needed for the tests for the test.
>  >  >  -     ***/
>  >  >  -    protected void openConnections() throws Exception
>  >  >  -    {
>  >  >  -       try {
>  >  >  -            server1 = new TimeTestSimpleServer(_port);
>  >  >  -            server1.connect();
>  >  >  -       } catch (IOException ioe)
>  >  >  -       {
>  >  >  -           // try again on another port
>  >  >  -           _port = 4000;
>  >  >  -            server1 = new TimeTestSimpleServer(_port);
>  >  >  -            server1.connect();
>  >  >  -       }
>  >  >  -        server1.start();
>  >  >  -    }
>  >  >  -
>  >  >  -    /***
>  >  >  -     *  tests the constant basetime used by TimeClient against tha
>  >  >  -     *  computed from Calendar class.
>  >  >  -     */
>  >  >  -    public void testInitial() {
>  >  >  -        TimeZone utcZone = TimeZone.getTimeZone("UTC");
>  >  >  -        Calendar calendar = Calendar.getInstance(utcZone);
>  >  >  -        calendar.set(1900, Calendar.JANUARY, 1, 0, 0, 0);
>  >  >  -        calendar.set(Calendar.MILLISECOND, 0);
>  >  >  -        long baseTime = calendar.getTime().getTime() / 1000L;
>  >  >  -
>  >  >  -        assertTrue(baseTime == -TimeTCPClient.SECONDS_1900_TO_1970);
>  >  >  -    }
>  >  >  -
>  >  >  -    /***
>  >  >  -     * tests the times retrieved via the Time protocol implementation.
>  >  >  -     ***/
>  >  >  -    public void testCompareTimes() throws Exception
>  >  >  -    {
>  >  >  -        openConnections();
>  >  >  -
>  >  >  -        long time, time2;
>  >  >  -        long clientTime, clientTime2;
>  >  >  -        try
>  >  >  -        {
>  >  >  -            TimeTCPClient client = new TimeTCPClient();
>  >  >  -            try
>  >  >  -            {
>  >  >  -                // We want to timeout if a response takes longer than 60 seconds
>  >  >  -                client.setDefaultTimeout(60000);
>  >  >  -                client.connect(InetAddress.getLocalHost(), _port);
>  >  >  -                clientTime = client.getDate().getTime();
>  >  >  -                time = System.currentTimeMillis();
>  >  >  -            } finally
>  >  >  -            {
>  >  >  -              if(client.isConnected())
>  >  >  -                client.disconnect();
>  >  >  -            }
>  >  >  -
>  >  >  -            try
>  >  >  -            {
>  >  >  -                // We want to timeout if a response takes longer than 60 seconds
>  >  >  -                client.setDefaultTimeout(60000);
>  >  >  -                client.connect(InetAddress.getLocalHost(), _port);
>  >  >  -                clientTime2 = (client.getTime() - TimeTCPClient.SECONDS_1900_TO_1970)*1000L;
>  >  >  -                time2 = System.currentTimeMillis();
>  >  >  -            } finally
>  >  >  -            {
>  >  >  -              if(client.isConnected())
>  >  >  -                client.disconnect();
>  >  >  -            }
>  >  >  -
>  >  >  -        } finally
>  >  >  -        {
>  >  >  -            closeConnections();
>  >  >  -        }
>  >  >  -
>  >  >  -      // current time shouldn't differ from time reported via network by 5 seconds
>  >  >  -      assertTrue(Math.abs(time - clientTime) < 5000);
>  >  >  -      assertTrue(Math.abs(time2 - clientTime2) < 5000);
>  >  >  -    }
>  >  >  -
>  >  >  -    /***
>  >  >  -     * closes all the connections
>  >  >  -     ***/
>  >  >  -    protected void closeConnections()
>  >  >  -    {
>  >  >  -        try
>  >  >  -        {
>  >  >  -            server1.stop();
>  >  >  -            Thread.sleep(1000);
>  >  >  -        } catch (Exception e)
>  >  >  -        {
>  >  >  -        }
>  >  >  -    }
>  >  >  -}
>  >  >  -
>  >  >  +/*
>  >  >  + * Licensed to the Apache Software Foundation (ASF) under one or more
>  >  >  + * contributor license agreements.  See the NOTICE file distributed with
>  >  >  + * this work for additional information regarding copyright ownership.
>  >  >  + * The ASF licenses this file to You under the Apache License, Version 2.0
>  >  >  + * (the "License"); you may not use this file except in compliance with
>  >  >  + * the License.  You may obtain a copy of the License at
>  >  >  + *
>  >  >  + *     http://www.apache.org/licenses/LICENSE-2.0
>  >  >  + *
>  >  >  + * Unless required by applicable law or agreed to in writing, software
>  >  >  + * distributed under the License is distributed on an "AS IS" BASIS,
>  >  >  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  >  >  + * See the License for the specific language governing permissions and
>  >  >  + * limitations under the License.
>  >  >  + */
>  >  >  +package org.apache.commons.net.time;
>  >  >  +
>  >  >  +import java.net.InetAddress;
>  >  >  +import java.util.Calendar;
>  >  >  +import java.io.IOException;
>  >  >  +import java.util.TimeZone;
>  >  >  +
>  >  >  +import junit.framework.TestCase;
>  >  >  +import org.apache.commons.net.TimeTCPClient;
>  >  >  +
>  >  >  +public class TimeTCPClientTest extends TestCase
>  >  >  +{
>  >  >  +    private TimeTestSimpleServer server1;
>  >  >  +
>  >  >  +    private int _port = 3333; // default test port
>  >  >  +
>  >  >  +    /***
>  >  >  +     * main for running the test.
>  >  >  +     ***/
>  >  >  +    public static void main(String[] args)
>  >  >  +    {
>  >  >  +        junit.textui.TestRunner.run(TimeTCPClientTest.class);
>  >  >  +    }
>  >  >  +
>  >  >  +    /***
>  >  >  +     * open connections needed for the tests for the test.
>  >  >  +     ***/
>  >  >  +    protected void openConnections() throws Exception
>  >  >  +    {
>  >  >  +       try {
>  >  >  +            server1 = new TimeTestSimpleServer(_port);
>  >  >  +            server1.connect();
>  >  >  +       } catch (IOException ioe)
>  >  >  +       {
>  >  >  +           // try again on another port
>  >  >  +           _port = 4000;
>  >  >  +            server1 = new TimeTestSimpleServer(_port);
>  >  >  +            server1.connect();
>  >  >  +       }
>  >  >  +        server1.start();
>  >  >  +    }
>  >  >  +
>  >  >  +    /***
>  >  >  +     *  tests the constant basetime used by TimeClient against tha
>  >  >  +     *  computed from Calendar class.
>  >  >  +     */
>  >  >  +    public void testInitial() {
>  >  >  +        TimeZone utcZone = TimeZone.getTimeZone("UTC");
>  >  >  +        Calendar calendar = Calendar.getInstance(utcZone);
>  >  >  +        calendar.set(1900, Calendar.JANUARY, 1, 0, 0, 0);
>  >  >  +        calendar.set(Calendar.MILLISECOND, 0);
>  >  >  +        long baseTime = calendar.getTime().getTime() / 1000L;
>  >  >  +
>  >  >  +        assertTrue(baseTime == -TimeTCPClient.SECONDS_1900_TO_1970);
>  >  >  +    }
>  >  >  +
>  >  >  +    /***
>  >  >  +     * tests the times retrieved via the Time protocol implementation.
>  >  >  +     ***/
>  >  >  +    public void testCompareTimes() throws Exception
>  >  >  +    {
>  >  >  +        openConnections();
>  >  >  +
>  >  >  +        long time, time2;
>  >  >  +        long clientTime, clientTime2;
>  >  >  +        try
>  >  >  +        {
>  >  >  +            TimeTCPClient client = new TimeTCPClient();
>  >  >  +            try
>  >  >  +            {
>  >  >  +                // We want to timeout if a response takes longer than 60 seconds
>  >  >  +                client.setDefaultTimeout(60000);
>  >  >  +                client.connect(InetAddress.getLocalHost(), _port);
>  >  >  +                clientTime = client.getDate().getTime();
>  >  >  +                time = System.currentTimeMillis();
>  >  >  +            } finally
>  >  >  +            {
>  >  >  +              if(client.isConnected())
>  >  >  +                client.disconnect();
>  >  >  +            }
>  >  >  +
>  >  >  +            try
>  >  >  +            {
>  >  >  +                // We want to timeout if a response takes longer than 60 seconds
>  >  >  +                client.setDefaultTimeout(60000);
>  >  >  +                client.connect(InetAddress.getLocalHost(), _port);
>  >  >  +                clientTime2 = (client.getTime() - TimeTCPClient.SECONDS_1900_TO_1970)*1000L;
>  >  >  +                time2 = System.currentTimeMillis();
>  >  >  +            } finally
>  >  >  +            {
>  >  >  +              if(client.isConnected())
>  >  >  +                client.disconnect();
>  >  >  +            }
>  >  >  +
>  >  >  +        } finally
>  >  >  +        {
>  >  >  +            closeConnections();
>  >  >  +        }
>  >  >  +
>  >  >  +      // current time shouldn't differ from time reported via network by 5 seconds
>  >  >  +      assertTrue(Math.abs(time - clientTime) < 5000);
>  >  >  +      assertTrue(Math.abs(time2 - clientTime2) < 5000);
>  >  >  +    }
>  >  >  +
>  >  >  +    /***
>  >  >  +     * closes all the connections
>  >  >  +     ***/
>  >  >  +    protected void closeConnections()
>  >  >  +    {
>  >  >  +        try
>  >  >  +        {
>  >  >  +            server1.stop();
>  >  >  +            Thread.sleep(1000);
>  >  >  +        } catch (Exception e)
>  >  >  +        {
>  >  >  +        }
>  >  >  +    }
>  >  >  +}
>  >  >  +
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >  Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java
>  >  >  URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java?rev=633028&r1=633027&r2=633028&view=diff
>  >  >  ==============================================================================
>  >  >  --- commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java (original)
>  >  >  +++ commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java Mon Mar  3 02:22:57 2008
>  >  >  @@ -35,7 +35,7 @@
>  >  >   *
>  >  >   * @author Jason Mathews, MITRE Corporation
>  >  >   *
>  >  >  - * @version $Revision: 1.1 $ $Date: 2003/09/24 21:51:48 $
>  >  >  + * @version $Revision$ $Date$
>  >  >   */
>  >  >   public class TimeTestSimpleServer implements Runnable
>  >  >   {
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:eol-style = native
>  >  >
>  >  >  Propchange: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java
>  >  >  ------------------------------------------------------------------------------
>  >  >     svn:keywords = Date Author Id Revision HeadURL
>  >  >
>  >  >
>  >  >
>  >
>
> >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  >  For additional commands, e-mail: dev-help@commons.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message