Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

JarExtractorTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SonarQube Runner - API
  3. * Copyright (C) 2011 SonarSource
  4. * sonarqube@googlegroups.com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.runner.impl;
  21. import org.apache.commons.io.FileUtils;
  22. import org.junit.Test;
  23. import java.io.File;
  24. import static org.fest.assertions.Assertions.assertThat;
  25. import static org.fest.assertions.Fail.fail;
  26. public class JarExtractorTest {
  27. @Test
  28. public void test_extract() throws Exception {
  29. File jarFile = new JarExtractor().extractToTemp("fake");
  30. assertThat(jarFile).isFile().exists();
  31. assertThat(FileUtils.readFileToString(jarFile, "UTF-8")).isEqualTo("Fake jar for unit tests");
  32. assertThat(jarFile.toURI().toURL().toString()).doesNotContain("jar:file");
  33. }
  34. @Test
  35. public void should_fail_to_extract() throws Exception {
  36. try {
  37. new JarExtractor().extractToTemp("unknown");
  38. fail();
  39. } catch (IllegalStateException e) {
  40. assertThat(e).hasMessage("Fail to extract unknown.jar");
  41. }
  42. }
  43. }