org.springframework.boot.DefaultApplicationArguments Java Examples

The following examples show how to use org.springframework.boot.DefaultApplicationArguments. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebApplication.java    From TrackRay with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

		ApplicationArguments applicationArguments = new DefaultApplicationArguments(
				args);


		String releaseDir = PropertyUtil.getProperty("trackray.release.dir");
		String root = System.getProperty("user.dir");

		if (!root.contains(releaseDir)){
			System.err.println("请检查工作目录是否在配置文件指定的 "+releaseDir+" 发布目录");
			System.exit(0);
		}

		if (applicationArguments.containsOption("help")){
			help(applicationArguments);
		}else{
			run(args,applicationArguments);
		}

	}
 
Example #2
Source File: InCommandTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runCallsHandler() throws Exception {
	InRequest request = mock(InRequest.class);
	InResponse response = mock(InResponse.class);
	given(this.systemInput.read(InRequest.class)).willReturn(request);
	given(this.handler.handle(eq(request), any())).willReturn(response);
	File tempFolder = this.temporaryFolder.newFolder();
	String dir = StringUtils.cleanPath(tempFolder.getPath());
	this.command.run(new DefaultApplicationArguments(new String[] { "in", dir }));
	verify(this.handler).handle(eq(request), this.directoryCaptor.capture());
	verify(this.systemOutput).write(response);
	assertThat(this.directoryCaptor.getValue().getFile()).isEqualTo(tempFolder);
}
 
Example #3
Source File: InCommandTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runWhenFolderArgIsMissingThrowsException() throws Exception {
	InRequest request = mock(InRequest.class);
	given(this.systemInput.read(InRequest.class)).willReturn(request);
	assertThatIllegalStateException()
			.isThrownBy(() -> this.command.run(new DefaultApplicationArguments(new String[] {})))
			.withMessage("No directory argument specified");
}
 
Example #4
Source File: CheckCommandTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runCallsHandler() throws Exception {
	CheckRequest request = mock(CheckRequest.class);
	CheckResponse response = mock(CheckResponse.class);
	given(this.systemInput.read(CheckRequest.class)).willReturn(request);
	given(this.handler.handle(request)).willReturn(response);
	this.command.run(new DefaultApplicationArguments(new String[] {}));
	verify(this.handler).handle(request);
	verify(this.systemOutput).write(response);
}
 
Example #5
Source File: CommandProcessorTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runWhenUnknownCommandThrowsException() throws Exception {
	Command fooCommand = mock(Command.class);
	given(fooCommand.getName()).willReturn("foo");
	CommandProcessor processor = new CommandProcessor(Collections.singletonList(fooCommand));
	DefaultApplicationArguments args = new DefaultApplicationArguments(new String[] { "bar", "go" });
	assertThatIllegalStateException().isThrownBy(() -> processor.run(args)).withMessage("Unknown command 'bar'");
}
 
Example #6
Source File: CommandProcessorTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runDelegatesToCommand() throws Exception {
	Command fooCommand = mock(Command.class);
	given(fooCommand.getName()).willReturn("foo");
	Command barCommand = mock(Command.class);
	given(barCommand.getName()).willReturn("bar");
	CommandProcessor processor = new CommandProcessor(Arrays.asList(fooCommand, barCommand));
	DefaultApplicationArguments args = new DefaultApplicationArguments(new String[] { "bar", "go" });
	processor.run(args);
	verify(fooCommand, never()).run(any());
	verify(barCommand).run(args);
}
 
Example #7
Source File: OutCommandTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runCallsHandler() throws Exception {
	OutRequest request = mock(OutRequest.class);
	OutResponse response = mock(OutResponse.class);
	given(this.systemInput.read(OutRequest.class)).willReturn(request);
	given(this.handler.handle(eq(request), any())).willReturn(response);
	File tempFolder = this.temporaryFolder.newFolder();
	String dir = StringUtils.cleanPath(tempFolder.getPath());
	this.command.run(new DefaultApplicationArguments(new String[] { "out", dir }));
	verify(this.handler).handle(eq(request), this.directoryCaptor.capture());
	verify(this.systemOutput).write(response);
	assertThat(this.directoryCaptor.getValue().getFile()).isEqualTo(tempFolder);
}
 
Example #8
Source File: OutCommandTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void runWhenFolderArgIsMissingThrowsException() throws Exception {
	InRequest request = mock(InRequest.class);
	given(this.systemInput.read(InRequest.class)).willReturn(request);
	assertThatIllegalStateException()
			.isThrownBy(() -> this.command.run(new DefaultApplicationArguments(new String[] {})))
			.withMessage("No directory argument specified");
}
 
Example #9
Source File: DirectoryTests.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Test
public void createFromArgsUsesArgument() throws Exception {
	File file = this.temporaryFolder.newFolder();
	String path = StringUtils.cleanPath(file.getPath());
	ApplicationArguments args = new DefaultApplicationArguments(new String[] { "in", path });
	Directory directory = Directory.fromArgs(args);
	assertThat(directory.getFile()).isEqualTo(file);
}
 
Example #10
Source File: FunctionDeployerConfiguration.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private ApplicationArguments updateArguments(ApplicationArguments arguments) {
	List<String> originalArguments =  new ArrayList<String>(Arrays.asList(arguments.getSourceArgs()));

	if (arguments.containsOption("function.name")) {
		originalArguments.add(FunctionProperties.PREFIX + ".definition=" + arguments.getOptionValues("function.name").get(0));
	}
	if (arguments.containsOption("function.location")) {
		originalArguments.add(FunctionProperties.PREFIX + ".location=" + arguments.getOptionValues("function.location").get(0));
	}
	ApplicationArguments updatedArguments = new DefaultApplicationArguments(originalArguments.toArray(new String[] {}));
	return updatedArguments;
}
 
Example #11
Source File: CommandProcessorTests.java    From artifactory-resource with Apache License 2.0 4 votes vote down vote up
@Test
public void runWhenNoArgumentThrowsException() throws Exception {
	CommandProcessor processor = new CommandProcessor(Collections.singletonList(mock(Command.class)));
	assertThatIllegalStateException().isThrownBy(() -> processor.run(new DefaultApplicationArguments(NO_ARGS)))
			.withMessage("No command argument specified");
}
 
Example #12
Source File: ProgramCommand.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
public static ProgramCommand parseArgs(String[] args) {
    if (args == null) {
        throw new NullPointerException("args");
    }
    return parseArgs(new DefaultApplicationArguments(args));
}