core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java
/**
     * Walks a folder structure, asserting it contains exactly the
     * expected files and folders.
     */
Walks a folder structure, asserting it contains exactly the
expected files and folders.
Walks a folder structure asserting it contains exactly the expected files and folders .
protected void assertSameStructure(final FileObject folder,
                                       final FileInfo expected)
        throws Exception
    {
        final List<FileInfo> queueExpected = new ArrayList<FileInfo>();
        queueExpected.add(expected);
        final List<FileObject> queueActual = new ArrayList<FileObject>();
        queueActual.add(folder);
        while (queueActual.size() > 0)
        {
            final FileObject file = queueActual.remove(0);
            final FileInfo info = queueExpected.remove(0);
            assertSame(info.type, file.getType());
            if (info.type == FileType.FILE)
            {
                continue;
            }
            final FileObject[] children = file.getChildren();
            assertNotNull(children);
            int length = children.length;
            if (info.children.size() != children.length)
            {
                for (int i=0; i < children.length; ++i)
                {
                    if (children[i].getName().getBaseName().startsWith("."))
                    {
                        --length;
                        continue;
                    }
                    System.out.println(children[i].getName());
                }
            }
            assertEquals("count children of \"" + file.getName() + "\"", info.children.size(), length);
            for (int i = 0; i < children.length; i++)
            {
                final FileObject child = children[i];
                String childName = child.getName().getBaseName();
                if (childName.startsWith("."))
                {
                    continue;
                }
                final FileInfo childInfo = info.children.get(childName);
                assertNotNull(childInfo);
                queueExpected.add(childInfo);
                queueActual.add(child);
            }
        }
    }
protected void assertSameStructure ( final FileObject folder , final FileInfo expected ) throws Exception { final List < FileInfo > queueExpected = new ArrayList < FileInfo > ( ) ; queueExpected . add ( expected ) ; final List < FileObject > queueActual = new ArrayList < FileObject > ( ) ; queueActual . add ( folder ) ; while ( queueActual . size ( ) > 0 ) { final FileObject file = queueActual . remove ( 0 ) ; final FileInfo info = queueExpected . remove ( 0 ) ; assertSame ( info . type , file . getType ( ) ) ; if ( info . type == FileType . FILE ) { continue ; } final FileObject [ ] children = file . getChildren ( ) ; assertNotNull ( children ) ; int length = children . length ; if ( info . children . size ( ) != children . length ) { for ( int i = 0 ; i < children . length ; ++ i ) { if ( children [ i ] . getName ( ) . getBaseName ( ) . startsWith ( "." ) ) { -- length ; continue ; } System . out . println ( children [ i ] . getName ( ) ) ; } } assertEquals ( "count children of \"" + file . getName ( ) + "\"" , info . children . size ( ) , length ) ; for ( int i = 0 ; i < children . length ; i ++ ) { final FileObject child = children [ i ] ; String childName = child . getName ( ) . getBaseName ( ) ; if ( childName . startsWith ( "." ) ) { continue ; } final FileInfo childInfo = info . children . get ( childName ) ; assertNotNull ( childInfo ) ; queueExpected . add ( childInfo ) ; queueActual . add ( child ) ; } } }
Walks a folder structure, asserting it contains exactly the
 expected files and folders.
Walks a folder structure asserting it contains exactly the expected files and folders .
// Setup the structure // Check the type is correct // Check children // Make sure all children were found // Recursively check each child // Make sure the child is expected // Add to the queue of files to check