/src/test/java/jenkins/plugins/shiningpanda/command/TestWindowsCommand.java

https://github.com/jenkinsci/shiningpanda-plugin · Java · 39 lines · 13 code · 5 blank · 21 comment · 0 complexity · 26fcf6e5118b3985065fd910f35d2966 MD5 · raw file

  1. /*
  2. * ShiningPanda plug-in for Jenkins
  3. * Copyright (C) 2011-2015 ShiningPanda S.A.S.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of its license which incorporates the terms and
  7. * conditions of version 3 of the GNU Affero General Public License,
  8. * supplemented by the additional permissions under the GNU Affero GPL
  9. * version 3 section 7: if you modify this program, or any covered work,
  10. * by linking or combining it with other code, such other code is not
  11. * for that reason alone subject to any of the requirements of the GNU
  12. * Affero GPL version 3.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * license for more details.
  18. *
  19. * You should have received a copy of the license along with this program.
  20. * If not, see <https://raw.github.com/jenkinsci/shiningpanda-plugin/master/LICENSE.txt>.
  21. */
  22. package jenkins.plugins.shiningpanda.command;
  23. import junit.framework.TestCase;
  24. public class TestWindowsCommand extends TestCase {
  25. public void testConvertCommand() throws Exception {
  26. WindowsCommand command = new WindowsCommand("Hello ${Who} and $Who!\nls toto/tutu", true, true);
  27. assertEquals("Hello %Who% and %Who%!\nls toto\\tutu\r\nexit %ERRORLEVEL%", command.getContents());
  28. }
  29. public void testDoNotConvertCommand() throws Exception {
  30. String contents = "Hello ${Who} and $Who2!\nls toto/tutu";
  31. WindowsCommand command = new WindowsCommand(contents, true, false);
  32. assertEquals(contents + "\r\nexit %ERRORLEVEL%", command.getContents());
  33. }
  34. }