001    /*
002     * $Id: SmokeTest.java,v 1.4 2011/07/09 21:43:23 oboehm Exp $
003     *
004     * Copyright (c) 2010 by Oliver Boehm
005     *
006     * Licensed under the Apache License, Version 2.0 (the "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *   http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     *
018     * (c)reated 29.07.2010 by oliver (ob@oasd.de)
019     */
020    
021    package patterntesting.runtime;
022    
023    import static org.junit.Assert.*;
024    
025    import java.io.FileFilter;
026    
027    import org.apache.commons.io.filefilter.FileFilterUtils;
028    import org.junit.Test;
029    import org.slf4j.*;
030    
031    
032    /**
033     * This tests checks some preconditions for PatternTesting Runtime.
034     * If one of these tests fails PatternTesting may work not correct.
035     * This class is part of src/main/java so that everybody can call this
036     * tests to check if one of the preconditions are broken.
037     * <br/>
038     * This class is not final so that you can extend it for your own needs.
039     *
040     * @author oliver
041     * @since 1.0.2 (29.07.2010)
042     */
043    public class SmokeTest {
044    
045        private static final Logger log = LoggerFactory.getLogger(SmokeTest.class);
046    
047        /**
048         * For the ClasspathMonitor and ClassWalker we need the commons-io lib.
049         * And at least version 1.3.1 of commons-io is needed because the
050         * FileFilter and DirectoryWalker of this lib is used.
051         * <br/>
052         * If you use commons-io-1.2 you may get a NoSuchMethodError and
053         * <pre>
054         * java.lang.NoSuchMethodError: org.apache.commons.io.filefilter.FileFilterUtils.fileFileFilter()Lorg/apache/commons/io/filefilter/IOFileFilter;
055         *    patterntesting.runtime.monitor.ClassWalker.getFileFilter(ClassWalker.java:65)
056         *    patterntesting.runtime.monitor.ClassWalker.<init>(ClassWalker.java:48)
057         *    patterntesting.runtime.monitor.ClasspathMonitor.addClassesFromDir_aroundBody38(ClasspathMonitor.java:884)
058         *    patterntesting.runtime.monitor.ClasspathMonitor.addClassesFromDir_aroundBody39$advice(ClasspathMonitor.java:49)
059         *    patterntesting.runtime.monitor.ClasspathMonitor.addClassesFromDir(ClasspathMonitor.java:1)
060         *    patterntesting.runtime.monitor.ClasspathMonitor.addClasses(ClasspathMonitor.java:864)
061         *    patterntesting.runtime.monitor.ClasspathMonitor.getClasspathClassSet_aroundBody36(ClasspathMonitor.java:847)
062         *    patterntesting.runtime.monitor.ClasspathMonitor.getClasspathClassSet_aroundBody37$advice(ClasspathMonitor.java:49)
063         *    patterntesting.runtime.monitor.ClasspathMonitor.getClasspathClassSet(ClasspathMonitor.java:1)
064         *    patterntesting.runtime.monitor.ClasspathMonitor.<init>(ClasspathMonitor.java:119)
065         *    patterntesting.runtime.monitor.ClasspathMonitor.<clinit>(ClasspathMonitor.java:109)
066         *    ...
067         * </pre>
068         * as stacktrace.
069         */
070        @Test
071        public final void testCommonsIO() {
072            try {
073                FileFilter filter = FileFilterUtils.fileFileFilter();
074                assertNotNull(filter);
075            } catch (NoSuchMethodError e) {
076                log.error("your commons-io lib is probably to old", e);
077                fail("use commons-io-1.3.1.jar or newer (" + e + ")");
078            }
079        }
080    
081    }
082