Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running EvoSuite on a java file that depends on a jar file? #440

Open
imesecan opened this issue Nov 22, 2022 · 1 comment
Open

Running EvoSuite on a java file that depends on a jar file? #440

imesecan opened this issue Nov 22, 2022 · 1 comment

Comments

@imesecan
Copy link

Context

Running EvoSuite on a java file that depends on a jar file.
The Java target 'Sanitizers' has the following structure and can be downloaded from here

Sanitizers
    |- evosuite-1.2.0.jar
    |- javax.servlet-api-40.0.1.jar
    |- src
        |- main
            |- java
                |- securibench
                    |- micro
                        |- MicroTestCase.java
                        |- BasicTestCase.java
                        |- sanitizers
                            |- Sanitizers1.java

Steps to Reproduce

The target program for EvoSuite is the Sanitizers1.java and that extends BasicTestCase implements MicroTestCase.
BasicTestCase and Sanitizers1 imports the following which are provided in javax.servlet-api-40.0.1.jar.

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

Maven can compile all java files and create a jar file with it. I am using evosuite-1.2.0.jar file
and, I can compile the java files, too. Several pages suggest using "-classpath" when a java file depends on a jar file. However, I when I include it, it fails and gives errors. So, I unpacked javax.servlet-api-40.0.1.jar in src/main/java folder
(javax folder). Again, when I compile everything is OK, and it compiles. When I try running EvoSuite, it gives errors.

EvoSuite Arguments

cd Sanitizers/src/main/java
javac -cp /evosuite/Sanitizers/src/main/java/ securibench/micro/MicroTestCase.java
javac -cp /evosuite/Sanitizers/src/main/java/ securibench/micro/BasicTestCase.java
javac -cp /evosuite/Sanitizers/src/main/java/ securibench/micro/sanitizers/Sanitizers1.java
java -Xmx1G  -Xss1G  -jar evosuite-1.2.0.jar  -projectCP ./  -class securibench.micro.sanitizers.Sanitizers1  \
    -seed 112      -Dsearch_budget=60  -Dstopping_condition=MaxTime 

Current Result

Below are some lines from the head and tail of 453 lines report from.

* EvoSuite 1.2.0
* Going to generate test cases for class: securibench.micro.sanitizers.Sanitizers1
* Starting Client-0
* Connecting to master process on port 11042
* Analyzing classpath: 
  - ./
[MASTER] 19:30:05.599 [logback-1] WARN  InheritanceTree - Class not in inheritance graph: java.util.Locale$IsoCountryCode
* Finished analyzing classpath
* Generating tests for class securibench.micro.sanitizers.Sanitizers1
* Test criteria:
  - Line Coverage
  - Branch Coverage
  - Exception
  - Mutation testing (weak)
  - Method-Output Coverage
  - Top-Level Method Coverage
  - No-Exception Top-Level Method Coverage
  - Context Branch Coverage
* Total number of test goals for DYNAMOSA: 126
* Using seed 112
* Starting evolution
[Progress:>                             0%] [Cov:>                                  0%]* Initial Number of Goals in DynaMOSA = 34 / 126
[Progress:>                             1%] [Cov:==============>                    42%][MASTER] 19:30:07.949 [logback-1] WARN  TestChromosome - Functional mock problem: org.evosuite.ga.ConstructionFailedException: Have no generator for class javax.servlet.http.HttpServletResponseWrapper canUseFunctionalMocks=false, canBeMocked: true
[Progress:>                             3%] [Cov:=========================>         74%][MASTER] 19:30:08.872 [logback-1] WARN  TestChromosome - Functional mock problem: org.evosuite.ga.ConstructionFailedException: Failed to add constructor for javax.servlet.ServletResponseWrapper due to org.evosuite.ga.ConstructionFailedException: Have no generator for class javax.servlet.http.HttpServletResponseWrapper canUseFunctionalMocks=false, canBeMocked: true
[MASTER] 19:30:09.008 [logback-2] ERROR ClientNodeImpl - Cannot inform master of change of state
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
	java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
	java.lang.ClassNotFoundException: securibench/micro/BasicTestCase
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:391)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
	at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
...
... 
	at org.evosuite.instrumentation.BytecodeInstrumentation.transformBytes(BytecodeInstrumentation.java:282)
	at org.evosuite.instrumentation.InstrumentingClassLoader.getTransformedBytes(InstrumentingClassLoader.java:135)
	at org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:149)
	... 78 common frames omitted
@imesecan
Copy link
Author

imesecan commented Jan 3, 2023

This is mock example and it worked when I provide the java -cp CLASSPATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant