Is there a way, to instruct Maven Surefire, to save the test starting time of each JUnit Test Case in the report xml file?
I expect that the report should look a bit like this:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="com.chris.testcases.Timestamp" time="1,962.965" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property ...>
</properties>
<testcase
name="Timestampfilter"
classname="com.chris.testcases.Timestamp"
time="1,339.383" <-- this is the already existing execution time
--> timestamp="2015-03-11 16:44:05" /> <-- this is the NEW attribute I need
...
</testsuite>
Background: I need this paramter for future processing in this xml, and just writing the timestamp in the "normal" logfile/output is no solution.
I am using: Maven 3.2.5 with Surefire-Plugin 2.18.1.
Update: I found an similar question here: https://jira.codehaus.org/browse/SUREFIRE-681
Related
I'm facing a problem using Liquibase with MySQL 8 where the following script is not putting the fraction part of type "time(3)", it only puts "time" on the type of the column. We run this script before with MySQL 5 and it worked fine.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.16.xsd"
logicalFilePath="20220901.xml">
<changeSet author="MyUser" id="Change column 'time' to Datatype to milliseconds">
<modifyDataType
columnName="time"
newDataType="TIME(3)"
schemaName="${defaultSchema}"
tableName="table1"/>
<addNotNullConstraint
columnDataType="TIME(3)"
columnName="time"
schemaName="${defaultSchema}"
tableName="table1" />
</changeSet>
</databaseChangeLog>
I tried to update to most recent versions on maven dependencies of liquibase.core(to 4.16.1) and mysql-connector-java(to 8.0.30), the problem persists.
After multiple tests, i discover that the problem may be on liquibase generated query that not includes the fraction part "(3)", so as a workaround I used "modifySql" to change the query at the end.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.16.xsd"
logicalFilePath="20220901.xml">
<!-- WORK-AROUND - Liquibase was generating a query with type 'TIME' instead of 'TIME(3)' so
we use 'REPLACE_WITH_TIME' as auxiliary type to replace all of it's occurrences in query
by 'TIME(3)' with 'modifySql'. -->
<changeSet author="MyUser"
id="Fix time column type to time(3) - 2022-10-06">
<modifyDataType columnName="time"
newDataType="REPLACE_WITH_TIME" schemaName="${defaultSchema}"
tableName="table1" />
<addNotNullConstraint columnDataType="REPLACE_WITH_TIME"
columnName="time" schemaName="${defaultSchema}"
tableName="table1" />
<modifySql>
<replace replace="REPLACE_WITH_TIME" with="TIME(3)" />
</modifySql>
</changeSet>
</databaseChangeLog>
It resolves the problem but its not the best solution.
So i wanted to ask if anybody noticed that and knows if its actally a liquibase bug or not.
Thanks in advance.
What is the best way to setup a new Gradle project in IntelliJ IDEA version 2021.3.2?
Specifically, I am trying to setup JPA/Hibernate and am fairly new to this, but cannot seem to get it to work.
I have added the following in build.gradle, as per the IntelliJ guide:
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
compileOnly('javax.persistence:javax.persistence-api:2.2')
implementation('org.hibernate:hibernate-core:5.6.5.Final')
}
When I try adding #Entity on a class, it is unable to compile as the Class is not recognised.
I also have the following persistence.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="default">
</persistence-unit>
</persistence>
good evening.
I'm trying to create a project that uses:
Java
JSF 2.3
Maven
CDI 2.0
Hibernate
Wildfly server
My intention here is to learn the basics of all these fellas.
At first I followed an awesome [tutorial by #BalusC][1] that tought me how to set up and first run the webapp.
My problem now rests on integrating the database with the application. I followed some guides and searched a bit on internet and found that a way to do it is by editing web.xml and persistence.xml. (I tried to keep it as close to hist tutorial as possible).
Here are my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0" metadata-complete="true">
<display-name>project</display-name>
... (some params)
<data-source>
<name>java:global/projectDS</name>
<class-name>org.postgresql.ds.PGConnectionPoolDataSource</class-name>
<url>jdbc:postgresql://localhost:5432/project</url>
</data-source>
... (servlet info)
</web-app>
And my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="projectPU"
transaction-type="JTA">
<jta-data-source>java:global/projectDS</jta-data-source>
<class>project.entity.Message</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQL95Dialect" />
<property name="hibernate.default_schema" value="main" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="javax.persistence.jdbc.driver"
value="org.postgresql.Driver" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
When I run the web app I receive the following error:
Caused by: org.jboss.as.controller.OperationFailedException: WFLYJCA0117: org.postgresql.ds.PGConnectionPoolDataSource is not a valid javax.sql.DataSource implementation [ "WFLYJCA0117: org.postgresql.ds.PGConnectionPoolDataSource is not a valid javax.sql.DataSource implementation" ]
I'd like to know if any of you know what I'm doing wrong and how can I work it out.
P.S.: I read on WildFly's page that WildFly has it's own Hibernate "version", and some foruns said that there might be some issues while working with an "external" hibernate source. However, as my Hibernate configuration has nothing linked to any of Wildfly's config (i believe so), I guess that's not the problem.
Thanks in advance.
UPDATE #1
I tried solution #2 from link #TacheDeChoco sent. At first it worker, but I got another error that I'm still trying to solve. I'll try I little bit more and will come here If a more complete feedback.
Ansewring your questions: by the time I first asked, I hadn't done any of the things you asked.
TY very much.
Did you
register a new postgres module (with the appropriate jar) in Wildfly ?
Declare the datasource, along with the used driver, in wildfly config file (standalone-***.xml) ?
Nice explanations can be found here (see option#2):
https://www.stenusys.com/how_to_setup_postgresql_datasource_with_wildfly/
I build a function that create JUnit report format xml that Jenkins can read.
my problem is that when I report 2 or more failures \ errors, Jenkins shows just the first on.
Also I tried to gather all error to one detailed error but jenkins show it not clear.
my xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuite errors="0" failures="2" hostName="name" name="Reporter" tests="1" time="202.053" timeStamp="Sun Jul 15 07:38:13 UTC 2018">
<testcase classname="bla" name="fail1" time="105.704">
<failure message="failure1" type="">trace...</failure>
<failure message="failure2" type="">trace2...</failure>
</testcase>
</testsuite>
jenkins shows he first only.
On other side if I put all failures in one node looks like this (I build it):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><testsuite errors="0" failures="2" hostName="name" name="Reporter" tests="1" time="202.053" timeStamp="Sun Jul 15 07:38:13 UTC 2018">
<testcase classname="bla" name="fail1" time="105.704">
<failure message=
"failure1
failure2
failure3
...
.."
type="">trace...</failure>
</testcase>
</testsuite>
all failures shown in on line without new line char.
can someone assist if there is a way to do it correctly?
Thanks,
Hezi
I am new to liquibase and have created a sample table utilizing a spring boot + liquibase project. My initial changelog to create the table in file 'createSampleTable.xml':
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.7"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.7
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd">
<changeSet id="1" author="Russ">
<comment>A sample table to see if liquibase works</comment>
<createTable tableName="testy">
<column name="VALUE" type="varchar(32)"/>
</createTable>
<insert tableName="testy">
<column name="value" value="Hello, world!"/>
</insert>
<insert tableName="testy">
<column name="value" value="Riddikulus!"/>
</insert>
</changeSet>
</databaseChangeLog>
Now that I've verified my liquibase configuration, this same deployment has run in our 2 lower regions (dev and test) but we have not yet stood up stage or prod. I would like to "undo" the sample table and start creating my real database structure.
My understanding is I have two options: conditional drop table, rollback
I am currently trying to implement the conditional drop table as the documentation states but the proposed attributes are not recognized even though the preconditions documentation clearly states the onFail annotation should be recognized. Here is my implementation of the proposed solution (this is the current contents of the 'createSampleTable.xml' file:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.7"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.7
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd">
<!-- The documentation for liquibase says if you ever create a changeset
in error that you never really wanted to follow this approach.
The general idea is to delete the original changeset and then
provide a new changeset that should only run if the original changset
has run as well. In essence this allows us to remove a naughty change
entirely from the code and prevent it from being run in new
environments while providing an "undo" changeset to be ran in
environments where this changeset has unfortunately already ran.
Documentation referenced and approach taken:
http://www.liquibase.org/2008/10/dealing-with-changing-changesets.html
To satisfy developer's curiosity and prevent them from having to
look up the history in the repository the original changeset of id=1
was simply to create a sample table to make sure the initial liquibase
config was working.
-->
<changeSet id="1-undo" author="Russ">
<preConditions onFail="MARK_RAN">
<changeSetExecuted id="1" author="Russ" changeLogFile="liquibase/createSampleTable.xml" />
</preConditions>
<dropTable tableName="testy"/>
</changeSet>
</databaseChangeLog>
However, when running this both the onFail attribute and the
<changeSetExecuted> tag are unrecognized by the schema. After this I tried to implement the maven plugin to rollback, but this executes on the build, so this target will only ever resolve one region.
What is the generally accepted approach for undoing changes? Does the approach differ if you're implementing a spring boot liquibase project?
Looks like your applied schema is quite old (1.7).
Check your included version (if Maven, check your pom).
You should be able to use the required tags if you use the 3.1 version xml schema:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
...
</databaseChangeLog>
Note the schema dbchangelog-3.1.xsd
If using Maven, the above schema works with the following plugin config:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<propertyFile>src/main/liquibase.properties</propertyFile>
</configuration>
</plugin>