From b094f449153bf917a1eba6bf235ca283ac17d1ba Mon Sep 17 00:00:00 2001 From: Jiyang Date: Thu, 14 Mar 2024 12:40:50 -0500 Subject: [PATCH] Add new exceptional tests --- .../extension/PropertiesParserTestCase.java | 10 +++++++++ .../servlet/BaseServletProtocolTestCase.java | 10 +++++++++ .../ServletCommandServiceTestCase.java | 21 +++++++++++++++++++ ...letProtocolDeploymentPackagerTestCase.java | 5 +++++ 4 files changed, 46 insertions(+) diff --git a/config/impl-base/src/test/java/org/jboss/arquillian/config/impl/extension/PropertiesParserTestCase.java b/config/impl-base/src/test/java/org/jboss/arquillian/config/impl/extension/PropertiesParserTestCase.java index 34ca67e4e..d9fab4230 100644 --- a/config/impl-base/src/test/java/org/jboss/arquillian/config/impl/extension/PropertiesParserTestCase.java +++ b/config/impl-base/src/test/java/org/jboss/arquillian/config/impl/extension/PropertiesParserTestCase.java @@ -468,6 +468,16 @@ public String get() { }); } + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfDescriptorIsNull() { + new PropertiesParser().addProperties(null, System.getProperties()); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfPropertiesIsNull() { + new PropertiesParser().addProperties(desc, null); + } + private void validate(String property, String value, ValueCallback callback) { validate(property, value, value, callback); } diff --git a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/BaseServletProtocolTestCase.java b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/BaseServletProtocolTestCase.java index c7f8464be..bcbf4c077 100644 --- a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/BaseServletProtocolTestCase.java +++ b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/BaseServletProtocolTestCase.java @@ -121,6 +121,16 @@ public void shouldThrowExceptionOnMissingNamedTargetedContext() throws Exception handler.locateTestServlet(testMethod); } + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionWhenNoConfig() throws Exception { + new ServletURIHandler(null, to(new HTTPContext("127.0.0.1", 8080).add(new Servlet(ServletMethodExecutor.ARQUILLIAN_SERVLET_NAME, "test")))); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionOnNoContexts() throws Exception { + new ServletURIHandler(new ServletProtocolConfiguration(), null); + } + private Collection to(HTTPContext... inputs) { List contexts = new ArrayList(); Collections.addAll(contexts, inputs); diff --git a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ServletCommandServiceTestCase.java b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ServletCommandServiceTestCase.java index a53317748..612a96bc0 100644 --- a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ServletCommandServiceTestCase.java +++ b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ServletCommandServiceTestCase.java @@ -103,4 +103,25 @@ public void shouldDisableCommandService() throws Exception { "Timeout exception should have been thrown", result.getThrowable().getMessage().contains("timeout")); } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfNoConfig() throws Exception { + new ServletMethodExecutor(null, createContexts(), new TestCommandCallback()); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfNoContexts() { + new ServletMethodExecutor(new ServletProtocolConfiguration(), null, new TestCommandCallback()); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfNoCallback() throws Exception { + new ServletMethodExecutor(new ServletProtocolConfiguration(), createContexts(), null); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionIfNoExecutor() throws Exception { + ServletMethodExecutor executor = new ServletMethodExecutor(new ServletProtocolConfiguration(), createContexts(), new TestCommandCallback()); + executor.invoke(null); + } } diff --git a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/v_2_5/ServletProtocolDeploymentPackagerTestCase.java b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/v_2_5/ServletProtocolDeploymentPackagerTestCase.java index 4772eac0a..0328751a0 100644 --- a/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/v_2_5/ServletProtocolDeploymentPackagerTestCase.java +++ b/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/v_2_5/ServletProtocolDeploymentPackagerTestCase.java @@ -302,6 +302,11 @@ public void shouldThrowExceptionOnEnterpriseArchiveWithMultipleMarkedWebArchives processors()); } + @Test(expected = IllegalArgumentException.class) + public void shouldVerifyExceptionOnEmptyVersion() throws Exception { + Descriptors.create(WebAppDescriptor.class).version(""); + } + private Collection> createAuxiliaryArchives() { List> archives = new ArrayList>(); archives.add(ShrinkWrap.create(JavaArchive.class, "auxiliaryArchive1.jar"));