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

Release #198

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'

- name: Build with Gradle
run: ./gradlew build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ jobs:
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'

- name: Setup git credentials
uses: oleksiyrudenko/gha-git-credentials@v2.1.1
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

## [Unreleased]
### Changed
- Client version updated on [5.1.21](https://github.com/reportportal/client-java/releases/tag/5.1.21), by @HardNorth
- Slf4j version updated on version 2.0.4 to support newer versions of Logback with security fixes, by @HardNorth
### Removed
- Java 8 support, by @HardNorth
- Obsolete `UniqueID` annotation support, by @HardNorth
- Deprecated code, by @HardNorth

## [5.2.0]
### Fixed
Expand Down
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ project.ext.limits = [
'class' : 83
]

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
mavenLocal()
Expand All @@ -39,29 +39,29 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:client-java:5.1.17'
api 'com.epam.reportportal:client-java:5.1.21'
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'com.epam.reportportal:commons-model:5.0.0'
api 'org.testng:testng:7.5' // 7.5 - the last version which supports Java 1.8
api 'org.testng:testng:7.7.0'

implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'org.slf4j:slf4j-api:2.0.4'

testImplementation('com.github.reportportal:agent-java-test-utils:236a68c')
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'

testImplementation("org.junit.platform:junit-platform-runner:${junit5_runner_version}") {
exclude module: 'junit'
}
testImplementation "org.junit.jupiter:junit-jupiter-params:${junit5_version}"
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junit5_version}"

testImplementation 'org.aspectj:aspectjweaver:1.9.2'
testImplementation 'org.aspectj:aspectjweaver:1.9.19'

testImplementation 'org.hamcrest:hamcrest-core:2.2'
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"
testImplementation 'ch.qos.logback:logback-classic:1.2.11'
testImplementation 'ch.qos.logback:logback-classic:1.4.5'

testImplementation 'com.epam.reportportal:logger-java-logback:5.1.3'
testImplementation 'com.epam.reportportal:logger-java-logback:5.1.5'

testImplementation 'org.apache.commons:commons-io:1.3.2'
testImplementation 'com.ibm.icu:icu4j:67.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.2.1-SNAPSHOT
version=5.3.0-SNAPSHOT
description=TestNG integration for ReportPortal
junit5_version=5.6.3
junit5_runner_version=1.6.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.epam.reportportal.testng;

import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.utils.MemoizingSupplier;

import java.util.function.Supplier;
Expand All @@ -27,7 +28,8 @@
public class ReportPortalTestNGListener extends BaseTestNGListener {

/* static instance with lazy init */
public static final Supplier<ITestNGService> SERVICE = new MemoizingSupplier<>(TestNGService::new);
public static final Supplier<ITestNGService> SERVICE =
new MemoizingSupplier<>(() -> new TestNGService(ReportPortal.builder().build()));

public ReportPortalTestNGListener() {
super(SERVICE.get());
Expand Down
41 changes: 0 additions & 41 deletions src/main/java/com/epam/reportportal/testng/TestNGService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.epam.reportportal.annotations.ParameterKey;
import com.epam.reportportal.annotations.TestCaseId;
import com.epam.reportportal.annotations.UniqueID;
import com.epam.reportportal.annotations.attribute.Attributes;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.reportportal.listeners.ListenerParameters;
Expand Down Expand Up @@ -95,8 +94,6 @@ public class TestNGService implements ITestNGService {
public static final String NULL_VALUE = "NULL";
public static final TestItemTree ITEM_TREE = new TestItemTree();

private static volatile ReportPortal REPORT_PORTAL = ReportPortal.builder().build();

private final Map<Object, Queue<Pair<Maybe<String>, FinishTestItemRQ>>> BEFORE_METHOD_TRACKER = new ConcurrentHashMap<>();

private final Map<Object, Boolean> RETRY_STATUS_TRACKER = new LimitedSizeConcurrentHashMap<>(MAXIMUM_HISTORY_SIZE);
Expand Down Expand Up @@ -127,38 +124,12 @@ public TestNGService(@Nonnull final ReportPortal reportPortal) {
});
}

public TestNGService() {
this(getReportPortal());
}

public TestNGService(Supplier<Launch> launchSupplier) {
launch = new MemoizingSupplier<>(launchSupplier);
shutDownHook = getShutdownHook(launch);
Runtime.getRuntime().addShutdownHook(shutDownHook);
}

/**
* Return current instance of {@link ReportPortal} class
*
* @return ReportPortal instance
* @deprecated use <code>Launch.currentLaunch().getClient()</code>
*/
@Deprecated
public static ReportPortal getReportPortal() {
return REPORT_PORTAL;
}

/**
* Set current instance of {@link ReportPortal} class
*
* @param reportPortal class instance
* @deprecated use {@link TestNGService#TestNGService(com.epam.reportportal.service.ReportPortal)}
*/
@Deprecated
protected static void setReportPortal(ReportPortal reportPortal) {
REPORT_PORTAL = reportPortal;
}

@Override
public void startLaunch() {
Maybe<String> launchId = launch.get().start();
Expand Down Expand Up @@ -338,7 +309,6 @@ protected StartTestItemRQ buildStartStepRq(final @Nonnull ITestResult testResult
rq.setAttributes(createStepAttributes(testResult));
rq.setDescription(createStepDescription(testResult));
rq.setParameters(createStepParameters(testResult));
rq.setUniqueId(extractUniqueID(testResult));
rq.setStartTime(new Date(testResult.getStartMillis()));
rq.setType(type.toString());
boolean retry = isRetry(testResult);
Expand Down Expand Up @@ -767,17 +737,6 @@ protected String createStepDescription(ITestResult testResult) {
return testResult.getMethod().getDescription();
}

/**
* Returns test item ID from annotation if it provided.
*
* @param testResult Where to find
* @return test item ID or null
*/
@Nullable
private String extractUniqueID(@Nonnull ITestResult testResult) {
return getMethodAnnotation(UniqueID.class, testResult).map(UniqueID::value).orElse(null);
}

@Nullable
private TestCaseIdEntry getTestCaseId(@Nonnull String codeRef, @Nonnull ITestResult testResult) {
Method method = getMethod(testResult);
Expand Down
26 changes: 0 additions & 26 deletions src/test/java/com/epam/reportportal/testng/BuildStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.epam.reportportal.annotations.ParameterKey;
import com.epam.reportportal.annotations.TestCaseId;
import com.epam.reportportal.annotations.TestCaseIdKey;
import com.epam.reportportal.annotations.UniqueID;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.utils.MemoizingSupplier;
Expand Down Expand Up @@ -171,25 +170,6 @@ public void testParametersNotSpecified() {
assertThat("Incorrect test item parameters", rq.getParameters(), nullValue());
}

@Test
public void testUniqueId() {
when(testResult.getMethod()).thenReturn(testNGMethod);
when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
when(testNGMethod.isTest()).thenReturn(true);
Method[] methods = TestMethodsExamples.class.getDeclaredMethods();
Method method = null;
for (Method m : methods) {
if (m.getName().contains("uniqueIdAnnotation")) {
method = m;
}
}

when(constructorOrMethod.getMethod()).thenReturn(method);
StartTestItemRQ rq = testNGService.buildStartStepRq(testResult);
assertThat("Incorrect unique id", rq.getUniqueId(), is("ProvidedID"));

}

@Test
public void testUniqueIdNotSpecified() {
when(testResult.getMethod()).thenReturn(testNGMethod);
Expand Down Expand Up @@ -358,12 +338,6 @@ public void testCaseId_fromAnnotationParametrized() {
}

private static class TestMethodsExamples {
@UniqueID("ProvidedID")
@org.testng.annotations.Test
private void uniqueIdAnnotation() {
//just for testing providing unique id
}

@Ignore
@org.testng.annotations.Test(dataProvider = "dp")
private void dataProviderWithoutKey(String param_0, String param_1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package com.epam.reportportal.testng;

import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.service.ReportPortalClient;
import com.epam.reportportal.testng.integration.feature.parameters.*;
import com.epam.reportportal.testng.integration.util.TestUtils;
import com.epam.reportportal.utils.MemoizingSupplier;
import com.epam.reportportal.utils.properties.PropertiesLoader;
import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -38,28 +32,12 @@ public static class TestReportPortalListener extends BaseTestNGListener {
public static final ThreadLocal<ReportPortal> REPORT_PORTAL_THREAD_LOCAL = new ThreadLocal<>();

public TestReportPortalListener() {
super(new TestNGServiceExtension(
new MemoizingSupplier<>(() -> getLaunch(REPORT_PORTAL_THREAD_LOCAL.get().getParameters())),
REPORT_PORTAL_THREAD_LOCAL.get()
));
super(new TestNGService(REPORT_PORTAL_THREAD_LOCAL.get()));
}

public static void initReportPortal(ReportPortal reportPortal) {
REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}

private static Launch getLaunch(ListenerParameters parameters) {

ReportPortal reportPortal = REPORT_PORTAL_THREAD_LOCAL.get();
StartLaunchRQ rq = new StartLaunchRQ();
rq.setName(parameters.getLaunchName());
rq.setStartTime(Calendar.getInstance().getTime());
rq.setMode(parameters.getLaunchRunningMode());
rq.setStartTime(Calendar.getInstance().getTime());

return reportPortal.newLaunch(rq);

}
}

private final String suitedUuid = namedUuid("suite");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.net.ServerSocket;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

Expand All @@ -22,16 +23,16 @@
public class TestLaunchFinishShutdownHook {

@ParameterizedTest
@ValueSource(classes = { LaunchFinishShutdownHookTest.class, LaunchFinishShutdownHookRemoveTest.class })
@ValueSource(classes = {LaunchFinishShutdownHookTest.class, LaunchFinishShutdownHookRemoveTest.class})
public void test_shutdown_hook_finishes_launch_on_java_machine_exit(final Class<?> clazz) throws Exception {

ServerSocket ss = SocketUtils.getServerSocketOnFreePort();
SocketUtils.ServerCallable serverCallable = new SocketUtils.ServerCallable(ss, Collections.emptyMap(), "files/socket_response.txt");
Callable<Process> clientCallable = () -> ProcessUtils.buildProcess(true, clazz,
Collections.singletonMap(StatisticsService.DISABLE_PROPERTY, "1"), String.valueOf(ss.getLocalPort()));
Pair<String, Process> startResult = SocketUtils.executeServerCallable(serverCallable, clientCallable);
Pair<List<String>, Process> startResult = SocketUtils.executeServerCallable(serverCallable, clientCallable);
assertThat(startResult.getValue(), notNullValue());
assertThat("First request is a launch start", startResult.getKey(), startsWith("POST /api/v1/test-project/launch"));
assertThat("First request is a launch start", startResult.getKey().get(0), startsWith("POST /api/v1/test-project/launch"));

Callable<Integer> clientCallableResult = () -> {
try {
Expand All @@ -45,10 +46,10 @@ public void test_shutdown_hook_finishes_launch_on_java_machine_exit(final Class<
return -2;
}
};
Pair<String, Integer> finishResult = SocketUtils.executeServerCallable(serverCallable, clientCallableResult);
Pair<List<String>, Integer> finishResult = SocketUtils.executeServerCallable(serverCallable, clientCallableResult);

assertThat("Second request is a launch finish",
finishResult.getKey(),
finishResult.getKey().get(0),
startsWith("PUT /api/v1/test-project/launch/b7a79414-287c-452d-b157-c32fe6cb1c72/finish")
);
assertThat("Exit code should be '0'", finishResult.getValue(), equalTo(0));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.epam.reportportal.testng.integration;

import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.testng.BaseTestNGListener;
import com.epam.reportportal.testng.TestNGServiceExtension;
import com.epam.reportportal.testng.integration.util.TestUtils;
import com.epam.reportportal.utils.MemoizingSupplier;
import com.epam.reportportal.testng.TestNGService;

/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
Expand All @@ -16,9 +12,7 @@ public class CallbackReportingListener extends BaseTestNGListener {
public static final ThreadLocal<ReportPortal> REPORT_PORTAL_THREAD_LOCAL = new ThreadLocal<>();

public CallbackReportingListener() {
super(new TestNGServiceExtension(new MemoizingSupplier<>(() -> getLaunch(REPORT_PORTAL_THREAD_LOCAL.get().getParameters())),
REPORT_PORTAL_THREAD_LOCAL.get()
));
super(new TestNGService(REPORT_PORTAL_THREAD_LOCAL.get()));
}

public static void initReportPortal(ReportPortal reportPortal) {
Expand All @@ -28,9 +22,4 @@ public static void initReportPortal(ReportPortal reportPortal) {
public static ReportPortal getReportPortal() {
return REPORT_PORTAL_THREAD_LOCAL.get();
}

private static Launch getLaunch(ListenerParameters parameters) {
ReportPortal reportPortal = REPORT_PORTAL_THREAD_LOCAL.get();
return reportPortal.newLaunch(TestUtils.launchRQ(parameters));
}
}
Loading