Avoid Star Import Check created separate compilable UT input based on InputImport #388
This commit is contained in:
parent
9c944ecd22
commit
b1d4299b1d
|
|
@ -38,10 +38,11 @@ public class AvoidStarImportTest
|
|||
"10: Using the '.*' form of import should be avoided - java.lang.*.",
|
||||
"25: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"28: Using the '.*' form of import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
"28: Using the '.*' form of import should be avoided - java.io.File.*.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected);
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputAvoidStarImportCheck.java"),
|
||||
expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -55,9 +56,10 @@ public class AvoidStarImportTest
|
|||
// allow the java.io/java.lang,javax.swing.WindowConstants star imports
|
||||
final String[] expected2 = new String[] {
|
||||
"7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.imports.*.",
|
||||
"28: Using the '.*' form of import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
"28: Using the '.*' form of import should be avoided - java.io.File.*.",
|
||||
};
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected2);
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputAvoidStarImportCheck.java"),
|
||||
expected2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -69,8 +71,8 @@ public class AvoidStarImportTest
|
|||
final String[] expected2 = new String[] {
|
||||
"25: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using the '.*' form of import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"28: Using the '.*' form of import should be avoided - sun.net.ftpclient.FtpClient.*.", };
|
||||
"28: Using the '.*' form of import should be avoided - java.io.File.*.", };
|
||||
verify(checkConfig, getPath("imports" + File.separator
|
||||
+ "InputImport.java"), expected2);
|
||||
+ "InputAvoidStarImportCheck.java"), expected2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Test case file for checkstyle.
|
||||
// Created: 2001
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.imports;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.imports.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.*;
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.List;
|
||||
import java.lang.AbstractMethodError;
|
||||
import java.util.Iterator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.ScrollPaneLayout;
|
||||
import javax.swing.BorderFactory;
|
||||
import static java.io.File.listRoots;
|
||||
|
||||
import static javax.swing.WindowConstants.*;
|
||||
import static javax.swing.WindowConstants.*;
|
||||
import static java.io.File.createTempFile;
|
||||
import static java.io.File.*;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Label;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
import java.util.BitSet;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultLogger;
|
||||
|
||||
/**
|
||||
* Test case for imports
|
||||
* Here's an import used only by javadoc: {@link Date}.
|
||||
* @author Oliver Burn
|
||||
* @author lkuehne
|
||||
* @author Michael Studman
|
||||
* @see Calendar Should avoid unused import for Calendar
|
||||
**/
|
||||
class InputAvoidStarImportCheck
|
||||
{
|
||||
/** ignore **/
|
||||
private Class mUse1 = Connection.class;
|
||||
/** ignore **/
|
||||
private Class mUse2 = java.io.File.class;
|
||||
/** ignore **/
|
||||
private Class mUse3 = Iterator[].class;
|
||||
/** ignore **/
|
||||
private Class mUse4 = java.util.Enumeration[].class;
|
||||
/** usage of illegal import **/
|
||||
private String ftpClient = null;
|
||||
|
||||
/** usage via static method, both normal and fully qualified */
|
||||
{
|
||||
int[] x = {};
|
||||
Arrays.sort(x);
|
||||
Object obj = javax.swing.BorderFactory.createEmptyBorder();
|
||||
File[] files = listRoots();
|
||||
}
|
||||
|
||||
/** usage of inner class as type */
|
||||
private JToolBar.Separator mSep = null;
|
||||
|
||||
/** usage of inner class in Constructor */
|
||||
private Object mUse5 = new Object();
|
||||
|
||||
/** usage of inner class in constructor, fully qualified */
|
||||
private Object mUse6 = new javax.swing.JToggleButton.ToggleButtonModel();
|
||||
|
||||
/** we use class name as member's name.
|
||||
* also an inline JavaDoc-only import {@link Vector linkText} */
|
||||
private int Component;
|
||||
|
||||
/**
|
||||
* method comment with JavaDoc-only import {@link BitSet#aMethod()}
|
||||
*/
|
||||
public void Label() {}
|
||||
|
||||
/**
|
||||
* Renders to a {@linkplain Graphics2D graphics context}.
|
||||
* @throws HeadlessException if no graphis environment can be found.
|
||||
* @exception HeadlessException if no graphis environment can be found.
|
||||
*/
|
||||
public void render() {}
|
||||
|
||||
/**
|
||||
* First is a class with a method with arguments {@link TestClass1#method1(TestClass2)}.
|
||||
* Next is a class with typed method {@link TestClass3#method2(TestClass4, TestClass5)}.
|
||||
*
|
||||
* @param param1 with a link {@link TestClass6}
|
||||
* @throws TestClass7 when broken
|
||||
* @deprecated in 1 for removal in 2. Use {@link TestClass8}
|
||||
*/
|
||||
public void aMethodWithManyLinks() {}
|
||||
}
|
||||
Loading…
Reference in New Issue