You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Eric Pugh <ep...@upstate.com> on 2004/06/23 09:53:06 UTC

[vfs] running unit tests for Http provider

Hi,

I wanted to look into using VFS in a project.  I downloaded it and tried out
the unit tests.  I am getting quite a few unit test failures, revolving
around the fact that I am missing test.hostname and test.path.

In order to run the unittests (specifially for the http provider) what kind
of http website do I need?  I believe it is a readonly provider, right?  I
tried doing this:

test.hostname=www.ibiblio.org
test.path=/maven

But now it fails on not finding a directory www.ibiblio.rog/maven/read-data.
Is it possible to a) Stick up docs on how to build and run the unit tests w/
what exteranal dependencies there are.  b) change the unit tests so that if
we are donig a readonly test, we could maybe point to files or something
that are on a public website, like maybe the VFS website?

Eric


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


RE: [vfs] running unit tests for Http provider

Posted by Eric Pugh <ep...@upstate.com>.
I would love to try out uml-linux..  Unfortunantly I'm a windows user who
has just dipped his toe in linux waters, so it'll be a while until I'm up to
running uml-linux.

Eric

> -----Original Message-----
> From: Mario Ivankovits [mailto:imario@apache.org]
> Sent: Wednesday, June 23, 2004 11:56 AM
> To: Jakarta Commons Developers List
> Subject: Re: [vfs] running unit tests for Http provider
>
>
> Eric Pugh wrote:
>
> >Something that
> >could be an approach would be to have two modes:  Real and Mock..
> >
> >
> Well, i use the local file provider to test if i do global changes on
> vfs, it is easy to setup and the core of vfs is tested well.
> For this, and if i have problems with a special filesystem i use a
> RunTest class.
>
> If this test passes, i startup my uml-linux and trigger the whole test
> chain.
>
> >But again, if you have a system, then that works..
> >
> >
> And never ever there should be a commit to vfs without testing the
> change against this system using ALL filesystems.
>
> If you are interested in this uml-linux server, just drop me a note.
>
>
> ---RunTest---
> package org.apache.commons.vfs.test;
>
> import junit.framework.AssertionFailedError;
> import junit.framework.Test;
> import junit.framework.TestResult;
> import org.apache.commons.vfs.provider.webdav.test.WebdavProviderTestCase;
>
> import java.util.Properties;
>
> public class RunTest
> {
>     public static void main(String[] args) throws Exception
>     {
>         Properties props = System.getProperties();
>         props.setProperty("test.data.src", "src/test-data");
>         props.setProperty("test.basedir", "target/test-data");
>         props.setProperty("test.policy", "src/test-data/test.policy");
>         props.setProperty("test.secure", "false");
>         props.setProperty("test.smb.uri",
> "smb://vfsusr:vfsusr@vfstest/vfsusr/vfstest");
>         props.setProperty("test.ftp.uri",
> "ftp://vfsusr:vfsusr@vfstest/vfstest");
>         props.setProperty("test.http.uri", "http://vfstest/vfstest");
>
>         props.setProperty("test.webdav.uri",
> "webdav://vfsusr:vfsusr@vfstest/vfstest");
>
>         props.setProperty("test.sftp.uri",
> "sftp://vfsusr:vfsusr@vfstest/home/vfsusr/vfstest");
>
>         Test test;
>         // test = FtpProviderTestCase.suite();
>         // test = HttpProviderTestCase.suite();
>         // test = LocalProviderTestCase.suite();
>         // test = JarProviderTestCase.suite();
>         // test = ZipProviderTestCase.suite();
>         // test = TemporaryProviderTestCase.suite();
>         test = WebdavProviderTestCase.suite();
>         // test = UrlProviderTestCase.suite();
>
>         // test = SmbProviderTestCase.suite();
>
>         // test = SftpProviderTestCase.suite();
>
>         TestResult result = new TestResult()
>         {
>             public synchronized void addError(Test test, Throwable
> throwable)
>             {
>                 throwable.printStackTrace();
>             }
>
>             public synchronized void addFailure(Test test,
> AssertionFailedError assertionFailedError)
>             {
>                 assertionFailedError.printStackTrace();
>             }
>         };
>         test.run(result);
>     }
> }
> ---RunTest---
>
> --
> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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


Re: [vfs] running unit tests for Http provider

Posted by Mario Ivankovits <im...@apache.org>.
Eric Pugh wrote:

>Something that
>could be an approach would be to have two modes:  Real and Mock.. 
>  
>
Well, i use the local file provider to test if i do global changes on 
vfs, it is easy to setup and the core of vfs is tested well.
For this, and if i have problems with a special filesystem i use a 
RunTest class.

If this test passes, i startup my uml-linux and trigger the whole test 
chain.

>But again, if you have a system, then that works..
>  
>
And never ever there should be a commit to vfs without testing the 
change against this system using ALL filesystems.

If you are interested in this uml-linux server, just drop me a note.


---RunTest---
package org.apache.commons.vfs.test;

import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestResult;
import org.apache.commons.vfs.provider.webdav.test.WebdavProviderTestCase;

import java.util.Properties;

public class RunTest
{
    public static void main(String[] args) throws Exception
    {
        Properties props = System.getProperties();
        props.setProperty("test.data.src", "src/test-data");
        props.setProperty("test.basedir", "target/test-data");
        props.setProperty("test.policy", "src/test-data/test.policy");
        props.setProperty("test.secure", "false");
        props.setProperty("test.smb.uri", 
"smb://vfsusr:vfsusr@vfstest/vfsusr/vfstest");
        props.setProperty("test.ftp.uri", 
"ftp://vfsusr:vfsusr@vfstest/vfstest");
        props.setProperty("test.http.uri", "http://vfstest/vfstest");

        props.setProperty("test.webdav.uri", 
"webdav://vfsusr:vfsusr@vfstest/vfstest");

        props.setProperty("test.sftp.uri", 
"sftp://vfsusr:vfsusr@vfstest/home/vfsusr/vfstest");

        Test test;
        // test = FtpProviderTestCase.suite();
        // test = HttpProviderTestCase.suite();
        // test = LocalProviderTestCase.suite();
        // test = JarProviderTestCase.suite();
        // test = ZipProviderTestCase.suite();
        // test = TemporaryProviderTestCase.suite();
        test = WebdavProviderTestCase.suite();
        // test = UrlProviderTestCase.suite();

        // test = SmbProviderTestCase.suite();

        // test = SftpProviderTestCase.suite();

        TestResult result = new TestResult()
        {
            public synchronized void addError(Test test, Throwable 
throwable)
            {
                throwable.printStackTrace();
            }

            public synchronized void addFailure(Test test, 
AssertionFailedError assertionFailedError)
            {
                assertionFailedError.printStackTrace();
            }
        };
        test.run(result);
    }
}
---RunTest---

-- 
Mario


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


RE: [vfs] running unit tests for Http provider

Posted by Eric Pugh <ep...@upstate.com>.
As I dig more into it..   I see your challenges with testing!  All the
different platforms means a LOT of external dependencies.   Something that
could be an approach would be to have two modes:  Real and Mock..  You could
Mock all the various platforms so that if someone is testing the logic of
VFS, they can run without having smb/webdav etc.  Then, to test that the
real world works, then you switch to Real mode, and run against smb and
webdav etc.

On the other hand, if you have a system setup to do this, and can therefore
run the tests for real, then maybe this isn't worth all the work.  The HTTP
one does though seem like an easy one to provide since the HTTP is a read
only provider..   But again, if you have a system, then that works..

Eric

> -----Original Message-----
> From: Mario Ivankovits [mailto:imario@apache.org]
> Sent: Wednesday, June 23, 2004 10:06 AM
> To: Jakarta Commons Developers List
> Subject: Re: [vfs] running unit tests for Http provider
>
>
> Eric Pugh wrote:
>
> >But now it fails on not finding a directory
> www.ibiblio.rog/maven/read-data.
> >Is it possible to a) Stick up docs on how to build and run the
> unit tests w/
> >what exteranal dependencies there are.  b) change the unit tests
> so that if
> >we are donig a readonly test, we could maybe point to files or something
> >that are on a public website, like maybe the VFS website?
> >
> >
> a) This might be possible, and for sure, completing the documentation
> should be a top priority ... but you know ;-)
> b) Not sure why we should provide a read-only test server for vfs as
> there are many write-tests one should do too.
> And the vfs tests expect a certain amount of files/directories and their
> content.
> And even if we are try to do this, think of the various different
> filesystem: sftp, smb, webdav, ...
>
> However i use a UML-Linux (UserModeLinux - something like vmware but for
> linux only) server which is configured in a manner that the vfs tests
> can pass (read and write).
> On every restart of this uml-linux instance the whole system is in a
> clear state and every update has been rollbacked.
>
> If it is allowed to provide a e.g. 70 MB download at apache i could
> simply upload it and everyone can use it to do the tests.
>
>
> --
> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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


Re: [vfs] running unit tests for Http provider

Posted by Mario Ivankovits <im...@apache.org>.
Eric Pugh wrote:

>But now it fails on not finding a directory www.ibiblio.rog/maven/read-data.
>Is it possible to a) Stick up docs on how to build and run the unit tests w/
>what exteranal dependencies there are.  b) change the unit tests so that if
>we are donig a readonly test, we could maybe point to files or something
>that are on a public website, like maybe the VFS website?
>  
>
a) This might be possible, and for sure, completing the documentation 
should be a top priority ... but you know ;-)
b) Not sure why we should provide a read-only test server for vfs as 
there are many write-tests one should do too.
And the vfs tests expect a certain amount of files/directories and their 
content.
And even if we are try to do this, think of the various different 
filesystem: sftp, smb, webdav, ...

However i use a UML-Linux (UserModeLinux - something like vmware but for 
linux only) server which is configured in a manner that the vfs tests 
can pass (read and write).
On every restart of this uml-linux instance the whole system is in a 
clear state and every update has been rollbacked.

If it is allowed to provide a e.g. 70 MB download at apache i could 
simply upload it and everyone can use it to do the tests.


-- 
Mario


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


Re: [vfs] running unit tests for Http provider

Posted by Mario Ivankovits <im...@apache.org>.
Http & webdav configuration:

Server version: Apache/1.3.26
/etc/apache/httpd.conf

--- snip ----
#
# VFSTEST
#
Alias /vfstest /vfstest/

<Location />
        DAV On
        Options Indexes MultiViews
        AllowOverride None

        AuthType Basic
        AuthName vfstest_zone
        AuthUserFile /etc/apache/passwd
        <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK 
UNLOCK>
                Require user vfsusr
        </Limit>
</Location>
--- snip ---

Direcotry-structure of /vfstest:

vfstest
vfstest/write-tests
vfstest/read-tests
vfstest/read-tests/emptydir
vfstest/read-tests/file1.txt
vfstest/read-tests/dir1
vfstest/read-tests/dir1/file1.txt
vfstest/read-tests/dir1/file2.txt
vfstest/read-tests/dir1/file3.txt
vfstest/read-tests/dir1/subdir1
vfstest/read-tests/dir1/subdir1/file1.txt
vfstest/read-tests/dir1/subdir1/file2.txt
vfstest/read-tests/dir1/subdir1/file3.txt
vfstest/read-tests/dir1/subdir2
vfstest/read-tests/dir1/subdir2/file1.txt
vfstest/read-tests/dir1/subdir2/file2.txt
vfstest/read-tests/dir1/subdir2/file3.txt
vfstest/read-tests/dir1/subdir3
vfstest/read-tests/dir1/subdir3/file1.txt
vfstest/read-tests/dir1/subdir3/file2.txt
vfstest/read-tests/dir1/subdir3/file3.txt
vfstest/read-tests/empty.txt
vfstest/code
vfstest/code/sealed
vfstest/code/sealed/AnotherClass.class
vfstest/code/ClassToLoad.class

You will find the files needed for "read-tests" and "code" in 
"test-data" in the vfs repository.

As i use ant for build i simply added the configuration in my build.xml 
into the "internal-test" target.

<property name="test.user" value="vfsusr" />
<property name="test.password" value="vfsusr" />
<property name="test.hostname" value="vfstest" />
<property name="test.path" value="/vfstest" />
<sysproperty key="test.smb.uri" 
value="smb://${test.user}:${test.password}@${test.hostname}/${test.user}${test.path}"/>
<sysproperty key="test.ftp.uri" 
value="ftp://${test.user}:${test.password}@${test.hostname}${test.path}"/>
<sysproperty key="test.http.uri" 
value="http://${test.hostname}${test.path}"/>
<sysproperty key="test.webdav.uri" 
value="webdav://${test.user}:${test.password}@${test.hostname}${test.path}"/>
<sysproperty key="test.sftp.uri" 
value="sftp://${test.user}:${test.password}@${test.hostname}/home/${test.user}${test.path}"/>


Hope this helps a little bit.

-- 
Mario


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