Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 9 new exceptional tests #541

Merged
merged 1 commit into from Mar 14, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -468,6 +468,16 @@ public String get() {
});
}

@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionIfDescriptorIsNull() {
new PropertiesParser().addProperties(null, System.getProperties());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is completly off in all the changes FYI, please fix this next time. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, even worse, these are tabs, but unfortunately, this project uses spaces...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, even worse, these are tabs, but unfortunately, this project uses spaces...

Nothing unfortunate about that. It's what Charles Babbage would have wanted... :P

}

@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);
}
Expand Down
Expand Up @@ -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<HTTPContext> to(HTTPContext... inputs) {
List<HTTPContext> contexts = new ArrayList<HTTPContext>();
Collections.addAll(contexts, inputs);
Expand Down
Expand Up @@ -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);
}
}
Expand Up @@ -302,6 +302,11 @@ public void shouldThrowExceptionOnEnterpriseArchiveWithMultipleMarkedWebArchives
processors());
}

@Test(expected = IllegalArgumentException.class)
public void shouldVerifyExceptionOnEmptyVersion() throws Exception {
Descriptors.create(WebAppDescriptor.class).version("");
}

private Collection<Archive<?>> createAuxiliaryArchives() {
List<Archive<?>> archives = new ArrayList<Archive<?>>();
archives.add(ShrinkWrap.create(JavaArchive.class, "auxiliaryArchive1.jar"));
Expand Down