@@ -0,0 +1,3227 @@
+/*-%0A * Copyright (c) 2014 Red Hat, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.fedoraproject.xmvn.tools.install.impl;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0A%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A%0A/**%0A * @author Mikolaj Izdebski%0A */%0Apublic abstract class AbstractFileTest%0A%7B%0A    private final List%3CFile%3E files = new ArrayList%3C%3E();%0A%0A    private Path installRoot;%0A%0A    protected void add( File file )%0A        throws Exception%0A    %7B%0A        files.add( file );%0A    %7D%0A%0A    protected Path performInstallation()%0A        throws Exception%0A    %7B%0A        try%0A        %7B%0A            String testName = getClass().getName();%0A            Path workPath = Paths.get( %22target%22 ).resolve( %22test-work%22 );%0A            Files.createDirectories( workPath );%0A            installRoot = Files.createTempDirectory( workPath, testName );%0A%0A            for ( File file : files )%0A                file.install( installRoot );%0A%0A            return installRoot;%0A        %7D%0A        finally%0A        %7B%0A            files.clear();%0A        %7D%0A    %7D%0A%0A    protected void assertDirectoryStructure( String... expected )%0A        throws Exception%0A    %7B%0A        assertDirectoryStructure( installRoot, expected );%0A    %7D%0A%0A    protected void assertDirectoryStructure( Path root, String... expected )%0A        throws Exception%0A    %7B%0A        List%3CString%3E expectedList = new ArrayList%3C%3E();%0A        for ( String string : expected )%0A            expectedList.add( string );%0A%0A        List%3CString%3E actualList = new ArrayList%3C%3E();%0A        Files.walkFileTree( root, new FileSystemWalker( root, actualList ) );%0A%0A        Collections.sort( expectedList );%0A        Collections.sort( actualList );%0A%0A        try%0A        %7B%0A            Iterator%3CString%3E expectedIterator = expectedList.iterator();%0A            Iterator%3CString%3E actualIterator = actualList.iterator();%0A%0A            while ( expectedIterator.hasNext() && actualIterator.hasNext() )%0A                assertEquals( expectedIterator.next(), actualIterator.next() );%0A%0A            assertFalse( expectedIterator.hasNext() );%0A            assertFalse( actualIterator.hasNext() );%0A        %7D%0A        catch ( AssertionError e )%0A        %7B%0A            System.err.println( %22EXPECTED directory structure:%22 );%0A            for ( String string : expectedList )%0A                System.err.println( %22  %22 + string );%0A%0A            System.err.println( %22ACTUAL directory structure:%22 );%0A            for ( String string : actualList )%0A                System.err.println( %22  %22 + string );%0A%0A            throw e;%0A        %7D%0A    %7D%0A%7D%0A

Implement AbstractFileTest