Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-51331 Fix JEP-200 issue in ConsoleAuditLogger
- Loading branch information
Showing
2 changed files
with
90 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/test/java/hudson/plugins/audit_trail/ConsoleAuditLoggerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Alan Harder | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package hudson.plugins.audit_trail; | ||
|
||
import com.gargoylesoftware.htmlunit.html.HtmlForm; | ||
import com.gargoylesoftware.htmlunit.html.HtmlPage; | ||
import jenkins.model.Jenkins; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author <a href="mailto:tomasz.sek.88@gmail.com">Tomasz Sęk</a> | ||
*/ | ||
public class ConsoleAuditLoggerTest { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Issue("JENKINS-51331") | ||
@Test | ||
public void shouldConfigureConsoleAuditLogger() throws Exception { | ||
// Given | ||
JenkinsRule.WebClient wc = j.createWebClient(); | ||
HtmlPage configure = wc.goTo("configure"); | ||
HtmlForm form = configure.getFormByName("config"); | ||
j.getButtonByCaption(form, "Add Logger").click(); | ||
configure.getAnchorByText("Console").click(); | ||
wc.waitForBackgroundJavaScript(2000); | ||
|
||
// When | ||
j.submit(form); | ||
|
||
// Then | ||
// submit configuration page without any errors | ||
AuditTrailPlugin plugin = Jenkins.get().getPlugin(AuditTrailPlugin.class); | ||
assertEquals("amount of loggers", 1, plugin.getLoggers().size()); | ||
AuditLogger logger = plugin.getLoggers().get(0); | ||
assertTrue("ConsoleAuditLogger should be configured", logger instanceof ConsoleAuditLogger); | ||
assertEquals("output", ConsoleAuditLogger.Output.STD_OUT, ((ConsoleAuditLogger) logger).getOutput()); | ||
} | ||
} |
100da55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work reliably, see #10