Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 06420d1

Browse files
committed
Revert "Add tests for shell 'app register' commands"
This reverts commit 95114a3.
1 parent c6efe32 commit 06420d1

File tree

4 files changed

+25
-173
lines changed

4 files changed

+25
-173
lines changed

spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/command/AppRegistryCommands.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ public String unregister(
182182

183183
List<AppRegistrationResource> appRegistrations = findAllAppsByNameAndType(name, type);
184184
Optional<AppRegistrationResource> defaultApp = appRegistrations.stream()
185-
.filter(AppRegistrationResource::getDefaultVersion).findFirst();
185+
.filter(a -> a.getDefaultVersion() == true).findFirst();
186186

187187
if (!CollectionUtils.isEmpty(appRegistrations) && !defaultApp.isPresent()) {
188-
String appVersions = appRegistrations.stream().map(AppRegistrationResource::getVersion)
188+
String appVersions = appRegistrations.stream().map(app -> app.getVersion())
189189
.collect(Collectors.joining(", ", "(", ")"));
190190
return String.format("Successfully unregistered application '%s' with type '%s'. " +
191191
"Please select new default version from: %s", name, type, appVersions);
@@ -240,7 +240,7 @@ public String defaultApplication(
240240
public String register(
241241
@ShellOption(value = { "", "--name" }, help = "the name for the registered application") String name,
242242
@ShellOption(help = "the type for the registered application", valueProvider = EnumValueProvider.class) ApplicationType type,
243-
@ShellOption(value = { "-b", "--bootVersion" }, help = "the boot version to use for the registered application", defaultValue = ShellOption.NULL) AppBootSchemaVersion bootVersion,
243+
@ShellOption(value = { "-bv", "--bootVersion" }, help = "the boot version to use for the registered application", defaultValue = ShellOption.NULL) AppBootSchemaVersion bootVersion,
244244
@ShellOption(help = "URI for the application artifact") String uri,
245245
@ShellOption(value = { "-m", "--metadata-uri", "--metadataUri"}, help = "Metadata URI for the application artifact", defaultValue = ShellOption.NULL) String metadataUri,
246246
@ShellOption(help = "force update if application is already registered (only if not in use)", defaultValue = "false") boolean force) {
@@ -275,7 +275,7 @@ public Object list(
275275
List<String> column = mappings.get(appRegistration.getType());
276276
String value = appRegistration.getName();
277277
if (application != null) {
278-
String version = StringUtils.hasLength(appRegistration.getVersion()) ? ("-" + appRegistration.getVersion()) : "";
278+
String version = StringUtils.isEmpty(appRegistration.getVersion()) ? "" : "-"+appRegistration.getVersion();
279279
value = value + version;
280280
if (appRegistration.getDefaultVersion()) {
281281
value = String.format("> %s <", value);
@@ -333,7 +333,7 @@ public String importFromResource(
333333
try {
334334
Resource resource = this.resourceLoader.getResource(uri);
335335
Properties applications = PropertiesLoaderUtils.loadProperties(resource);
336-
PagedModel<AppRegistrationResource> registered;
336+
PagedModel<AppRegistrationResource> registered = null;
337337
try {
338338
registered = appRegistryOperations().registerAll(applications, force);
339339
}

spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/converter/AppBootSchemaVersionConverter.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

spring-cloud-dataflow-shell-core/src/test/java/org/springframework/cloud/dataflow/shell/AbstractShellIntegrationTest.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
import org.springframework.cloud.skipper.client.SkipperClient;
3333
import org.springframework.context.ApplicationContext;
3434
import org.springframework.shell.Shell;
35-
import org.springframework.test.util.TestSocketUtils;
3635
import org.springframework.util.AlternativeJdkIdGenerator;
3736
import org.springframework.util.IdGenerator;
37+
import org.springframework.util.SocketUtils;
3838

3939
/**
4040
* Base class for shell integration tests. This class sets up and tears down the
4141
* infrastructure required for executing shell tests - in particular, the Data Flow
4242
* server.
43+
*
4344
* Extensions of this class may obtain instances of command templates. For example, call
4445
* {@link #stream} to obtain a {@link StreamCommandTemplate} in order to perform stream
4546
* operations.
@@ -67,7 +68,7 @@ public abstract class AbstractShellIntegrationTest {
6768
/**
6869
* TCP port for the server.
6970
*/
70-
private static final int serverPort = TestSocketUtils.findAvailableTcpPort();
71+
private static final int serverPort = SocketUtils.findAvailableTcpPort();
7172

7273
/**
7374
* Application context for server application.
@@ -106,30 +107,39 @@ public abstract class AbstractShellIntegrationTest {
106107
@BeforeClass
107108
public static void startUp() {
108109
if (applicationContext == null) {
109-
shutdownAfterRun = Boolean.parseBoolean(System.getProperty(SHUTDOWN_AFTER_RUN, "false"));
110-
int randomPort = TestSocketUtils.findAvailableTcpPort();
110+
if (System.getProperty(SHUTDOWN_AFTER_RUN) != null) {
111+
shutdownAfterRun = Boolean.getBoolean(SHUTDOWN_AFTER_RUN);
112+
}
113+
114+
SpringApplication application = new SpringApplicationBuilder(TestConfig.class).build();
115+
116+
int randomPort = SocketUtils.findAvailableTcpPort();
111117
String dataFlowUri = String.format("--dataflow.uri=http://localhost:%s", serverPort);
112118
String dataSourceUrl = String.format("jdbc:h2:tcp://localhost:%s/mem:dataflow", randomPort);
113-
SpringApplication application = new SpringApplicationBuilder(TestConfig.class).build();
114119
applicationContext = application.run(String.format("--server.port=%s", serverPort), dataFlowUri,
115120
"--spring.jmx.default-domain=" + System.currentTimeMillis(), "--spring.jmx.enabled=false",
116121
"--security.basic.enabled=false", "--spring.main.show_banner=false",
117122
"--spring.cloud.config.enabled=false",
118123
"--spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration,org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration,org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundryDeployerAutoConfiguration,org.springframework.cloud.deployer.spi.kubernetes.KubernetesAutoConfiguration",
119124
"--spring.datasource.url=" + dataSourceUrl,
120125
"--spring.cloud.dataflow.features.schedules-enabled=true");
126+
121127
Shell shell = applicationContext.getBean(Shell.class);
128+
122129
skipperClient = applicationContext.getBean(SkipperClient.class);
123130
commandRunner = new ShellCommandRunner(shell);
124131
}
125132
}
126133

127134
@AfterClass
128135
public static void shutdown() {
129-
if (shutdownAfterRun && applicationContext != null) {
130-
logger.info("Stopping Data Flow Server");
131-
SpringApplication.exit(applicationContext);
132-
applicationContext = null;
136+
if (shutdownAfterRun) {
137+
if (applicationContext != null) {
138+
logger.info("Stopping Data Flow Server");
139+
SpringApplication.exit(applicationContext);
140+
141+
applicationContext = null;
142+
}
133143
}
134144
}
135145

@@ -187,14 +197,6 @@ protected JobCommandTemplate job() {
187197
return new JobCommandTemplate(commandRunner);
188198
}
189199

190-
/**
191-
* Gets the configured shell command runner.
192-
* @return the configured shell command runner
193-
*/
194-
protected ShellCommandRunner commandRunner() {
195-
return commandRunner;
196-
}
197-
198200
/**
199201
* Return a unique random name for stream/task testing.
200202
*
@@ -219,3 +221,4 @@ protected String generateUniqueStreamOrTaskName() {
219221
}
220222

221223
}
224+

spring-cloud-dataflow-shell-core/src/test/java/org/springframework/cloud/dataflow/shell/command/AppRegistryCommandsTests.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)