Skip to content

Commit

Permalink
Added new MockitoTests SegmentationErrorTest (#5133)
Browse files Browse the repository at this point in the history
* $Signed-off-by: sophiaxu0424 <[email protected]>

fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fif

Signed-off-by: sophiaxu0424 <[email protected]>

* fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fix testng

Signed-off-by: sophiaxu0424 <[email protected]>

* fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fixx

Signed-off-by: sophiaxu0424 <[email protected]>

* add command element

Signed-off-by: sophiaxu0424 <[email protected]>

* added command part

Signed-off-by: sophiaxu0424 <[email protected]>

* fix command

Signed-off-by: sophiaxu0424 <[email protected]>

* added junit-platform-console-standalone.jar

Signed-off-by: sophiaxu0424 <[email protected]>

* fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fix

Signed-off-by: sophiaxu0424 <[email protected]>

* fix version with 21+

Signed-off-by: sophiaxu0424 <[email protected]>

* fix /> error

Signed-off-by: sophiaxu0424 <[email protected]>

* fix tab not 8 spaces error

Signed-off-by: sophiaxu0424 <[email protected]>

* fix line 7 syntax error: unexpected end of file

Signed-off-by: sophiaxu0424 <[email protected]>

* fix classpath from org.example to test.java in playlist command

Signed-off-by: sophiaxu0424 <[email protected]>

* added junit-platform-console-standalone-1.10.2.jar in the <command> element

Signed-off-by: sophiaxu0424 <[email protected]>

* adjust <command>

Signed-off-by: sophiaxu0424 <[email protected]>

* fix all

Signed-off-by: sophiaxu0424 <[email protected]>

* remove mockito-junit-jupiter.jar

Signed-off-by: sophiaxu0424 <[email protected]>

* removed byte-buddy.jar

Signed-off-by: sophiaxu0424 <[email protected]>

* removed mockito-core.jar

Signed-off-by: sophiaxu0424 <[email protected]>

* added back mockito-core.jar

Signed-off-by: sophiaxu0424 <[email protected]>

* added two test case output

Signed-off-by: sophiaxu0424 <[email protected]>

* fixed as to the review comment

Signed-off-by: sophiaxu0424 <[email protected]>

* added license info

Signed-off-by: sophiaxu0424 <[email protected]>

* disabled test on zos platform

Signed-off-by: sophiaxu0424 <[email protected]>

* Added tracking issue

Signed-off-by: sophiaxu0424 <[email protected]>

* updated the comment

Signed-off-by: sophiaxu0424 <[email protected]>

---------

Signed-off-by: sophiaxu0424 <[email protected]>
  • Loading branch information
sophiaxu0424 authored Apr 18, 2024
1 parent 1ef8a6f commit 78002b9
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
24 changes: 24 additions & 0 deletions functional/MockitoTests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Mockito Tests
There are two OpenJ9 user issues where a crash with Mockito is reported:

- Issue: https://github.com/eclipse-openj9/openj9/issues/18750 and

- Issue: https://github.com/eclipse-openj9/openj9/issues/18781

- Crash with Java 21 0.42, and set testing jdk version to 17+ as required for now

- Segmentation error when using Mockito with Java 21

- More Testcases would be added later as required

# This Mockito test cases will help identify the above crashes in our builds.
Test case added: test.java.MockitoMockTest

# Next test case to be added
Test case: test.java.MockitoJunitTest(TBD)

# Dependencies Required:
- mockito-core
- byte-buddy
- byte-buddy-agent
- objenesis
71 changes: 71 additions & 0 deletions functional/MockitoTests/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<project name="Mockito Tests" default="build" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<description>
Mockito Tests
</description>
<import file="${TEST_ROOT}/functional/build.xml"/>
<property name="LIB" value="byte_buddy,byte_buddy_agent,objenesis,mockito_core" />
<import file="${TEST_ROOT}/TKG/scripts/getDependencies.xml"/>

<!-- set global properties for this build -->
<property name="DEST" value="${BUILD_ROOT}/functional/MockitoTests" />

<!--Properties for this particular build-->
<property name="src" location="./src" />
<property name="build" location="./bin" />

<target name="init">
<mkdir dir="${DEST}" />
<mkdir dir="${build}" />
</target>

<target name="compile" depends="init,getDependentLibs" description="Using java ${JDK_VERSION} to compile the source ">
<echo>Ant version is ${ant.version}</echo>
<echo>============COMPILER SETTINGS============</echo>
<echo>===fork: yes</echo>
<echo>===executable: ${compiler.javac}</echo>
<echo>===debug: on</echo>
<echo>===destdir: ${DEST}</echo>
<javac srcdir="${src}" destdir="${build}" debug="true" fork="true" executable="${compiler.javac}" includeAntRuntime="false" encoding="ISO-8859-1">
<src path="${src}" />
<classpath>
<pathelement location="${LIB_DIR}/mockito-core.jar"/>
</classpath>
</javac>
</target>

<target name="dist" depends="compile" description="generate the distribution">
<jar jarfile="${DEST}/MockitoTests.jar" filesonly="true">
<fileset dir="${build}" />
<fileset dir="${src}/../" includes="*.properties,*.xml" />
</jar>
<copy todir="${DEST}">
<fileset dir="${src}/../" includes="*.xml" />
<fileset dir="${src}/../" includes="*.mk" />
</copy>
</target>

<target name="clean" depends="dist" description="clean up">
<!-- Delete the ${build} directory trees -->
<delete dir="${build}" />
</target>

<target name="build" >
<antcall target="clean" inheritall="true" />
</target>
</project>
38 changes: 38 additions & 0 deletions functional/MockitoTests/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-->

<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../TKG/resources/playlist.xsd">
<test>
<testCaseName>MockitoMockTest</testCaseName>
<disables>
<disable>
<comment>https://github.com/eclipse-openj9/openj9/issues/19331</comment>
<platform>.*zos.*</platform>
</disable>
</disables>
<command>
$(JAVA_COMMAND) $(JVM_OPTIONS) -cp $(Q)$(RESOURCES_DIR)$(P)$(TEST_RESROOT)$(D)MockitoTests.jar$(P)$(LIB_DIR)$(D)mockito-core.jar$(P)$(LIB_DIR)$(D)byte-buddy.jar$(P)$(LIB_DIR)$(D)byte-buddy-agent.jar$(P)$(LIB_DIR)$(D)objenesis.jar$(Q) test.java.MockitoMockTest ; \
$(TEST_STATUS)</command>
<levels>
<level>extended</level>
</levels>
<groups>
<group>functional</group>
</groups>
<versions>
<version>11+</version>
</versions>
</test>
</playlist>
24 changes: 24 additions & 0 deletions functional/MockitoTests/src/test/java/MockitoMockTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package test.java;

import java.util.ArrayList;
import org.mockito.Mockito;

public class MockitoMockTest {
public static void main(String[] args) {
System.out.println("Call Mockito.mock(ArrayList.class)");
Mockito.mock(ArrayList.class);
}
}

0 comments on commit 78002b9

Please sign in to comment.