You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/20 23:52:57 UTC

cvs commit: jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/format NoBreaksTest.java

jvanzyl     02/02/20 14:52:57

  Added:       src/test/org/apache/maven/importscrubber FilePairTest.java
                        ImportStatementTest.java ImportStatementsTest.java
                        JavaFileFilterTest.java PackageStmtTest.java
               src/test/org/apache/maven/importscrubber/filechooser
                        AllInDirTest.java RecursiveFileChooserTest.java
               src/test/org/apache/maven/importscrubber/format
                        NoBreaksTest.java
  Log:
  - adding tests for importscrubber
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/FilePairTest.java
  
  Index: FilePairTest.java
  ===================================================================
  package org.apache.maven.importscrubber;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.File;
  import java.util.Iterator;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.FilePair;
  
  public class FilePairTest extends TestCase
  {
     public FilePairTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(FilePairTest.class);
     }
  
     public void testBasic()
     {
        File a = new File("c:\\");
        File b = new File("d:\\");
        FilePair pair = new FilePair(a, b);
        assert(pair.getSourceFile().equals(a));
  
        Iterator i = pair.getClassFiles();
        assert(i.hasNext());
        i.next();
        assert(!i.hasNext());
     }
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/ImportStatementTest.java
  
  Index: ImportStatementTest.java
  ===================================================================
  package org.apache.maven.importscrubber;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.*;
  import org.apache.maven.importscrubber.format.NoBreaks;
  import java.util.*;
  
  public class ImportStatementTest extends TestCase
  {
  
     private static final String BAR_CLASS = "com.foo.Bar";
     private static final String BAZ_CLASS = "com.foo.Baz";
     private static final String BUZ_CLASS = "com.foo.biz.Buz";
     private static final String STRING_CLASS = "java.lang.String";
     private static final String SQL_DATE_CLASS = "javax.sql.Date";
  
  
     public ImportStatementTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(ImportStatementTest.class);
     }
  
     public void testBasic()
     {
        ImportStatement stmt = new ImportStatement(BAR_CLASS);
        assertEquals(BAR_CLASS, stmt.getFullyQualifiedClassName());
     }
  
     public void testStdLib()
     {
        ImportStatement stmt = new ImportStatement(BAR_CLASS);
        assertTrue(!stmt.isInStdJavaLibrary());
        
        stmt = new ImportStatement(STRING_CLASS);
        assertTrue(stmt.isInStdJavaLibrary());
     }
  
     public void testStdExtLib()
     {
        ImportStatement stmt = new ImportStatement(BAR_CLASS);
        assertTrue(!stmt.isInStdJavaExtensionLibrary());
        
        stmt = new ImportStatement(SQL_DATE_CLASS);
        assertTrue(stmt.isInStdJavaExtensionLibrary());
     }
  
     public void testCompare()
     {
        ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
        ImportStatement stmtBaz = new ImportStatement(BUZ_CLASS);
        assertEquals(-1, stmtBar.compareTo(stmtBaz));
        assertEquals(1, stmtBaz.compareTo(stmtBar));
        assertEquals(0, stmtBaz.compareTo(stmtBaz));
     }
  
     public void testIsInDefaultPackage()
     {
        ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
        assertTrue(!stmtBar.isInDefaultPackage());
  
        ImportStatement defaultStmt = new ImportStatement("Worble");
        assertTrue(defaultStmt.isInDefaultPackage());
     }
  
     public void testGetPackage()
     {
        ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
        assertEquals("com.foo", stmtBar.getPackage());
     }
  
     public void testCompareBad()
     {
        try
        {
           ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
           stmtBar.compareTo("hello");
           fail("Should have gotten a ClassCastException");
        } catch (ClassCastException ex)
        {
           // cool
        }
     }
     public void testCompareNull()
     {
        try
        {
           ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
           stmtBar.compareTo(null);
           fail("Should have gotten an IllegalArgumentException");
        } catch (IllegalArgumentException ex)
        {
           // cool
        }
     }
  
     public void testHashcode()
     {
        ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
        ImportStatement stmtBaz = new ImportStatement(BUZ_CLASS);
        assertTrue(stmtBar.hashCode() != stmtBaz.hashCode());
  
        HashMap map = new HashMap();
        map.put(stmtBar, "hello");
        assertEquals("hello", map.get(stmtBar));
     }
  
     public void testEquals()
     {
        ImportStatement stmtBar = new ImportStatement(BAR_CLASS);
        ImportStatement stmtBaz = new ImportStatement(BUZ_CLASS);
        assertTrue(!stmtBar.equals(stmtBaz));
        assertTrue(stmtBar.equals(stmtBar));
     }
  
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/ImportStatementsTest.java
  
  Index: ImportStatementsTest.java
  ===================================================================
  package org.apache.maven.importscrubber;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.ImportScrubber;
  import org.apache.maven.importscrubber.ImportStatements;
  import org.apache.maven.importscrubber.PackageStmt;
  import org.apache.maven.importscrubber.ImportStatement;
  import org.apache.maven.importscrubber.format.NoBreaks;
  
  public class ImportStatementsTest extends TestCase
  {
  
     private static final String BAR_CLASS = "com.foo.Bar";
     private static final String BAZ_CLASS = "com.foo.Baz";
     private static final String BUZ_CLASS = "com.foo.biz.Buz";
  
     public ImportStatementsTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(ImportStatementsTest.class);
     }
  
     public void testBasic()
     {
        ImportStatements is = new ImportStatements();
        is.add(BAR_CLASS);
        String out = is.getOutput(new NoBreaks()).toString();
        assertEquals(ImportStatements.MARKER + BAR_CLASS + ";" + ImportScrubber.LINE_SEPARATOR, out);
     }
  
     public void testDupe()
     {
        ImportStatements is = new ImportStatements();
        is.add(BAR_CLASS);
        is.add(BAR_CLASS);
        assertEquals(1, is.getCount());
     }
  
     public void testRemoveLocal()
     {
        ImportStatements is = new ImportStatements();
        is.add(BAR_CLASS);
        is.add(BUZ_CLASS);
        assertEquals(2, is.getCount());
        PackageStmt ps = new PackageStmt("package com.foo.biz;");
        is.removeLocalToPackage(ps);
        assertEquals(1, is.getCount());
     }
  
     public void testRemoveUnreferenced()
     {
        ImportStatements is = new ImportStatements();
        is.add(BAR_CLASS);
        is.add(BUZ_CLASS);
        assertEquals(2, is.getCount());
        is.removeUnreferenced("Buz");
        assertEquals(1, is.getCount());
     }
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/JavaFileFilterTest.java
  
  Index: JavaFileFilterTest.java
  ===================================================================
  package org.apache.maven.importscrubber;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.File;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.JavaFileFilter;
  
  public class JavaFileFilterTest extends TestCase
  {
     public JavaFileFilterTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(JavaFileFilterTest.class);
     }
  
     public void testBasic()
     {
        JavaFileFilter f = new JavaFileFilter();
        assertTrue(f.accept(new File("d:\\data\\importscrubber\\etc"), "FunctionalTest.java"));
        assertTrue(!f.accept(new File("d:\\data\\importscrubber\\etc"), "Foo.java"));
     }
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/PackageStmtTest.java
  
  Index: PackageStmtTest.java
  ===================================================================
  package org.apache.maven.importscrubber;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.PackageStmt;
  import org.apache.maven.importscrubber.ImportStatement;
  
  
  public class PackageStmtTest extends TestCase
  {
  
     private static final String DEFAULT = "package org.apache.maven.importscrubber;";
  
     public PackageStmtTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(PackageStmtTest.class);
     }
  
     public void testBasic()
     {
        PackageStmt stmt = new PackageStmt(DEFAULT);
        assert(stmt.isInSamePackageAs(new ImportStatement("org.apache.maven.importscrubber.Buz")));
        assert(!stmt.isInSamePackageAs(new ImportStatement("net.sourceforge.osage.Bat")));
     }
  
     public void testDefaultPkg()
     {
        PackageStmt stmt = new PackageStmt();
        assert(!stmt.isInSamePackageAs(new ImportStatement("org.apache.maven.importscrubber.Foo")));
        assert(stmt.isInSamePackageAs(new ImportStatement("")));
     }
  
     public void testInnerClass()
     {
        PackageStmt stmt = new PackageStmt(DEFAULT);
        assert(stmt.isInSamePackageAs(new ImportStatement("org.apache.maven.importscrubber.Foo.Fiz")));
     }
     
     public void testChildPackage()
     {
        PackageStmt stmt = new PackageStmt(DEFAULT);
        assert(!stmt.isInSamePackageAs(new ImportStatement("org.apache.maven.importscrubber.biz.Buz")));
     }
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/filechooser/AllInDirTest.java
  
  Index: AllInDirTest.java
  ===================================================================
  package org.apache.maven.importscrubber.filechooser;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.filechooser.AllInDirectoryFileChooser;
  
  public class AllInDirTest extends TestCase
  {
     public AllInDirTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(AllInDirTest.class);
     }
  
     public void testBasic()
     {
        AllInDirectoryFileChooser fc = new AllInDirectoryFileChooser();
        fc.setRoot("d:\\data\\importscrubber\\etc");
        assertEquals(2, fc.getFiles().size());
     }
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/filechooser/RecursiveFileChooserTest.java
  
  Index: RecursiveFileChooserTest.java
  ===================================================================
  package org.apache.maven.importscrubber.filechooser;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.filechooser.RecursiveFileChooser;
  
  public class RecursiveFileChooserTest extends TestCase
  {
     public RecursiveFileChooserTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(RecursiveFileChooserTest.class);
     }
  
     public void testBasic()
     {
        RecursiveFileChooser fc = new RecursiveFileChooser();
        fc.setRoot("d:\\data\\importscrubber\\etc");
        assertEquals(4, fc.getFiles().size());
     }
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/test/org/apache/maven/importscrubber/format/NoBreaksTest.java
  
  Index: NoBreaksTest.java
  ===================================================================
  package org.apache.maven.importscrubber.format;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.util.ArrayList;
  import java.util.List;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.maven.importscrubber.format.NoBreaks;
  import org.apache.maven.importscrubber.*;
  
  public class NoBreaksTest extends TestCase
  {
     public NoBreaksTest(String aName)
     {
        super(aName);
     }
  
     public static Test suite()
     {
        return new TestSuite(NoBreaksTest.class);
     }
  
     public void testBasic()
     {
        List l = new ArrayList();
        l.add(new ImportStatement("com.foo.Bar"));
        l.add(new ImportStatement("java.util.Buz"));
        
        NoBreaks n = new NoBreaks();
  
        StringBuffer res = n.applyFormat(l.iterator());
  
        int count = 0;
        for (int i=0; i<res.length(); i++)
        {
           if (res.charAt(i) == '\n') {
              count++;
           }
        }
  
        assertEquals(2, count);
     }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>