karate-config.js failed after update of karate-core - karate

I'm trying to update my karate project with the newest version of karate-junit5 library.
In the documentation for Maven it's mentioned that only one dependency is required to run karate.
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
Previously I was using karate-jersey and karate-junit4 and everything was working flawless.
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-jersey</artifactId>
<version>0.9.6</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-junit5 -->
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.6</version>
<scope>test</scope>
</dependency>
I managed to update karate-junit4 to karate-junit5 but I see that karate-core is still using 0.9.6
When I want to replace jersey with karate-core 1.3.0 and run my tests I have an error with loading my karate-config.js
karate-config.js failed
js failed:
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:82:0 Expected ) but found function
This is strange because I didn't change anything besides the dependencies.
Do I still have to use karate-jersey in my project? The documentation doesn't mention this.
I tried to update the dependency to the newest version. Now I got a failing karate-config.js

There's no such thing as karate-jersey. Get rid of that dependency, the HTTP client is now built-in.
Since you are upgrading from such an old version, you need to read all the release notes. For example this one: https://github.com/karatelabs/karate/wiki/1.0-upgrade-guide#java-projects
But let's hope you get by with just this one change. Else be prepared to scan all the release notes. The JS engine has changed, but all those who kept tracking the project and tried RC versions (we spend a lot of time on this) have been having a smooth experience.
I guess this is what folks call "technical debt" ;)

Related

How to easily upgrade Karate Version?

I would like to upgrade to Karate 0.9.0 which is released recently. How can i do this easily. My existing .pom file contains many dependencies in 0.8.0 version. Should i replace each with updated one? Or, is there a better way to do this?
And again, i can see many RC versions of dependencies in maven repository which one's stable?
And, Finally, Is there any separate dependency for KarateOptions? Because, I was using 0.8.0 and was not able to find any dependency jars for this.
This is actually a maven question. But yes the recommended practice is to define a maven "property" once and then use it in the multiple places.
I'm surprised, because at the max you should have only 2.
<properties>
<karate.version>0.9.0</karate.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
And yes, KarateOptions is new in 0.9.0 - please read the release notes carefully and you don't even need to change that immediately when you upgrade: https://github.com/intuit/karate/releases/tag/v0.9.0

NoClassDefFoundError using with boxable plugin

I am using boxable plugin with pdfbox and I am trying to create a teble. I am getting error:
2015-09-09T10:36:52.453+0200|Severe: java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/edit/PDPageContentStream
at the line of code:
BaseTable table = new BaseTable(yStart,yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, drawContent);
Here is a part from pom.xml, describing the dependencies that I am using:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.dhorions</groupId>
<artifactId>boxable</artifactId>
<version>1.2</version>
</dependency>
Is there a bug in current version of dependencies or am I missing something?
Thank you very much for any help.
Remove this:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
2.0 is an unreleased version and is in development, and it has a different API. Boxable has its dependencies in its own pom.xml, it is currently requesting 1.8.8. (Which is not the latest version, but I don't think this matters for simple PDF creation)

IntelliJ with flexunit4

I have a maven project where I am using flexmojos and flexunit and the tests execute fine when building through maven.
However when I try to execute a single test using IntelliJ (right click the on test - run), it creates the _flexunit.swf file and tries to execute it, however there is an exception when it runs:
VerifyError: Error #1014: Class mx.core::Application could not be found.
My knowledge of flexmojos is not great, but I believe it takes care of loading the flex sdk dependencies, however I have tried adding flex sdk dependencies directly in my pom but after that I can't even build in maven, which doesn't happen if I leave those dependencies out:
Unable to locate specified base class 'spark.components.supportClasses.ItemRenderer'
So my question is, what tells IntelliJ to configure the _flexunit.swf not to link the flex sdk? Are there some settings where I have to set these specifically?
Seems like my pom is correctly set up to run the tests (so the TestRunner.swf is fine) but the _flexunit.swf compiled by IntelliJ is missing something...
Sounds to me that you need to do something like this:
<dependency>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-unittest-flexunit4</artifactId>
<version>4.1-beta</version>
<type>swc</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>playerglobal</artifactId>
</exclusion>
<exclusion>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>airframework</artifactId>
</exclusion>
</exclusions>
</dependency>
Notice the Exclusions Tag.

apache mime4j maven dependency for 0.7.2

Trying to use the Apache Mime4J dependency for Version 0.7.2 like this:
<repositories>
<repository>
<id>org.apache.james</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.7.2</version>
</dependency>
I got an error message that the dependency could not be downloaded.
After checking that
http://uk.maven.org/maven2/org/apache/james/apache-mime4j/0.7.2/apache-mime4j-0.7.2.jar
indeed does not exist
but http://uk.maven.org/maven2/org/apache/james/apache-mime4j/0.7.2/
had .bin.tar.gz files I worked around the problem using:
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.6.1</version>
</dependency>
This will therefore not reference the more current 0.7.2 release.
This is my "set of questions":
Why does the 0.7.2 release not contain a Jar file?
How should I reference the dependency to get the latest Jar?
Do I need it anyway?
What differences are there between the 0.7.2 and the
0.6.1 release?
Question 1: Why an artifact might not exist
According to the changelog there has been some refactoring going on to split the functionality into the three parts: core,dom and storage.
Question 2: How to get the latest artifact
modify the dependencies to:
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-core</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-dom</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-storage</artifactId>
<version>0.7.2</version>
</dependency>
Question 3: Do I need it?
if you'd like to use the improved DOM API: yes. You will need to modify your
import statements and can not use new Message() any more. Use
MessageServiceFactory.newInstance().newMessageBuilder().newMessage();
instead. The multipart.getBodyParts() function has also changed and returns an Entity now.
There is no isMimeType() for the Entity. You might want to use getMimeType() instead.
Question 4: What changed between versions?
See the change log between 0.7.2 and 0.6.1.

How to make IntelliJ understand annotations

I have recently switched from using Eclipse to IntelliJ, and am preferring the experience.
However, the IDE is not understanding any of the Annotations. I am using Spring #Autowired annotation as well as some of the Spring-WS annotations and the IDE is telling me that they are unresolved.
When the project is built using Maven, it builds fine, and the Annotations are recognised in Eclipse.
Im sure this is a simple setup thing, but cannot find any information on how to set it up.
As Peter said, when correctly importing the Maven project the dependencies should be correctly recognized. The IntelliJ manual has a section on how to import a Maven project.
For the record, in our project pom, we have the following dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
The former two have been present already before implementing a web service, so they may not be required strictly for web services.