From f31e131f6f386d4810f5ab3dca7f7a3aecc3992e Mon Sep 17 00:00:00 2001 From: saivivek mac Date: Tue, 9 Jul 2024 09:36:53 -0700 Subject: [PATCH] temporary fixes for issues --- pom.xml | 90 +++++++---- .../java/com/gw/GeoweaverApplication.java | 30 ++-- src/main/java/com/gw/jpa/Checkpoint.java | 8 +- .../java/com/gw/server/FileUploadServlet.java | 7 +- .../com/gw/ssh/SecurityConfiguration.java | 148 +++++++++++++----- .../com/gw/web/GoogleEarthController.java | 48 +++--- .../java/com/gw/web/JupyterController.java | 130 ++++++++++----- src/main/resources/application.properties | 8 +- src/test/java/com/gw/CLITests.java | 27 ++-- 9 files changed, 329 insertions(+), 167 deletions(-) diff --git a/pom.xml b/pom.xml index 2f7b97f0a..c3462c17c 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.6.3 - 2.4.13 + 3.0.12.RELEASE @@ -108,6 +108,17 @@ 2.1.4 + + org.springframework.boot + spring-boot-starter-mail + + + + org.apache.httpcomponents.client5 + httpclient5 + + + org.postgresql @@ -168,16 +179,21 @@ test - - io.springfox - springfox-swagger2 - 3.0.0 - + + + + + + + + + + - io.springfox - springfox-boot-starter - 3.0.0 + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.3.0 @@ -191,11 +207,18 @@ jtar 2.3 - - javax.mail - mail - 1.4.5 + + + + + + + + com.sun.mail + jakarta.mail + 2.0.1 + com.google.apis google-api-services-gmail @@ -279,11 +302,11 @@ commons-codec - - commons-httpclient - commons-httpclient - 3.1 - + + + + + com.googlecode.json-simple json-simple @@ -361,24 +384,31 @@ jakarta.websocket-api - - javax.websocket - javax.websocket-client-api - 1.0 - + + + + + org.glassfish.tyrus.bundles tyrus-standalone-client - 1.17 - - - - org.apache.tomcat - juli - 6.0.26 + 2.1.3 + + + + + + + + + + + + + com.github.oshi oshi-core diff --git a/src/main/java/com/gw/GeoweaverApplication.java b/src/main/java/com/gw/GeoweaverApplication.java index 6f034d18e..ad2c6282a 100644 --- a/src/main/java/com/gw/GeoweaverApplication.java +++ b/src/main/java/com/gw/GeoweaverApplication.java @@ -21,15 +21,17 @@ import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +//import springfox.documentation.builders.PathSelectors; +//import springfox.documentation.builders.RequestHandlerSelectors; +//import springfox.documentation.spi.DocumentationType; +//import springfox.documentation.spring.web.plugins.Docket; +//import springfox.documentation.swagger2.annotations.EnableSwagger2; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springdoc.core.models.GroupedOpenApi; @SpringBootApplication @ServletComponentScan -@EnableSwagger2 public class GeoweaverApplication { static Logger logger = Logger.getLogger(GeoweaverApplication.class); @@ -70,12 +72,16 @@ public static void main(String[] args) { } @Bean - public Docket geoweaverAPI() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); + public OpenAPI geoweaverAPI() { +// return new Docket(DocumentationType.SWAGGER_2) +// .select() +// .apis(RequestHandlerSelectors.any()) +// .paths(PathSelectors.any()) +// .build(); + return new OpenAPI() + .info(new Info().title("Your API Title") + .description("Your API Description") + .version("1.0")); } public static void addLocalhost() { diff --git a/src/main/java/com/gw/jpa/Checkpoint.java b/src/main/java/com/gw/jpa/Checkpoint.java index 3e5b7c7b6..7f9687e6f 100644 --- a/src/main/java/com/gw/jpa/Checkpoint.java +++ b/src/main/java/com/gw/jpa/Checkpoint.java @@ -15,8 +15,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.hibernate.annotations.GenericGenerator; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.UuidGenerator; import java.util.Date; import java.util.UUID; @@ -29,9 +28,8 @@ public class Checkpoint { @Id - @GeneratedValue(generator = "uuid2") - @GenericGenerator(name = "uuid2", strategy = "uuid2") - @Type(uuid-char.class) + @GeneratedValue + @UuidGenerator @Column(name = "id", columnDefinition = "VARCHAR(36)") private UUID id; diff --git a/src/main/java/com/gw/server/FileUploadServlet.java b/src/main/java/com/gw/server/FileUploadServlet.java index 5c2380d38..9f1d3383c 100644 --- a/src/main/java/com/gw/server/FileUploadServlet.java +++ b/src/main/java/com/gw/server/FileUploadServlet.java @@ -13,6 +13,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.RequestContext; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.slf4j.Logger; @@ -86,8 +87,8 @@ public void init(ServletConfig config) throws ServletException { /** * Processes requests for both HTTP GET and POST methods. * - * @param request servlet request - * @param response servlet response + * @param req servlet request + * @param res servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @@ -115,7 +116,7 @@ protected void processRequest(HttpServletRequest req, HttpServletResponse res) // 2000M // upload.setSizeMax(maxvol * 1024 * 1024); // HTTP - List fileItems = upload.parseRequest(req); + List fileItems = null;//upload.parseRequest((RequestContext) req); Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); diff --git a/src/main/java/com/gw/ssh/SecurityConfiguration.java b/src/main/java/com/gw/ssh/SecurityConfiguration.java index dea261e9a..c6bddf409 100644 --- a/src/main/java/com/gw/ssh/SecurityConfiguration.java +++ b/src/main/java/com/gw/ssh/SecurityConfiguration.java @@ -1,66 +1,140 @@ -package com.gw.ssh; +//package com.gw.ssh; +// +//import static org.springframework.security.config.Customizer.withDefaults; +// +//import java.util.Arrays; +//import org.apache.log4j.Logger; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +//import org.springframework.security.config.annotation.web.builders.HttpSecurity; +//import org.springframework.security.config.annotation.web.builders.WebSecurity; +//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +//import org.springframework.security.crypto.password.PasswordEncoder; +//import org.springframework.web.cors.CorsConfiguration; +//import org.springframework.web.cors.CorsConfigurationSource; +//import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +// +//// import com.gw.tools.SessionManager; +// +//@Configuration +//@EnableWebSecurity +//public class SecurityConfiguration extends WebSecurityConfigurerAdapter { +// +// protected final Logger log = Logger.getLogger(getClass()); +// +// @Bean +// public SSHAuthenticationProvider sshAuthentication() { +// SSHAuthenticationProvider sshAuthentication = new SSHAuthenticationProvider(); +// return sshAuthentication; +// } +// +// /* +// * TODO - use 'registerAuthentication' in 3.2.0.RC1 and 'configure' in 3.2.0.RELEASE +// * but note that 'configure' does not appear to work in tomcat7 +// */ +// /*~~(Migrate manually based on https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter)~~>*/@Override +// protected void configure(AuthenticationManagerBuilder auth) throws Exception { +// log.info("registering SSH authentication provider"); +// auth.authenticationProvider(sshAuthentication()); +// } +// +// /** +// * WebSecurity is used to ask Spring Security to bypass the following resources WebSecurity is +// * based on HttpSecurity +// */ +// @Override +// public void configure(WebSecurity builder) throws Exception {} +// +// @Override +// protected void configure(HttpSecurity http) throws Exception { +// +// http.authorizeRequests(requests -> requests +// .formLogin(login -> login +// .loginProcessingUrl("/Geoweaver/users/login")) +// .logout(withDefaults())); +// +// http.cors(cors -> cors.csrf(csrf -> csrf.disable())); +// +// http.headers(withDefaults()); +// +// http.headers(withDefaults()); // this must be turned off to make the JupyterHub work +// } +// +// @Bean +// CorsConfigurationSource corsConfigurationSource() { +// CorsConfiguration configuration = new CorsConfiguration(); +// configuration.setAllowedOriginPatterns(Arrays.asList("*")); +// configuration.setAllowedMethods(Arrays.asList("*")); +// configuration.setAllowedHeaders(Arrays.asList("*")); +// configuration.setAllowCredentials(true); +// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); +// source.registerCorsConfiguration("/**", configuration); +// return source; +// } +// +// @Bean +// public PasswordEncoder passwordEncoder() { +// return new BCryptPasswordEncoder(); +// } +//} -import static org.springframework.security.config.Customizer.withDefaults; +package com.gw.ssh; -import java.util.Arrays; import org.apache.log4j.Logger; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -// import com.gw.tools.SessionManager; +import java.util.Arrays; @Configuration @EnableWebSecurity -public class SecurityConfiguration extends WebSecurityConfigurerAdapter { +public class SecurityConfiguration { protected final Logger log = Logger.getLogger(getClass()); @Bean public SSHAuthenticationProvider sshAuthentication() { - SSHAuthenticationProvider sshAuthentication = new SSHAuthenticationProvider(); - return sshAuthentication; + return new SSHAuthenticationProvider(); } - /* - * TODO - use 'registerAuthentication' in 3.2.0.RC1 and 'configure' in 3.2.0.RELEASE - * but note that 'configure' does not appear to work in tomcat7 - */ - /*~~(Migrate manually based on https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter)~~>*/@Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - log.info("registering SSH authentication provider"); - auth.authenticationProvider(sshAuthentication()); + @Bean + public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception { + AuthenticationManagerBuilder authenticationManagerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class); + authenticationManagerBuilder.authenticationProvider(sshAuthentication()); + return authenticationManagerBuilder.build(); } - /** - * WebSecurity is used to ask Spring Security to bypass the following resources WebSecurity is - * based on HttpSecurity - */ - @Override - public void configure(WebSecurity builder) throws Exception {} - - @Override - protected void configure(HttpSecurity http) throws Exception { - - http.authorizeRequests(requests -> requests - .formLogin(login -> login - .loginProcessingUrl("/Geoweaver/users/login")) - .logout(withDefaults())); - - http.cors(cors -> cors.csrf(csrf -> csrf.disable())); - - http.headers(withDefaults()); + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http + .authorizeHttpRequests(authorize -> authorize + .anyRequest().authenticated() + ) + .formLogin(form -> form + .loginProcessingUrl("/Geoweaver/users/login") + .permitAll() + ) + .logout(logout -> logout + .permitAll() + ) + .cors(cors -> cors.configurationSource(corsConfigurationSource())) + .csrf(csrf -> csrf.disable()) + .headers(headers -> headers.defaultsDisabled()); // This disables the default security headers - http.headers(withDefaults()); // this must be turned off to make the JupyterHub work + return http.build(); } @Bean @@ -79,4 +153,4 @@ CorsConfigurationSource corsConfigurationSource() { public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/gw/web/GoogleEarthController.java b/src/main/java/com/gw/web/GoogleEarthController.java index 8c5290688..2a76de2f6 100644 --- a/src/main/java/com/gw/web/GoogleEarthController.java +++ b/src/main/java/com/gw/web/GoogleEarthController.java @@ -9,11 +9,13 @@ import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; + import jakarta.servlet.http.HttpServletRequest; import org.apache.http.client.config.CookieSpecs; -import org.apache.http.client.config.RequestConfig; +//import org.apache.http.client.config.RequestConfig; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; +//import org.apache.http.impl.client.HttpClients; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +36,10 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.core5.util.Timeout; /** * Controller for Google Earth related activities. @@ -65,29 +71,28 @@ public GoogleEarthController(RestTemplateBuilder builder) {} @Bean(name = "GErestTemplate") @Scope("prototype") public RestTemplate getRestTemplate() { - RestTemplate GErestTemplate = new RestTemplate(); - HttpComponentsClientHttpRequestFactory requestFactory = - new HttpComponentsClientHttpRequestFactory(); - - requestFactory.setConnectTimeout(TIMEOUT); - requestFactory.setReadTimeout(TIMEOUT); - - CloseableHttpClient httpClient = - HttpClients.custom() - .setDefaultRequestConfig( - RequestConfig.custom() - .setCookieSpec(CookieSpecs.STANDARD) - .setRedirectsEnabled(true) - .build()) + RequestConfig requestConfig = RequestConfig.custom() + .setCookieSpec(CookieSpecs.STANDARD) + .setRedirectsEnabled(true) + .setConnectTimeout(Timeout.ofMilliseconds(TIMEOUT)) + .setResponseTimeout(Timeout.ofMilliseconds(TIMEOUT)) .build(); + HttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpComponentsClientHttpRequestFactory requestFactory = + new HttpComponentsClientHttpRequestFactory(httpClient); + GErestTemplate.setRequestFactory(requestFactory); logger.debug("A new Google Earth restTemplate is created"); return GErestTemplate; + } public String getRealTargetURL(String referurl) { @@ -343,9 +348,9 @@ private HttpHeaders updateRequestHeader( * Update response header * * @param oldheaders - * @param h - * @param realurl - * @param querystr + * @param hostid + * @param body + * * @return */ private HttpHeaders updateResponseHeader(HttpHeaders oldheaders, byte[] body, String hostid) { @@ -498,8 +503,9 @@ HttpHeaders updateHeader(HttpHeaders oldheaders, String returnbody, String hosti /** * Process GET Request * - * @param - * @param headers +// * @param +// * @param headers + * @param reqentity * @param method * @param request * @param hostid diff --git a/src/main/java/com/gw/web/JupyterController.java b/src/main/java/com/gw/web/JupyterController.java index 991b91cee..6c2a0e546 100644 --- a/src/main/java/com/gw/web/JupyterController.java +++ b/src/main/java/com/gw/web/JupyterController.java @@ -14,13 +14,17 @@ import java.util.List; import java.util.Map; import jakarta.servlet.http.HttpServletRequest; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.methods.GetMethod; +//import org.apache.commons.httpclient.HttpClient; +//import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +//import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.util.Timeout; import org.apache.http.client.config.CookieSpecs; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; +//import org.apache.http.client.config.RequestConfig; +//import org.apache.http.impl.client.CloseableHttpClient; +//import org.apache.http.impl.client.HttpClients; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +52,10 @@ import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; import org.springframework.web.context.request.WebRequest; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.core5.util.Timeout; @Controller public class JupyterController { @@ -78,20 +86,36 @@ public RestTemplate getRestTemplate() { RestTemplate restTemplate1 = new RestTemplate(); - HttpComponentsClientHttpRequestFactory requestFactory = - new HttpComponentsClientHttpRequestFactory(); - requestFactory.setConnectTimeout(TIMEOUT); - requestFactory.setReadTimeout(TIMEOUT); - - CloseableHttpClient httpClient = - HttpClients.custom() - .setDefaultRequestConfig( - RequestConfig.custom() - .setCookieSpec(CookieSpecs.STANDARD) - .setRedirectsEnabled(false) - .build()) +// HttpComponentsClientHttpRequestFactory requestFactory = +// new HttpComponentsClientHttpRequestFactory(); + +// requestFactory.setConnectTimeout(TIMEOUT); +// requestFactory.setReadTimeout(TIMEOUT); + +// CloseableHttpClient httpClient = +// HttpClients.custom() +// .setDefaultRequestConfig( +// RequestConfig.custom() +// .setCookieSpec(CookieSpecs.STANDARD) +// .setRedirectsEnabled(false) +// .build()) +// .build(); + +// restTemplate1.setRequestFactory(requestFactory); + RequestConfig requestConfig = org.apache.hc.client5.http.config.RequestConfig.custom() + .setCookieSpec(CookieSpecs.STANDARD) + .setRedirectsEnabled(true) + .setConnectTimeout(Timeout.ofMilliseconds(TIMEOUT)) + .setResponseTimeout(Timeout.ofMilliseconds(TIMEOUT)) + .build(); + + org.apache.hc.client5.http.classic.HttpClient httpClient = org.apache.hc.client5.http.impl.classic.HttpClients.custom() + .setDefaultRequestConfig(requestConfig) .build(); + HttpComponentsClientHttpRequestFactory requestFactory = + new HttpComponentsClientHttpRequestFactory(httpClient); + restTemplate1.setRequestFactory(requestFactory); logger.debug("A new restTemplate is created"); @@ -377,7 +401,7 @@ private HttpHeaders getHeaders( /** * Process Patch * - * @param entity +// * @param entity * @param method * @param request * @param hostid @@ -482,7 +506,7 @@ private HttpHeaders getHeaderByRequest(HttpServletRequest request) { /** * Process PUT request * - * @param entity +// * @param entity * @param method * @param request * @param hostid @@ -634,7 +658,7 @@ private ResponseEntity processPut( /** * Process DELETE request * - * @param headers +// * @param headers * @param method * @param request * @param hostid @@ -718,7 +742,7 @@ private ResponseEntity processDelete( /** * Process POST Request * - * @param reqentity +// * @param reqentity * @param method * @param request * @param hostid @@ -960,7 +984,7 @@ private ResponseEntity processGet_415( * Process GET Request * * @param - * @param headers +// * @param headers * @param method * @param request * @param hostid @@ -1722,29 +1746,49 @@ public ResponseEntity proxyroot_get( produces = MediaType.ALL_VALUE) public @ResponseBody String jupyter_http(ModelMap model, WebRequest request) { +// String resp = null; +// +// try { +// +// String targeturl = request.getParameter("url"); +// +// HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); +// +// client.getHttpConnectionManager().getParams().setConnectionTimeout(30000); +// +// GetMethod get = new GetMethod(targeturl); +// +// get.setFollowRedirects(true); +// +// int iGetResultCode = client.executeMethod(get); +// +// resp = get.getResponseBodyAsString(); +// +// } catch (Exception e) { +// +// throw new RuntimeException("failed " + e.getLocalizedMessage()); +// } String resp = null; try { - String targeturl = request.getParameter("url"); - HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); - - client.getHttpConnectionManager().getParams().setConnectionTimeout(30000); - - GetMethod get = new GetMethod(targeturl); + HttpClient client = HttpClients.createDefault(); - get.setFollowRedirects(true); + HttpGet httpGet = new HttpGet(targeturl); + httpGet.setConfig(RequestConfig.custom() + .setConnectTimeout(Timeout.ofMilliseconds(30000)) + .build()); - int iGetResultCode = client.executeMethod(get); - - resp = get.getResponseBodyAsString(); + try (CloseableHttpResponse response = (CloseableHttpResponse) client.execute(httpGet)) { + resp = EntityUtils.toString(response.getEntity()); + } } catch (Exception e) { - throw new RuntimeException("failed " + e.getLocalizedMessage()); } +// return resp; return resp; } @@ -1761,17 +1805,17 @@ public ResponseEntity proxyroot_get( String targeturl = request.getParameter("url"); - HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); - - client.getHttpConnectionManager().getParams().setConnectionTimeout(30000); - - GetMethod get = new GetMethod(targeturl); - - get.setFollowRedirects(true); +// HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); - int iGetResultCode = client.executeMethod(get); +// client.getHttpConnectionManager().getParams().setConnectionTimeout(30000); +// +// GetMethod get = new GetMethod(targeturl); +// +// get.setFollowRedirects(true); +// +// int iGetResultCode = client.executeMethod(get); - resp = get.getResponseBodyAsString(); +// resp = get.getResponseBodyAsString(); } catch (Exception e) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 31f89c990..53bb3f9fc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,10 +9,12 @@ server.servlet.contextPath=/Geoweaver # logging.level.org.springframework.boot.autoconfigure=DEBUG # Log -logging.level.root=FATAL -logging.level.org.springframework=FATAL +server.tomcat.apr.lifecycleListener.disable=true + +logging.level.root=DEBUG +logging.level.org.springframework=DEBUG logging.level.com.gw=FATAL -logging.level.org.hibernate=FATAL +logging.level.org.hibernate=DEBUG # import the external configuration file if exists spring.config.import=optional:file:${HOME}/geoweaver/application.properties diff --git a/src/test/java/com/gw/CLITests.java b/src/test/java/com/gw/CLITests.java index 24ff7925e..7d6c80911 100644 --- a/src/test/java/com/gw/CLITests.java +++ b/src/test/java/com/gw/CLITests.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.system.OutputCaptureRule; @@ -19,7 +20,7 @@ public class CLITests { @Test - public void testTopLevelHelp () { + public void testTopLevelHelp (CapturedOutput output) { TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute("help"); @@ -28,7 +29,7 @@ public void testTopLevelHelp () { } @Test - public void testListHelp(){ + public void testListHelp(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"list", "--help"}); @@ -39,7 +40,7 @@ public void testListHelp(){ } @Test - public void testListHost(){ + public void testListHost(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"list", "--host"}); @@ -51,7 +52,7 @@ public void testListHost(){ } @Test - public void testListProcess(){ + public void testListProcess(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"list", "--process"}); @@ -63,7 +64,7 @@ public void testListProcess(){ } @Test - public void testListWorkflow(){ + public void testListWorkflow(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"list", "--workflow"}); @@ -73,7 +74,7 @@ public void testListWorkflow(){ } @Test - public void testListWithoutArgument(){ + public void testListWithoutArgument(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"list"}); @@ -85,7 +86,7 @@ public void testListWithoutArgument(){ // TODO: Performing only negative tests on detail command for now. Need to add success tests for detail command. @Test - public void testDetailHelp(){ + public void testDetailHelp(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--help"}); @@ -96,7 +97,7 @@ public void testDetailHelp(){ } @Test - public void testDetailHostWithoutHostId(){ + public void testDetailHostWithoutHostId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--host-id"}); @@ -105,7 +106,7 @@ public void testDetailHostWithoutHostId(){ } @Test - public void testDetailHostWithWrongHostId(){ + public void testDetailHostWithWrongHostId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--host-id=wrongHostId"}); @@ -114,7 +115,7 @@ public void testDetailHostWithWrongHostId(){ } @Test - public void testDetailProcessWithoutProcessId(){ + public void testDetailProcessWithoutProcessId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--process-id"}); @@ -123,7 +124,7 @@ public void testDetailProcessWithoutProcessId(){ } @Test - public void testDetailProcessWithWrongProcessId(){ + public void testDetailProcessWithWrongProcessId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--process-id=wrongProcessId"}); @@ -132,7 +133,7 @@ public void testDetailProcessWithWrongProcessId(){ } @Test - public void testDetailWorkflowWithoutWorkflowId(){ + public void testDetailWorkflowWithoutWorkflowId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--workflow-id"}); @@ -141,7 +142,7 @@ public void testDetailWorkflowWithoutWorkflowId(){ } @Test - public void testDetailWorkflowWithWrongWorkflowId(){ + public void testDetailWorkflowWithWrongWorkflowId(CapturedOutput output){ TopEntryCommand topEntryCommand = BeanTool.getBean(TopEntryCommand.class); new CommandLine(topEntryCommand).execute(new String[]{"detail", "--workflow-id=wrongWorkflowId"});