File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
main/java/org/springframework/boot/cli/command/jar
test/java/org/springframework/boot/cli Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ protected void run(OptionSet options) throws Exception {
110
110
"The name of the resulting jar and at least one source file must be specified" );
111
111
112
112
File output = new File ((String ) nonOptionArguments .remove (0 ));
113
+ Assert .isTrue (output .getName ().toLowerCase ().endsWith (".jar" ), "The output '"
114
+ + output + "' is not a JAR file." );
113
115
deleteIfExists (output );
114
116
115
117
GroovyCompiler compiler = createCompiler (options );
Original file line number Diff line number Diff line change 35
35
import org .springframework .boot .cli .command .AbstractCommand ;
36
36
import org .springframework .boot .cli .command .OptionParsingCommand ;
37
37
import org .springframework .boot .cli .command .grab .GrabCommand ;
38
+ import org .springframework .boot .cli .command .jar .JarCommand ;
38
39
import org .springframework .boot .cli .command .run .RunCommand ;
39
40
import org .springframework .boot .cli .command .test .TestCommand ;
40
41
import org .springframework .boot .cli .util .OutputCapture ;
@@ -82,6 +83,12 @@ public String grab(String... args) throws Exception {
82
83
return getOutput ();
83
84
}
84
85
86
+ public String jar (String ... args ) throws Exception {
87
+ Future <JarCommand > future = submitCommand (new JarCommand (), args );
88
+ this .commands .add (future .get (this .timeout , TimeUnit .MILLISECONDS ));
89
+ return getOutput ();
90
+ }
91
+
85
92
private <T extends OptionParsingCommand > Future <T > submitCommand (final T command ,
86
93
String ... args ) {
87
94
final String [] sources = getSources (args );
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2012-2013 the original author or authors.
2
+ * Copyright 2012-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
19
19
import org .junit .Rule ;
20
20
import org .junit .Test ;
21
+ import org .junit .rules .ExpectedException ;
21
22
22
23
import static org .hamcrest .Matchers .containsString ;
23
24
import static org .junit .Assert .assertThat ;
@@ -32,6 +33,9 @@ public class ReproIntegrationTests {
32
33
@ Rule
33
34
public CliTester cli = new CliTester ("src/test/resources/repro-samples/" );
34
35
36
+ @ Rule
37
+ public ExpectedException thrown = ExpectedException .none ();
38
+
35
39
@ Test
36
40
public void grabAntBuilder () throws Exception {
37
41
this .cli .run ("grab-ant-builder.groovy" );
@@ -54,4 +58,10 @@ public void shellDependencies() throws Exception {
54
58
containsString ("{\" message\" :\" Hello World\" }" ));
55
59
}
56
60
61
+ @ Test
62
+ public void jarFileExtensionNeeded () throws Exception {
63
+ this .thrown .expect (IllegalStateException .class );
64
+ this .thrown .expectMessage ("is not a JAR file" );
65
+ this .cli .jar ("secure.groovy" , "crsh.groovy" );
66
+ }
57
67
}
You can’t perform that action at this time.
0 commit comments