Jenkins doesn't execute tests - unit-testing

I have a Maven project and I'm using TestNG. My build completes in Jenkins, but the tests I want to run are not actually executed. I have my console output from Jenkins and my pom.xml file. Hopefully, something can be gleaned from this. The tutorials I've followed all seem to do something a little different with config settings or plug-ins. I meticulously followed one tutorial but somewhere I've done not something correctly. I would be hugely indebted for any assistance.
17:15:56 [INFO] Scanning for projects...
17:15:56 [INFO]
17:15:56 [INFO] -----------------< >------------------
17:15:56 [INFO] Building test 1.0-SNAPSHOT
17:15:56 [INFO] --------------------------------[ jar ]---------------------------------
17:15:57 [INFO]
17:15:57 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) # test ---
17:15:57 [INFO]
17:15:57 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # test ---
17:15:57 [INFO] Using 'UTF-8' encoding to copy filtered resources.
17:15:57 [INFO] skip non existing resourceDirectory /dbdata/testauto/home/testauto/jenkins/workspace/_7692-api-test-gestion-binaire/src/main/resources
17:15:57 [INFO]
17:15:57 [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # test ---
17:15:57 [INFO] Changes detected - recompiling the module!
17:15:57 [INFO] Compiling 15 source files to /dbdata/testauto/home/testauto/jenkins/workspace/_7692-api-test-gestion-binaire/target/classes
17:15:57 [INFO]
17:15:57 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # test ---
17:15:57 [INFO] Not copying test resources
17:15:57 [INFO]
17:15:57 [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # test ---
17:15:57 [INFO] Not compiling test sources
17:15:57 [INFO]
17:15:57 [INFO] --- maven-surefire-plugin:3.0.0-M1:test (default-test) # test ---
17:15:57 [INFO] Tests are skipped.
17:15:57 [INFO]
17:15:57 [INFO] --- maven-jar-plugin:2.4:jar (default-jar) # test ---
17:15:58 [INFO] Building jar: /dbdata/testauto/home/testauto/jenkins/workspace/_7692-api-test-gestion-binaire/target/test-1.0-SNAPSHOT.jar
17:15:58 [INFO]
17:15:58 [INFO] --- maven-install-plugin:2.4:install (default-install) # test ---
And this is my pom.xml file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
</plugins>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<!--scriptSourceDirectory>src/main/scripts</scriptSourceDirectory-->
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>

Related

Spring Cloud application fails to connect to AWS Kinesis 'dynamoDBClient' must not be null

Unable to connect to Kinesis stream using Spring Cloud Stream Kinesis binder due to error java.lang.IllegalArgumentException: 'dynamoDBClient' must not be null
//Stream binding
EnableBinding(DataStream.class)
public class StreamsConfig {}
//Stream config
public interface DataStream {
String AUDIT_IN = "auditIn";
#Input(AUDIT_IN)
SubscribableChannel auditIn();
}
//Stream Listener
#StreamListener(DataStream.AUDIT_IN)
public void processAudit(finalAuditMessage auditMessage) {
logger.info("Received audit message : {}", auditMessage);
MDCUtil.setContext(auditMessage.getTenantId(), null, null);
persistAuditMessage(auditMessage);
MDCUtil.clearContext();
}
Application.yaml
cloud:
aws:
stack:
auto: false
region:
static: us-west-2
credentials:
useDefaultAwsCredentialsChain: true
management:
context-path: /actuator
security:
enabled: false
roles: ADMIN
endpoint:
metrics:
enabled: true
loggers:
enabled: true
health:
show-details: always
endpoints:
web:
exposure:
include: "health,metrics,info,loggers"
metrics:
export:
statsd:
enabled: true
flavor: telegraf
host: telegraf-s.cluster-services.svc.cluster.local
port: 8125
tags:
service: audit
namespace: {{ .Release.Namespace }}
distribution:
percentiles:
http:
server:
requests: 0.5,0.9,0.99
percentiles-histogram:
http:
server:
requests: true
logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
spring:
application:
name: audit
zipkin:
enabled: false
cloud:
stream:
bindings:
auditIn:
content-type: application/json
destination: ***
consumer:
describeStreamRetries: 10
group: ***
kinesis:
binder:
autoCreateStream: true
autoAddShards: false
kplKclEnabled: true
vault:
token: 00000000-0000-0000-0000-000000000000
ssl:
trust-store: ***
trust-store-password: ***
generic:
enabled: false
host: localhost
port: 8200
scheme: https
connection:
timeout: 5000
read-timeout: 15000
authentication: KUBERNETES
kubernetes:
role: owner
kubernetes-path: kubernetes
service-account-token-file: token
kv:
enabled: false
backend: kv-v2
application-name: configuration/mysql
jpa:
open-in-view: false
audit:
filter:
block:
methods: GET
Debug log
INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: osx-x86_64
[INFO]
[INFO] ---------------------------< com.nile:audit >---------------------------
[INFO] Building audit 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) > test-compile # audit >>>
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # audit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # audit ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # audit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # audit ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) < test-compile # audit <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) # audit ---
[INFO] Attaching agents: []
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.2.RELEASE)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/Users/arvindkgs/.m2/repository/org/springframework/spring-core/5.2.2.RELEASE/spring-core-5.2.2.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-02-24 20:40:38,529 ERROR [main] com.nile.cloudutilities.audit.aspect.MethodMap [] [] - STARTING AUDIT BUILD AT 2021-02-24T15:10:38.524052Z
2021-02-24 20:40:39,984 ERROR [main] com.nile.cloudutilities.audit.aspect.MethodMap [] [] - FINISHED AUDIT BUILD AT 2021-02-24T15:10:39.984543Z: 3/14/0 (0 mappings)
Running custom WebSecurity
2021-02-24 20:40:52,203 DEBUG [main] org.hibernate.SQL [] [] - select loggerconf0_.id as id1_2_, loggerconf0_.create_time as create_t2_2_, loggerconf0_.last_update as last_upd3_2_, loggerconf0_.configuration as configur4_2_, loggerconf0_.service as service5_2_ from logger_configs loggerconf0_ where loggerconf0_.service=?
2021-02-24 20:40:52,219 TRACE [main] org.hibernate.type.descriptor.sql.BasicBinder [] [] - binding parameter [1] as [VARCHAR] - [audit]
2021-02-24 20:40:54,068 ERROR [main] org.springframework.cloud.stream.binding.BindingService [] [] - Failed to create consumer binding; retrying in 30 seconds
org.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer:
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:471) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:90) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:143) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.BindingService.doBindConsumer(BindingService.java:169) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:126) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.AbstractBindableProxyFactory.createAndBindInputs(AbstractBindableProxyFactory.java:112) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.InputBindingLifecycle.doStartWithBindable(InputBindingLifecycle.java:58) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.AbstractBindingLifecycle$$Lambda$1628/000000000000000000.accept(Unknown Source) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608) [?:?]
at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.start(AbstractBindingLifecycle.java:57) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:34) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at com.nile.audit.AuditService.main(AuditService.java:60) [classes/:?]
Caused by: java.lang.IllegalArgumentException: 'dynamoDBClient' must not be null.
at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.integration.aws.inbound.kinesis.KclMessageDrivenChannelAdapter.<init>(KclMessageDrivenChannelAdapter.java:143) ~[spring-integration-aws-2.3.0.RELEASE.jar:?]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createKclConsumerEndpoint(KinesisMessageChannelBinder.java:314) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createConsumerEndpoint(KinesisMessageChannelBinder.java:291) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createConsumerEndpoint(KinesisMessageChannelBinder.java:89) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:417) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
... 23 more
2021-02-24 20:40:54,167 DEBUG [main] org.hibernate.SQL [] [] - select loggerconf0_.id as id1_2_, loggerconf0_.create_time as create_t2_2_, loggerconf0_.last_update as last_upd3_2_, loggerconf0_.configuration as configur4_2_, loggerconf0_.service as service5_2_ from logger_configs loggerconf0_ where loggerconf0_.service=?
2021-02-24 20:40:54,169 TRACE [main] org.hibernate.type.descriptor.sql.BasicBinder [] [] - binding parameter [1] as [VARCHAR] - [audit]
^C[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.955 s
[INFO] Finished at: 2021-02-24T20:40:58+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.
pom.xml - https://drive.google.com/file/d/1kBEj6HqTQS5BgA7StaFZBEKfbLrpgSMR/view?usp=sharing
Using following jars
org.springframework.cloud:spring-cloud-stream-binder-kinesis:jar:2.0.0.RELEASE:compile
[INFO] | +- com.amazonaws:amazon-kinesis-client:jar:1.13.0:compile
[INFO] | | +- com.amazonaws:aws-java-sdk-cloudwatch:jar:1.11.655:compile
[INFO] | | \- com.google.protobuf:protobuf-java:jar:2.6.1:compile
[INFO] | +- com.amazonaws:amazon-kinesis-producer:jar:0.14.0:compile
[INFO] | | \- commons-lang:commons-lang:jar:2.6:compile
[INFO] | +- org.springframework.integration:spring-integration-aws:jar:2.3.0.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-aws-core:jar:2.2.0.RELEASE:compile
[INFO] | | | +- com.amazonaws:aws-java-sdk-ec2:jar:1.11.415:compile
[INFO] | | | \- com.amazonaws:aws-java-sdk-cloudformation:jar:1.11.415:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-aws-messaging:jar:2.2.0.RELEASE:runtime
[INFO] | | | +- com.amazonaws:aws-java-sdk-sns:jar:1.11.415:runtime
[INFO] | | | \- com.amazonaws:aws-java-sdk-sqs:jar:1.11.415:runtime
[INFO] | | +- org.springframework.integration:spring-integration-file:jar:5.2.2.RELEASE:runtime
[INFO] | | \- org.springframework.integration:spring-integration-http:jar:5.2.2.RELEASE:runtime
[INFO] | +- org.springframework.cloud:spring-cloud-starter-aws:jar:2.2.0.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-aws-context:jar:2.2.0.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-aws-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.11.415:compile
[INFO] | | \- com.amazonaws:aws-java-sdk-s3:jar:1.11.415:compile
[INFO] | | \- com.amazonaws:aws-java-sdk-kms:jar:1.11.415:compile
[INFO] | +- com.amazonaws:dynamodb-lock-client:jar:1.1.0:compile
[INFO] | | \- org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO] | +- com.amazonaws:aws-java-sdk-kinesis:jar:1.11.415:compile
[INFO] | \- com.amazonaws:dynamodb-streams-kinesis-adapter:jar:1.5.0:compile
To work with Spring BOOT apps and AWS APIs, try using the official AWS SDK for Java V2 API (as opposed to non Amazon APIs). Amazon recommends moving from V1 to V2.
Here is an example that does use DynamoDB API V2 within a Spring BOOT application. This use case lets a user submit data from a simple web form and then the data is stored in an Amazon DynamoDB table. Then it shows you how to use SNS to fire off a text message. In addition, this shows you how to successfully use AWS Java V2 APIs within a Spring Boot app.
Once its written, this shows you how to deploy the Spring Boot App to the cloud:
Creating your first AWS Java web application
Once you get a basic Spring app working with AWS Java V2 APIs, you can use other services.
My bad. I was creating a DynamoDBClient bean that returned null. This bean is autowired in org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.

Cannot get response 200 with spring boot

Hi i am testing my controllers methods with chrome's reslet client and i have an error 404, after checking everything in my project i built a new one and created just one service and one controller and still all i get is error 404.
any ideas?
this is the url im calling:
http://localhost:8080/rest/api/encryptor/checkAutorization
that is my PomXML with al the dependencys :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.serverside</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>app</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
this is the Controller:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import Services.GeneralResponse;
import Services.TokenEncryptor;
#RestController
#RequestMapping("rest/api/encryptor")
public class EncryptionController {
#Autowired
private TokenEncryptor tokenEncryptor;
#GetMapping("/checkAutorization")
public GeneralResponse checkAutorization() throws Throwable {
try {
// byte[] byteToken = token.getBytes(StandardCharsets.UTF_8);
return new GeneralResponse(tokenEncryptor.encryptToken(new byte[]
{}));
} catch (Exception AccessDeniedException) {
return new GeneralResponse(AccessDeniedException);
}
}
}
Main method:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
#Configuration
#SpringBootApplication
public class AppApplication {
public static void main(String[] args) {
SpringApplication.run(AppApplication.class, args);
}
}
General Response Class:
import java.text.SimpleDateFormat;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonInclude;
#JsonInclude(JsonInclude.Include.NON_NULL)
public class GeneralResponse {
private Object error;
private Object result;
public GeneralResponse() {
}
public GeneralResponse(Object result) {
this.result = result;
}
public GeneralResponse(Exception e) {
this.result = null;
this.error = e;
StackTraceElement[] stackTrace = e.getStackTrace();
System.out.println("The exception occured in method " + stackTrace[0].getMethodName());
System.out.println("The class name is " + stackTrace[0].getClassName());
System.out.println("at line number: " + stackTrace[0].getLineNumber());
System.out.println(e.toString() + " \n" + "error cause: " + e.getCause() + "\n" + "at: " + formatTime(System.currentTimeMillis()));
}
public Object getError() {
return error;
}
public void setError(Object error) {
this.error = error;
}
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
private String formatTime(Long currentTime) {
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
Date resultdate = new Date(currentTime);
return (sdf.format(resultdate));
}
}
Console startup log :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE)
2018-12-17 13:40:20.763 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : Starting AppApplication on LAPTOP-0GNLE6KN with PID 21872 (C:\Users\omert\eclipse-workspace\app\target\classes started by omert in C:\Users\omert\eclipse-workspace\app)
2018-12-17 13:40:20.766 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : No active profile set, falling back to default profiles: default
2018-12-17 13:40:20.814 INFO 21872 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2018-12-17 13:40:20.815 INFO 21872 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2018-12-17 13:40:21.546 INFO 21872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2018-12-17 13:40:21.569 INFO 21872 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15ms. Found 0 repository interfaces.
2018-12-17 13:40:21.946 INFO 21872 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$365e8361] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-12-17 13:40:22.515 INFO 21872 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-12-17 13:40:22.541 INFO 21872 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-12-17 13:40:22.542 INFO 21872 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2018-12-17 13:40:22.554 INFO 21872 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_181\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_191/bin/server;C:/Program Files/Java/jre1.8.0_191/bin;C:/Program Files/Java/jre1.8.0_191/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\omert\AppData\Local\Microsoft\WindowsApps;C:\Users\omert\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\node.exe;;C:\WINDOWS\system32;;.]
2018-12-17 13:40:22.697 INFO 21872 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-12-17 13:40:22.697 INFO 21872 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1882 ms
2018-12-17 13:40:22.915 INFO 21872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-12-17 13:40:23.063 INFO 21872 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-12-17 13:40:23.109 INFO 21872 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-12-17 13:40:23.178 INFO 21872 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.7.Final}
2018-12-17 13:40:23.181 INFO 21872 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-12-17 13:40:23.338 INFO 21872 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2018-12-17 13:40:23.482 INFO 21872 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-12-17 13:40:23.713 INFO 21872 --- [ restartedMain] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#77c8a0a2'
2018-12-17 13:40:23.716 INFO 21872 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-12-17 13:40:23.731 INFO 21872 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-12-17 13:40:23.983 INFO 21872 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-12-17 13:40:24.038 WARN 21872 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-12-17 13:40:24.325 INFO 21872 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-12-17 13:40:24.329 INFO 21872 --- [ restartedMain] com.serverside.app.AppApplication : Started AppApplication in 3.869 seconds (JVM running for 4.415)
I am getting 200 response code
POM : http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.gjp.springboot
test
0.0.1-SNAPSHOT
jar
test
Test Spring Boot Web Application
org.springframework.boot
spring-boot-starter-parent
2.0.0.RELEASE
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
#Service
public class TokenEncryptor {

Eclipse maven plugin: Cannot run program "mvn" for WSO2 ESB SampleServices

All are good if I used mvn clean install via command line inside SampleServices of the pre-packaged project. But it gives me this error when I try to mvn clean install it via eclipse m2e
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec
(package) on project SampleServices: Command execution failed. Cannot
run program "mvn" (in directory
"/Users/johndoe/Project/ChickenEngine/SampleServices/target/capp"):
error=2, No such file or directory -> [Help 1]
I've tried using external maven located at /opt but still no success. I'm following this guide.
Eventually find out to pay more attention to problem
SampleServices\pom.xml configure exec-maven-plugin. Important part is maven itself is called as executable
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>....
This means that mvn.bat has to be in PATH. Use variable PATH or run eclipse from cmd, but before start of application execute
set PATH=%PATH%;c:\path-to-maven-bin-directory\
and only then
./eclipse.exe
and u will get in eclipse console
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] QueryDoctorEP ...................................... SUCCESS [ 2.855 s]
[INFO] GrandOakEP ......................................... SUCCESS [ 0.057 s]
[INFO] ClemencyEP ......................................... SUCCESS [ 0.064 s]
[INFO] PineValleyEP ....................................... SUCCESS [ 0.067 s]
[INFO] ChannelingFeeEP .................................... SUCCESS [ 0.044 s]
[INFO] SettlePaymentEP .................................... SUCCESS [ 0.051 s]
[INFO] HealthcareAPI ...................................... SUCCESS [ 0.776 s]
[INFO] PaymentRequestMessageStore ......................... SUCCESS [ 0.599 s]
[INFO] PaymentRequestProcessingSequence ................... SUCCESS [ 0.541 s]
[INFO] PaymentRequestProcessor ............................ SUCCESS [ 0.597 s]
[INFO] SampleServices_module .............................. SUCCESS [ 0.437 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.829 s
[INFO] Finished at: 2017-05-23T12:23:58+03:00
[INFO] Final Memory: 17M/209M
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.775 s
[INFO] Finished at: 2017-05-23T12:23:58+03:00
[INFO] Final Memory: 12M/201M
[INFO] ------------------------------------------------------------------------

WSO2 MSF4J - Maven Compiler Sample

I have a problem with Maven Compiler Hellow-Service sample.
the response: Unable to add module to the current project as it is not of packaging type 'pom' -> [Help 1]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WSO2 MSF4J Microservice 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) # Hello-Service >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) # Hello-Service <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) # Hello-Service ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.wso2.msf4j:msf4j-microservice:1.0.0] found in catalog remote
[INFO] Using property: groupId = org.example
[INFO] Using property: artifactId = Hello-Service
[INFO] Using property: version = 1.0.0-SNAPSHOT
[INFO] Using property: package = br.teste.service
[INFO] Using property: serviceClass = HelloService
Confirm properties configuration:
groupId: org.example
artifactId: Hello-Service
version: 1.0.0-SNAPSHOT
package: br.teste.service
serviceClass: HelloService
Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: msf4j-microservice:1.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.example
[INFO] Parameter: artifactId, Value: Hello-Service
[INFO] Parameter: version, Value: 1.0.0-SNAPSHOT
[INFO] Parameter: package, Value: br.teste.service
[INFO] Parameter: packageInPathFormat, Value: br/teste/service
[INFO] Parameter: package, Value: br.teste.service
[INFO] Parameter: version, Value: 1.0.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.example
[INFO] Parameter: serviceClass, Value: HelloService
[INFO] Parameter: artifactId, Value: Hello-Service
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping WSO2 MSF4J Microservice
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.359s
[INFO] Finished at: Wed Mar 16 15:05:44 BRT 2016
[INFO] Final Memory: 22M/265M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project Hello-Service: org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.msf4j</groupId>
<artifactId>msf4j-service</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Hello-Service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>WSO2 MSF4J Microservice</name>
<properties>
<microservice.mainClass>org.example.service.Application</microservice.mainClass>
</properties>
</project>
You are using old version of source code. I can identify it from your module artifact name. Relevant pom file can be found here
I can compile the latest source code without any issues.

Maven can't see tests

I'm using maven to run my selenium tests but it doesn't find this tests i put it under src/test/java. My test class is named SeleniumTest.java so it follows convention (*Test.java) here's the code :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org
/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-
v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tests.functional.selenium</groupId>
<artifactId>functionalTestsSelenium</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>functionalTestsSelenium Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>functionalTestsSelenium</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-beta-1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
</plugin>
<!-- Start the tomcat server and Deploy the war -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat6x</containerId>
<type>installed</type>
<home>${env.CATALINA_HOME}</home>
</container>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Start the selenium server -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Fire the function tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<junitArtifactname>
org.junit:com.springsource.org.junit
</junitArtifactname>
<excludes>
excluding the test class in the functional tests package
during the test phase
<exclude>**/functional/*Test.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<!-- Running the tests in the functional tests package during the integration tests phase. -->
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/functional/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
here's my test class :
package functional;
import com.thoughtworks.selenium.SeleneseTestCase;
public class SeleniumTest extends SeleneseTestCase {
#Override
public void setUp() throws Exception {
setUp("http://www.netapsys.fr"); // délégation de la configuration à la classe parente
}
public void test() {
selenium.open("/"); // ouverture de la page
selenium.waitForPageToLoad("5000");
assertTrue(selenium.isTextPresent("Netapsys"));
}
}
here's the console result after running :
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building seleniumproject Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # seleniumproject ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # seleniumproject ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # seleniumproject ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\neila\workspace\seleniumproject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # seleniumproject ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # seleniumproject ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Users\neila\workspace\seleniumproject\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.0.2:war (default-war) # seleniumproject ---
[INFO] Exploding webapp...
[INFO] Assembling webapp seleniumproject in C:\Users\neila\workspace\seleniumproject\target\seleniumproject
[INFO] Copy webapp webResources to C:\Users\neila\workspace\seleniumproject\target\seleniumproject
[INFO] Generating war C:\Users\neila\workspace\seleniumproject\target\seleniumproject.war
[INFO] Building war: C:\Users\neila\workspace\seleniumproject\target\seleniumproject.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.922s
[INFO] Finished at: Wed Jul 04 08:18:56 GMT+01:00 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
Your test belongs to the package functional. Thus, it will not run during the test phase, as your pom specifies that any *functional* package should be excluded:
<configuration>
<junitArtifactname>
org.junit:com.springsource.org.junit
</junitArtifactname>
<excludes>
excluding the test class in the functional tests package
during the test phase
<exclude>**/functional/*Test.java</exclude>
</excludes>
</configuration>
Your pom is configured to start (and stop) the Selenium server during the pre-integration-test and post-integration-test phases. However, during these phases, you do not ask to run any test. I suggest that you have a look on the failsafe Maven plugin to run your functional.* Selenium tests during the integration-test phase.