|
| 1 | +/** |
| 2 | + * Copyright 2012-2019 The Feign Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 5 | + * in compliance with the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 10 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 11 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 12 | + * the License. |
| 13 | + */ |
| 14 | +package feign.example.wikipedia; |
| 15 | + |
| 16 | +import static org.junit.Assert.assertThat; |
| 17 | +import org.apache.commons.exec.CommandLine; |
| 18 | +import org.apache.commons.exec.DefaultExecutor; |
| 19 | +import org.hamcrest.CoreMatchers; |
| 20 | +import org.junit.Test; |
| 21 | +import java.io.File; |
| 22 | +import java.util.Arrays; |
| 23 | + |
| 24 | +/** |
| 25 | + * Run main for {@link WikipediaExampleIT} |
| 26 | + */ |
| 27 | +public class WikipediaExampleIT { |
| 28 | + |
| 29 | + @Test |
| 30 | + public void runMain() throws Exception { |
| 31 | + final String jar = Arrays.stream(new File("target").listFiles()) |
| 32 | + .filter(file -> file.getName().startsWith("feign-example-wikipedia") |
| 33 | + && file.getName().endsWith(".jar")) |
| 34 | + .findFirst() |
| 35 | + .map(File::getAbsolutePath) |
| 36 | + .get(); |
| 37 | + |
| 38 | + final String line = "java -jar " + jar; |
| 39 | + final CommandLine cmdLine = CommandLine.parse(line); |
| 40 | + final int exitValue = new DefaultExecutor().execute(cmdLine); |
| 41 | + |
| 42 | + assertThat(exitValue, CoreMatchers.equalTo(0)); |
| 43 | + } |
| 44 | + |
| 45 | +} |
0 commit comments