|
21 | 21 | import org.apache.maven.plugin.AbstractMojoExecutionException; |
22 | 22 | import org.apache.maven.plugin.MojoFailureException; |
23 | 23 | import org.eclipse.sisu.equinox.launching.internal.P2ApplicationLauncher; |
24 | | -import org.junit.Test; |
| 24 | +import org.junit.jupiter.api.Test; |
25 | 25 | import org.mockito.Mockito; |
26 | 26 |
|
27 | 27 | import java.io.File; |
28 | 28 | import java.io.IOException; |
29 | 29 | import java.util.UUID; |
30 | 30 |
|
| 31 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
31 | 32 | import static org.mockito.Mockito.when; |
32 | 33 |
|
33 | 34 | /** |
|
36 | 37 | * http://www.reficio.org |
37 | 38 | * @since 1.0.0 |
38 | 39 | */ |
39 | | -public class CategoryPublisherTest { |
| 40 | +class CategoryPublisherTest { |
40 | 41 |
|
41 | | - @Test(expected = NullPointerException.class) |
42 | | - public void nullLauncher() { |
43 | | - CategoryPublisher.builder().p2ApplicationLauncher(null); |
| 42 | + @Test |
| 43 | + void nullLauncher() { |
| 44 | + assertThrows(NullPointerException.class, () -> { |
| 45 | + CategoryPublisher.builder().p2ApplicationLauncher(null); |
| 46 | + }); |
44 | 47 | } |
45 | 48 |
|
46 | | - @Test(expected = NullPointerException.class) |
47 | | - public void emptyBuilder() { |
48 | | - CategoryPublisher.builder().build(); |
| 49 | + @Test |
| 50 | + void emptyBuilder() { |
| 51 | + assertThrows(NullPointerException.class, () -> { |
| 52 | + CategoryPublisher.builder().build(); |
| 53 | + }); |
49 | 54 | } |
50 | 55 |
|
51 | | - @Test(expected = IllegalArgumentException.class) |
52 | | - public void wrongTimeout() { |
53 | | - CategoryPublisher.builder().forkedProcessTimeoutInSeconds(-1); |
| 56 | + @Test |
| 57 | + void wrongTimeout() { |
| 58 | + assertThrows(IllegalArgumentException.class, () -> { |
| 59 | + CategoryPublisher.builder().forkedProcessTimeoutInSeconds(-1); |
| 60 | + }); |
54 | 61 | } |
55 | 62 |
|
56 | | - @Test(expected = IllegalArgumentException.class) |
57 | | - public void wrongArgs() { |
58 | | - CategoryPublisher.builder().additionalArgs("--zcx.vzxc.v§';s.dcxz-1-aods[vzmcxvlkzndofahsdpf"); |
| 63 | + @Test |
| 64 | + void wrongArgs() { |
| 65 | + assertThrows(IllegalArgumentException.class, () -> { |
| 66 | + CategoryPublisher.builder().additionalArgs("--zcx.vzxc.v§';s.dcxz-1-aods[vzmcxvlkzndofahsdpf"); |
| 67 | + }); |
59 | 68 | } |
60 | 69 |
|
61 | | - @Test(expected = MojoFailureException.class) |
62 | | - public void exceptionThrownInCaseOfLauncherFailure() throws IOException, AbstractMojoExecutionException { |
63 | | - // given |
64 | | - P2ApplicationLauncher launcher = Mockito.mock(P2ApplicationLauncher.class, Mockito.RETURNS_DEEP_STUBS); |
65 | | - when(launcher.execute(Mockito.anyInt())).thenReturn(137); |
66 | | - File file = File.createTempFile(UUID.randomUUID().toString(), UUID.randomUUID().toString()); |
67 | | - file.deleteOnExit(); |
| 70 | + @Test |
| 71 | + void exceptionThrownInCaseOfLauncherFailure() throws IOException, AbstractMojoExecutionException { |
| 72 | + assertThrows(MojoFailureException.class, () -> { |
| 73 | + // given |
| 74 | + P2ApplicationLauncher launcher = Mockito.mock(P2ApplicationLauncher.class, Mockito.RETURNS_DEEP_STUBS); |
| 75 | + when(launcher.execute(Mockito.anyInt())).thenReturn(137); |
| 76 | + File file = File.createTempFile(UUID.randomUUID().toString(), UUID.randomUUID().toString()); |
| 77 | + file.deleteOnExit(); |
68 | 78 |
|
69 | | - // when |
70 | | - CategoryPublisher publisher = CategoryPublisher.builder() |
71 | | - .p2ApplicationLauncher(launcher) |
72 | | - .categoryFileLocation(file.getPath()) |
73 | | - .additionalArgs("-args") |
74 | | - .metadataRepositoryLocation("target/tmp") |
75 | | - .build(); |
76 | | - publisher.execute(); |
| 79 | + // when |
| 80 | + CategoryPublisher publisher = CategoryPublisher.builder() |
| 81 | + .p2ApplicationLauncher(launcher) |
| 82 | + .categoryFileLocation(file.getPath()) |
| 83 | + .additionalArgs("-args") |
| 84 | + .metadataRepositoryLocation("target/tmp") |
| 85 | + .build(); |
| 86 | + publisher.execute(); |
| 87 | + }); |
77 | 88 | } |
78 | 89 |
|
79 | 90 | } |
0 commit comments