Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>43</version>
<version>44</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -173,6 +173,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.15.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private JavaSource getJavaSource(String source) {
}

@Test
public void testReplaceLinkTags_noLinkTag() {
public void testReplaceLinkTagsNoLinkTag() {
String comment = "/** @see ConnectException */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class NoLinkTag {}";

Expand All @@ -45,7 +45,7 @@ public void testReplaceLinkTags_noLinkTag() {
}

@Test
public void testReplaceLinkTags_oneLinkTag() {
public void testReplaceLinkTagsOneLinkTag() {
String comment = "/** {@link ConnectException} */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class OneLinkTag {}";

Expand All @@ -56,7 +56,7 @@ public void testReplaceLinkTags_oneLinkTag() {
}

@Test
public void testReplaceLinkTags_missingEndBrace() {
public void testReplaceLinkTagsMissingEndBrace() {
String comment = "/** {@link ConnectException */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class MissingEndBrace {}";

Expand All @@ -67,7 +67,7 @@ public void testReplaceLinkTags_missingEndBrace() {
}

@Test
public void testReplaceLinkTags_spacesAfterLinkTag() {
public void testReplaceLinkTagsSpacesAfterLinkTag() {
String comment = "/** {@link ConnectException} */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class SpacesAfterLinkTag {}";

Expand All @@ -78,7 +78,7 @@ public void testReplaceLinkTags_spacesAfterLinkTag() {
}

@Test
public void testReplaceLinkTags_spacesAfterClassName() {
public void testReplaceLinkTagsSpacesAfterClassName() {
String comment = "/** {@link ConnectException } */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class SpacesAfterClassName {}";

Expand All @@ -89,7 +89,7 @@ public void testReplaceLinkTags_spacesAfterClassName() {
}

@Test
public void testReplaceLinkTags_spacesAfterMethod() {
public void testReplaceLinkTagsSpacesAfterMethod() {
String comment = "/** {@link ConnectException#getMessage() } */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class SpacesAfterMethod {}";

Expand All @@ -100,7 +100,7 @@ public void testReplaceLinkTags_spacesAfterMethod() {
}

@Test
public void testReplaceLinkTags_containingHash() {
public void testReplaceLinkTagsContainingHash() {
String comment = "/** {@link ConnectException#getMessage()} */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class ContainingHashes {}";

Expand All @@ -111,7 +111,7 @@ public void testReplaceLinkTags_containingHash() {
}

@Test
public void testReplaceLinkTags_followedByHash() {
public void testReplaceLinkTagsFollowedByHash() {
String comment = "/** {@link ConnectException} ##important## */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class FollowedByHash {}";

Expand All @@ -122,7 +122,7 @@ public void testReplaceLinkTags_followedByHash() {
}

@Test
public void testReplaceLinkTags_twoLinks() {
public void testReplaceLinkTagsTwoLinks() {
String comment = "/** Use {@link ConnectException} instead of {@link Exception} */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class TwoLinks {}";

Expand All @@ -134,7 +134,7 @@ public void testReplaceLinkTags_twoLinks() {
}

@Test
public void testReplaceLinkTags_OnlyAnchor() {
public void testReplaceLinkTagsOnlyAnchor() {
String comment = "/** There's a {@link #getClass()} but no setClass() */";
String source = "import java.net.ConnectException;\n" + comment + "\n" + "public class OnlyAnchor {}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void doExecute() {}
}

@Test
public void testMJAVADOC432_DetectLinksMessages() {
public void testMJAVADOC432DetectLinksMessages() {
Log log = mock(Log.class);
when(log.isErrorEnabled()).thenReturn(true);
mojo.setLog(log);
Expand All @@ -69,7 +69,7 @@ public void testMJAVADOC432_DetectLinksMessages() {
}

@Test
public void testMJAVADOC527_DetectLinksRecursion() {
public void testMJAVADOC527DetectLinksRecursion() {
Log log = mock(Log.class);
when(log.isErrorEnabled()).thenReturn(true);
mojo.setLog(log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AggregatorJavadocReportTest extends AbstractMojoTestCase {
private static final char LINE_SEPARATOR = ' ';

/** flag to copy repo only one time */
private static boolean TEST_REPO_CREATED = false;
private static boolean testRepoCreated = false;

private File unit;

Expand Down Expand Up @@ -88,7 +88,7 @@ private JavadocReport lookupMojo(File testPom) throws Exception {
* @throws IOException if any
*/
private void createTestRepo() throws IOException {
if (TEST_REPO_CREATED) {
if (testRepoCreated) {
return;
}

Expand Down Expand Up @@ -148,7 +148,7 @@ private void createTestRepo() throws IOException {
}
}

TEST_REPO_CREATED = true;
testRepoCreated = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class FixJavadocMojoTest extends AbstractMojoTestCase {
private static final String EOL = System.getProperty("line.separator");

/** flag to copy repo only one time */
private static boolean TEST_REPO_CREATED = false;
private static boolean testRepoCreated = false;

/** {@inheritDoc} */
@Override
Expand All @@ -69,7 +69,7 @@ protected void setUp() throws Exception {
* @throws IOException if any
*/
private void createTestRepo() throws Exception {
if (TEST_REPO_CREATED) {
if (testRepoCreated) {
return;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ private void createTestRepo() throws Exception {
}
}

TEST_REPO_CREATED = true;
testRepoCreated = true;
}

/**
Expand Down
50 changes: 14 additions & 36 deletions src/test/java/org/apache/maven/plugins/javadoc/JavadocUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
*/
public class JavadocUtilTest extends PlexusTestCase {

public void testParseJavadocVersion_Null() {
public void testParseJavadocVersionNull() {
try {
JavadocUtil.extractJavadocVersion(null);
fail("Not catch null");
Expand All @@ -70,7 +70,7 @@ public void testParseJavadocVersion_Null() {
}
}

public void testParseJavadocVersion_EmptyString() {
public void testParseJavadocVersionEmptyString() {
try {
JavadocUtil.extractJavadocVersion("");
fail("Not catch empty version");
Expand Down Expand Up @@ -163,7 +163,7 @@ public void testParseJavadocVersion() {
assertEquals("10.0.1", JavadocUtil.extractJavadocVersion(version));
}

public void testParseJavadocMemory_null() {
public void testParseJavadocMemoryNull() {
try {
JavadocUtil.parseJavadocMemory(null);
fail("Not catch null");
Expand All @@ -172,7 +172,7 @@ public void testParseJavadocMemory_null() {
}
}

public void testParseJavadocMemory_empty() {
public void testParseJavadocMemoryEmpty() {
try {
JavadocUtil.parseJavadocMemory("");
fail("Not catch null");
Expand Down Expand Up @@ -291,35 +291,24 @@ public void testIsValidPackageList() throws Exception {
}

// real proxy
ProxyServer proxyServer = null;
AuthAsyncProxyServlet proxyServlet;
try {
proxyServlet = new AuthAsyncProxyServlet();
proxyServer = new ProxyServer(proxyServlet);
AuthAsyncProxyServlet proxyServlet = new AuthAsyncProxyServlet();
try (ProxyServer proxyServer = new ProxyServer(proxyServlet)) {
proxyServer.start();

settings = new Settings();

assertTrue(JavadocUtil.isValidPackageList(url, settings, true));

try {
JavadocUtil.isValidPackageList(wrongUrl, settings, false);
fail();
} catch (IOException e) {
assertTrue(true);
}
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
}

Map<String, String> authentications = new HashMap<>();
authentications.put("foo", "bar");
// wrong auth
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServlet = new AuthAsyncProxyServlet(authentications);
try (ProxyServer proxyServer = new ProxyServer(proxyServlet)) {
proxyServer.start();

settings = new Settings();
Expand All @@ -334,14 +323,11 @@ public void testIsValidPackageList() throws Exception {
fail();
} catch (FileNotFoundException e) {
assertTrue(true);
} finally {
proxyServer.stop();
}

// auth proxy
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServlet = new AuthAsyncProxyServlet(authentications);
try (ProxyServer proxyServer = new ProxyServer(proxyServlet)) {
proxyServer.start();

settings = new Settings();
Expand All @@ -362,14 +348,11 @@ public void testIsValidPackageList() throws Exception {
} catch (IOException e) {
assertTrue(true);
}
} finally {
proxyServer.stop();
}

// timeout
try {
proxyServlet = new AuthAsyncProxyServlet(authentications, 3000); // more than 2000, see fetchURL
proxyServer = new ProxyServer(proxyServlet);
proxyServlet = new AuthAsyncProxyServlet(authentications, 3000); // more than 2000, see fetchURL
try (ProxyServer proxyServer = new ProxyServer(proxyServlet)) {
proxyServer.start();

settings = new Settings();
Expand All @@ -386,14 +369,11 @@ public void testIsValidPackageList() throws Exception {
fail();
} catch (SocketTimeoutException e) {
assertTrue(true);
} finally {
proxyServer.stop();
}

// nonProxyHosts
try {
proxyServlet = new AuthAsyncProxyServlet(authentications);
proxyServer = new ProxyServer(proxyServlet);
proxyServlet = new AuthAsyncProxyServlet(authentications);
try (ProxyServer proxyServer = new ProxyServer(proxyServlet)) {
proxyServer.start();

settings = new Settings();
Expand All @@ -408,8 +388,6 @@ public void testIsValidPackageList() throws Exception {
settings.addProxy(proxy);

assertTrue(JavadocUtil.isValidPackageList(url, settings, true));
} finally {
proxyServer.stop();
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/test/java/org/apache/maven/plugins/javadoc/ProxyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
* @author <a href="mailto:[email protected]">Vincent Siveton</a>
* @since 2.6
*/
class ProxyServer {
class ProxyServer implements AutoCloseable {
private Server proxyServer;

private ServerConnector serverConnector;

/**
* @param proxyServlet the wanted auth proxy servlet
*/
public ProxyServer(AuthAsyncProxyServlet proxyServlet) {
ProxyServer(AuthAsyncProxyServlet proxyServlet) {
this(null, 0, proxyServlet);
}

Expand All @@ -60,7 +60,7 @@ public ProxyServer(AuthAsyncProxyServlet proxyServlet) {
* @param port the server port
* @param proxyServlet the wanted auth proxy servlet
*/
public ProxyServer(String hostName, int port, AuthAsyncProxyServlet proxyServlet) {
ProxyServer(String hostName, int port, AuthAsyncProxyServlet proxyServlet) {
proxyServer = new Server();

serverConnector = new ServerConnector(proxyServer);
Expand Down Expand Up @@ -105,6 +105,11 @@ public void start() throws Exception {
}
}

@Override
public void close() throws Exception {
this.stop();
}

/**
* @throws Exception if any
*/
Expand All @@ -126,7 +131,7 @@ static class AuthAsyncProxyServlet extends AsyncProxyServlet {
/**
* Constructor for non authentication servlet.
*/
public AuthAsyncProxyServlet() {
AuthAsyncProxyServlet() {
super();
}

Expand All @@ -135,7 +140,7 @@ public AuthAsyncProxyServlet() {
*
* @param authentications a map of user/password
*/
public AuthAsyncProxyServlet(Map<String, String> authentications) {
AuthAsyncProxyServlet(Map<String, String> authentications) {
this();

this.authentications = authentications;
Expand All @@ -147,7 +152,7 @@ public AuthAsyncProxyServlet(Map<String, String> authentications) {
* @param authentications a map of user/password
* @param sleepTime a positive time to sleep the service thread (for timeout)
*/
public AuthAsyncProxyServlet(Map<String, String> authentications, long sleepTime) {
AuthAsyncProxyServlet(Map<String, String> authentications, long sleepTime) {
this();
this.authentications = authentications;
this.sleepTime = sleepTime;
Expand Down