Skip to content

Commit

Permalink
Fixes #3519 - Fix SonarCloud issues (#3520)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem committed Aug 15, 2023
1 parent 5d9f755 commit 4f0ef2c
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class DefaultWebApplicationManagerTest {
class DefaultWebApplicationManagerTest {

/**
* Test getAnnotationManager method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class DefaultWebApplicationRequestMappingTest {
class DefaultWebApplicationRequestMappingTest {

/**
* Test getMatchValue method.
*/
@Test
public void testGetMatchValue() {
void testGetMatchValue() {
DefaultWebApplicationRequestMapping mapping = new DefaultWebApplicationRequestMapping(null);
assertNull(mapping.getMatchValue());
mapping.setMatchValue("/match");
Expand All @@ -52,7 +52,7 @@ public void testGetMatchValue() {
* Test getPattern method.
*/
@Test
public void testGetPattern() {
void testGetPattern() {
DefaultWebApplicationRequestMapping mapping = new DefaultWebApplicationRequestMapping("/*");
assertEquals("/*", mapping.getPattern());
}
Expand All @@ -61,7 +61,7 @@ public void testGetPattern() {
* Test isExact method.
*/
@Test
public void testIsExact() {
void testIsExact() {
DefaultWebApplicationRequestMapping mapping = new DefaultWebApplicationRequestMapping("/exact");
assertFalse(mapping.isExact());
mapping.setExact(true);
Expand All @@ -72,7 +72,7 @@ public void testIsExact() {
* Test isExtension method.
*/
@Test
public void testIsExtension() {
void testIsExtension() {
DefaultWebApplicationRequestMapping mapping = new DefaultWebApplicationRequestMapping("*.html");
assertFalse(mapping.isExtension());
mapping.setExtension(true);
Expand All @@ -83,7 +83,7 @@ public void testIsExtension() {
* Test setPattern method.
*/
@Test
public void testSetPattern() {
void testSetPattern() {
DefaultWebApplicationRequestMapping mapping = new DefaultWebApplicationRequestMapping("/pattern1");
assertEquals("/pattern1", mapping.getPattern());
mapping.setPattern("/pattern2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
* @author Manfred Riem (mriem@manorrock.com)
*/
class DefaultWebConnectionTest {

/**
* Test close method.
*/
@Test
void testClose() throws Exception {
DefaultWebApplicationRequest request = new DefaultWebApplicationRequest();
DefaultWebApplicationResponse response = new DefaultWebApplicationResponse();
DefaultWebConnection connection = new DefaultWebConnection(request, response);
connection.close();
assertFalse(connection.getInputStream().isReady());
assertFalse(connection.getOutputStream().isReady());
}

/**
* Test getInputStream method.
Expand All @@ -57,17 +70,4 @@ void testGetOutputStream() throws Exception {
DefaultWebConnection connection = new DefaultWebConnection(null, response);
assertNotNull(connection.getOutputStream());
}

/**
* Test close method.
*/
@Test
public void testClose() throws Exception {
DefaultWebApplicationRequest request = new DefaultWebApplicationRequest();
DefaultWebApplicationResponse response = new DefaultWebApplicationResponse();
DefaultWebConnection connection = new DefaultWebConnection(request, response);
connection.close();
assertFalse(connection.getInputStream().isReady());
assertFalse(connection.getOutputStream().isReady());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/


public class CracFeatureTest {
class CracFeatureTest {

/**
* Test init method.
*/
@Test
public void testInit() {
void testInit() {
DefaultFeatureManager manager = new DefaultFeatureManager();
HttpFeature httpFeature = new HttpFeature();
httpFeature.setFeatureManager(manager);
Expand All @@ -65,7 +63,7 @@ public void testInit() {
* Test init method.
*/
@Test
public void testInit2() {
void testInit2() {
DefaultFeatureManager manager = new DefaultFeatureManager();
HttpsFeature httpsFeature = new HttpsFeature();
httpsFeature.setFeatureManager(manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class ExitOnStopFeatureTest {
class ExitOnStopFeatureTest {

/**
* Test stop method.
*
* @throws Exception when an error occurs.
*/
@Test
public void testStop() throws Exception {
void testStop() throws Exception {
ExitOnStopFeature feature = new ExitOnStopFeature();
feature.stop();
Thread.sleep(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.feature.https;
package cloud.piranha.feature.http;

import cloud.piranha.feature.http.HttpFeature;
import cloud.piranha.http.api.HttpServer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -41,13 +40,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class HttpFeatureTest {
class HttpFeatureTest {

/**
* Test destroy method.
*/
@Test
public void testDestroy() {
void testDestroy() {
HttpFeature feature = new HttpFeature();
feature.init();
assertNotNull(feature.getHttpServer());
Expand All @@ -64,7 +63,7 @@ public void testDestroy() {
* Test getHttpServer method.
*/
@Test
public void testGetHttpServerMethod() {
void testGetHttpServerMethod() {
HttpFeature feature = new HttpFeature();
feature.init();
HttpServer httpsServer = feature.getHttpServer();
Expand All @@ -78,7 +77,7 @@ public void testGetHttpServerMethod() {
* Test getHttpServerClass method.
*/
@Test
public void testGetHttpServerClass() {
void testGetHttpServerClass() {
HttpFeature feature = new HttpFeature();
feature.setHttpServerClass("BOGUS");
assertEquals("BOGUS", feature.getHttpServerClass());
Expand All @@ -90,7 +89,7 @@ public void testGetHttpServerClass() {
* Test getPort method.
*/
@Test
public void testGetPort() {
void testGetPort() {
HttpFeature feature = new HttpFeature();
feature.setPort(1234);
assertEquals(1234, feature.getPort());
Expand All @@ -100,7 +99,7 @@ public void testGetPort() {
* Test stop method.
*/
@Test
public void testStop() {
void testStop() {
HttpFeature feature = new HttpFeature();
feature.init();
assertFalse(feature.getHttpServer().isRunning());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class HttpsFeatureTest {
class HttpsFeatureTest {

/**
* Test destroy method.
*/
@Test
public void testDestroy() {
void testDestroy() {
HttpsFeature feature = new HttpsFeature();
feature.init();
assertNotNull(feature.getHttpsServer());
Expand All @@ -63,7 +63,7 @@ public void testDestroy() {
* Test getHttpsKeystoreFile method.
*/
@Test
public void testGetHttpsKeystoreFile() {
void testGetHttpsKeystoreFile() {
HttpsFeature feature = new HttpsFeature();
feature.setHttpsKeystoreFile("keystore");
assertEquals("keystore", feature.getHttpsKeystoreFile());
Expand All @@ -83,7 +83,7 @@ public void testGetHttpsKeystorePassword() {
* Test getHttpServer method.
*/
@Test
public void testGetHttpServerMethod() {
void testGetHttpServerMethod() {
HttpsFeature feature = new HttpsFeature();
feature.init();
HttpServer httpsServer = feature.getHttpsServer();
Expand All @@ -97,7 +97,7 @@ public void testGetHttpServerMethod() {
* Test getHttpServerClass method.
*/
@Test
public void testGetHttpServerClass() {
void testGetHttpServerClass() {
HttpsFeature feature = new HttpsFeature();
feature.setHttpsServerClass("BOGUS");
assertEquals("BOGUS", feature.getHttpsServerClass());
Expand All @@ -109,7 +109,7 @@ public void testGetHttpServerClass() {
* Test getHttpsTruststoreFile method.
*/
@Test
public void testGetHttpsTruststoreFile() {
void testGetHttpsTruststoreFile() {
HttpsFeature feature = new HttpsFeature();
feature.setHttpsTruststoreFile("truststore");
assertEquals("truststore", feature.getHttpsTruststoreFile());
Expand All @@ -119,7 +119,7 @@ public void testGetHttpsTruststoreFile() {
* Test getHttpsTruststorePassword method.
*/
@Test
public void testGetHttpsTruststorePassword() {
void testGetHttpsTruststorePassword() {
HttpsFeature feature = new HttpsFeature();
feature.setHttpsTruststorePassword("password");
assertEquals("password", feature.getHttpsTruststorePassword());
Expand All @@ -129,7 +129,7 @@ public void testGetHttpsTruststorePassword() {
* Test getPort method.
*/
@Test
public void testGetPort() {
void testGetPort() {
HttpsFeature feature = new HttpsFeature();
feature.setPort(1234);
assertEquals(1234, feature.getPort());
Expand All @@ -139,7 +139,7 @@ public void testGetPort() {
* Test stop method.
*/
@Test
public void testStop() {
void testStop() {
HttpsFeature feature = new HttpsFeature();
feature.init();
assertFalse(feature.getHttpsServer().isRunning());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class DefaultFeatureManagerTest {
class DefaultFeatureManagerTest {

/**
* Test addFeature method.
*/
@Test
public void testAddFeature() {
void testAddFeature() {
DefaultFeatureManager manager = new DefaultFeatureManager();
Feature feature = new DefaultFeature();
manager.addFeature(feature);
assertEquals(feature, manager.getFeatures().get(0));
}

/**
* Test of stop method, of class DefaultFeatureManager.
* Test stop method.
*/
@Test
public void testStop() {
void testStop() {
DefaultFeatureManager manager = new DefaultFeatureManager();
manager.addFeature(new DefaultFeature() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class DefaultFeatureTest {
class DefaultFeatureTest {

/**
* Test getFeatureManager method
*/
@Test
public void testGetFeatureManager() {
void testGetFeatureManager() {
DefaultFeature feature = new DefaultFeature();
assertNull(feature.getFeatureManager());
DefaultFeatureManager manager = new DefaultFeatureManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class LoggingFeatureTest {
class LoggingFeatureTest {

/**
* Test getLevel method.
*/
@Test
public void testGetLevel() {
void testGetLevel() {
LoggingFeature feature = new LoggingFeature();
assertNull(feature.getLevel());
feature.setLevel("SEVERE");
Expand All @@ -56,7 +56,7 @@ public void testGetLevel() {
* Test init method
*/
@Test
public void testInit() {
void testInit() {
LoggingFeature feature = new LoggingFeature();
feature.init();
assertEquals(INFO, LogManager.getLogManager().getLogger("").getLevel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
*
* @author Manfred Riem (mriem@manorrock.com)
*/
public class WebAppFeatureTest {
class WebAppFeatureTest {

/**
* Test getExtensionClass method.
*/
@Test
public void testGetExtensionClass() {
void testGetExtensionClass() {
WebAppFeature feature = new WebAppFeature();
assertNull(feature.getExtensionClass());
feature.setExtensionClass(WebApplicationExtension.class);
Expand All @@ -56,7 +56,7 @@ public void testGetExtensionClass() {
* Test getContextPath method.
*/
@Test
public void testGetContextPath() {
void testGetContextPath() {
WebAppFeature feature = new WebAppFeature();
assertNull(feature.getContextPath());
feature.setContextPath("/contextpath");
Expand All @@ -67,7 +67,7 @@ public void testGetContextPath() {
* Test getWarFile method.
*/
@Test
public void testGetWarFile() {
void testGetWarFile() {
WebAppFeature feature = new WebAppFeature();
assertNull(feature.getWarFile());
File warFile = new File("test.war");
Expand All @@ -79,7 +79,7 @@ public void testGetWarFile() {
* Test getWebAppDir method.
*/
@Test
public void testGetWebAppDir() {
void testGetWebAppDir() {
WebAppFeature feature = new WebAppFeature();
assertNull(feature.getWebAppDir());
File webAppDir = new File("test");
Expand Down

0 comments on commit 4f0ef2c

Please sign in to comment.