Java Code Examples for org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties#StubsMode

The following examples show how to use org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties#StubsMode . 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: MavenContractsDownloader.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
MavenContractsDownloader(MavenProject project, Dependency contractDependency,
		String contractsPath, String contractsRepositoryUrl,
		StubRunnerProperties.StubsMode stubsMode, Log log, String repositoryUsername,
		String repositoryPassword, String repositoryProxyHost,
		Integer repositoryProxyPort, boolean deleteStubsAfterTest,
		Map<String, String> contractsProperties, boolean failOnNoContracts) {
	this.project = project;
	this.contractDependency = contractDependency;
	this.contractsPath = contractsPath;
	this.contractsRepositoryUrl = contractsRepositoryUrl;
	this.stubsMode = stubsMode;
	this.log = log;
	this.repositoryUsername = repositoryUsername;
	this.repositoryPassword = repositoryPassword;
	this.repositoryProxyHost = repositoryProxyHost;
	this.repositoryProxyPort = repositoryProxyPort;
	this.stubDownloaderBuilderProvider = new StubDownloaderBuilderProvider();
	this.deleteStubsAfterTest = deleteStubsAfterTest;
	this.contractsProperties = contractsProperties;
	this.failOnNoStubs = failOnNoContracts;
}
 
Example 2
Source File: StubRunnerOptionsBuilder.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
public StubRunnerOptionsBuilder withStubsMode(
		StubRunnerProperties.StubsMode stubsMode) {
	if (stubsMode == null) {
		return this;
	}
	this.stubsMode = stubsMode;
	return this;
}
 
Example 3
Source File: StubRunnerOptions.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
StubRunnerOptions(Integer minPortValue, Integer maxPortValue,
		Resource stubRepositoryRoot, StubRunnerProperties.StubsMode stubsMode,
		String stubsClassifier, Collection<StubConfiguration> dependencies,
		Map<StubConfiguration, Integer> stubIdsToPortMapping, String username,
		String password, final StubRunnerProxyOptions stubRunnerProxyOptions,
		boolean stubsPerConsumer, String consumerName, String mappingsOutputFolder,
		boolean deleteStubsAfterTest, boolean generateStubs, boolean failOnNoStubs,
		Map<String, String> properties,
		Class<? extends HttpServerStubConfigurer> httpServerStubConfigurer,
		String serverId) {
	this.minPortValue = minPortValue;
	this.maxPortValue = maxPortValue;
	this.stubRepositoryRoot = stubRepositoryRoot;
	this.stubsMode = stubsMode != null ? stubsMode
			: StubRunnerProperties.StubsMode.CLASSPATH;
	this.stubsClassifier = stubsClassifier;
	this.dependencies = dependencies;
	this.stubIdsToPortMapping = stubIdsToPortMapping;
	this.username = username;
	this.password = password;
	this.stubRunnerProxyOptions = stubRunnerProxyOptions;
	this.stubsPerConsumer = stubsPerConsumer;
	this.consumerName = consumerName;
	this.mappingsOutputFolder = mappingsOutputFolder;
	this.deleteStubsAfterTest = deleteStubsAfterTest;
	this.generateStubs = generateStubs;
	this.failOnNoStubs = failOnNoStubs;
	this.properties = properties;
	this.httpServerStubConfigurer = httpServerStubConfigurer;
	this.serverId = serverId;
}
 
Example 4
Source File: StubRunnerMain.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
private StubRunnerMain(String[] args) throws Exception {
	OptionParser parser = new OptionParser();
	try {
		ArgumentAcceptingOptionSpec<Integer> minPortValueOpt = parser.acceptsAll(
				Arrays.asList("minp", "minPort"),
				"Minimum port value to be assigned to the WireMock instance. Defaults to 10000")
				.withRequiredArg().ofType(Integer.class).defaultsTo(10000);
		ArgumentAcceptingOptionSpec<Integer> maxPortValueOpt = parser.acceptsAll(
				Arrays.asList("maxp", "maxPort"),
				"Maximum port value to be assigned to the WireMock instance. Defaults to 15000")
				.withRequiredArg().ofType(Integer.class).defaultsTo(15000);
		ArgumentAcceptingOptionSpec<String> stubsOpt = parser.acceptsAll(
				Arrays.asList("s", "stubs"),
				"Comma separated list of Ivy representation "
						+ "of jars with stubs. Eg. groupid:artifactid1,groupid2:artifactid2:classifier")
				.withRequiredArg();
		ArgumentAcceptingOptionSpec<String> classifierOpt = parser.acceptsAll(
				Arrays.asList("c", "classifier"),
				"Suffix for the jar containing stubs (e.g. 'stubs' "
						+ "if the stub jar would have a 'stubs' classifier for stubs: foobar-stubs ). Defaults to 'stubs'")
				.withRequiredArg().defaultsTo("stubs");
		ArgumentAcceptingOptionSpec<String> rootOpt = parser.acceptsAll(
				Arrays.asList("r", "root"),
				"Location of a Jar containing server where you keep "
						+ "your stubs (e.g. https://nexus.net/content/repositories/repository)")
				.withRequiredArg();
		ArgumentAcceptingOptionSpec<String> usernameOpt = parser
				.acceptsAll(Arrays.asList("u", "username"),
						"Username to user when connecting to repository")
				.withOptionalArg();
		ArgumentAcceptingOptionSpec<String> passwordOpt = parser
				.acceptsAll(Arrays.asList("p", "password"),
						"Password to user when connecting to repository")
				.withOptionalArg();
		ArgumentAcceptingOptionSpec<String> proxyHostOpt = parser
				.acceptsAll(Arrays.asList("phost", "proxyHost"),
						"Proxy host to use for repository requests")
				.withOptionalArg();
		ArgumentAcceptingOptionSpec<Integer> proxyPortOpt = parser
				.acceptsAll(Arrays.asList("pport", "proxyPort"),
						"Proxy port to use for repository requests")
				.withOptionalArg().ofType(Integer.class);
		ArgumentAcceptingOptionSpec<String> stubsMode = parser
				.acceptsAll(Arrays.asList("sm", "stubsMode"),
						"Stubs mode to be used. Acceptable values " + Arrays
								.toString(StubRunnerProperties.StubsMode.values()))
				.withRequiredArg()
				.defaultsTo(StubRunnerProperties.StubsMode.CLASSPATH.toString());
		OptionSet options = parser.parse(args);
		String stubs = options.valueOf(stubsOpt);
		StubRunnerProperties.StubsMode stubsModeValue = StubRunnerProperties.StubsMode
				.valueOf(options.valueOf(stubsMode));
		Integer minPortValue = options.valueOf(minPortValueOpt);
		Integer maxPortValue = options.valueOf(maxPortValueOpt);
		String stubRepositoryRoot = options.valueOf(rootOpt);
		String stubsSuffix = options.valueOf(classifierOpt);
		final String username = options.valueOf(usernameOpt);
		final String password = options.valueOf(passwordOpt);
		final String proxyHost = options.valueOf(proxyHostOpt);
		final Integer proxyPort = options.valueOf(proxyPortOpt);
		final StubRunnerOptionsBuilder builder = new StubRunnerOptionsBuilder()
				.withMinMaxPort(minPortValue, maxPortValue)
				.withStubRepositoryRoot(stubRepositoryRoot)
				.withStubsMode(stubsModeValue).withStubsClassifier(stubsSuffix)
				.withUsername(username).withPassword(password).withStubs(stubs);
		if (proxyHost != null) {
			builder.withProxy(proxyHost, proxyPort);
		}
		StubRunnerOptions stubRunnerOptions = builder.build();
		this.arguments = new Arguments(stubRunnerOptions);
	}
	catch (Exception e) {
		printErrorMessage(e, parser);
		throw e;
	}
}
 
Example 5
Source File: StubRunnerOptions.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
public StubRunnerProperties.StubsMode getStubsMode() {
	return this.stubsMode;
}
 
Example 6
Source File: ContractVerifierExtension.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
public Property<StubRunnerProperties.StubsMode> getContractsMode() {
	return contractsMode;
}
 
Example 7
Source File: ContractVerifierExtension.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
public void setContractsMode(StubRunnerProperties.StubsMode contractsMode) {
	this.contractsMode.set(contractsMode);
}