Skip to content

Commit

Permalink
fix: rebased on main for #2767
Browse files Browse the repository at this point in the history
  • Loading branch information
U117293 authored and U117293 committed Oct 13, 2024
1 parent 8ce1a35 commit 5af37c7
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.cucumber.java.en.*;

import org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

public class StepDefinitions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.cucumber.java.en.*;

import org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

public class StepDefinitions {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.cucumber.core.backend;

import io.cucumber.core.backend.Pending;

import java.io.PrintStream;
import java.io.PrintWriter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

import io.cucumber.core.eventbus.EventBus;
import io.cucumber.core.runtime.TimeServiceEventBus;
import io.cucumber.plugin.event.HookTestStep;
import io.cucumber.plugin.event.Argument;
import io.cucumber.plugin.event.Location;
import io.cucumber.plugin.event.PickleStepTestStep;
import io.cucumber.plugin.event.Result;
import io.cucumber.plugin.event.Step;
import io.cucumber.plugin.event.StepArgument;
import io.cucumber.plugin.event.TestCase;
import io.cucumber.plugin.event.TestRunFinished;
import io.cucumber.plugin.event.TestStep;
import io.cucumber.plugin.event.TestStepFinished;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.UUID;

import static io.cucumber.core.plugin.Bytes.bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class HookTestStepTest {
" Scenario: Test scenario\n" +
" Given I have 4 cukes in my belly\n");
List<Object> listener = new ArrayList<>();
private final CoreHookDefinition hookDefintion = CoreHookDefinition.create(new MockHookDefinition(listener));
private final CoreHookDefinition hookDefintion = CoreHookDefinition.create(new MockHookDefinition(listener),
UUID::randomUUID);
private final HookDefinitionMatch definitionMatch = new HookDefinitionMatch(hookDefintion);
private final TestCase testCase = new TestCase(
UUID.randomUUID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class PickleStepTestStepTest {
private void buildStep(
RuntimeException beforeHookException, RuntimeException afterHookException, Throwable stepException
) {
beforeHookDefinition = CoreHookDefinition.create(new MockHookDefinition(beforeHookException));
afterHookDefinition = CoreHookDefinition.create(new MockHookDefinition(afterHookException));
beforeHookDefinition = CoreHookDefinition.create(new MockHookDefinition(beforeHookException), UUID::randomUUID);
afterHookDefinition = CoreHookDefinition.create(new MockHookDefinition(afterHookException), UUID::randomUUID);
definitionMatch = new MockPickleStepDefinitionMatch(stepException);
step = new PickleStepTestStep(
UUID.randomUUID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ private PickleStepTestStep createPickleStepTestStep(int index, PickleStepDefinit
feature.getPickles().get(0).getSteps().get(index),
singletonList(
new HookTestStep(UUID.randomUUID(), BEFORE_STEP,
new HookDefinitionMatch(CoreHookDefinition.create(new StubHookDefinition())))),
new HookDefinitionMatch(CoreHookDefinition.create(new StubHookDefinition(), UUID::randomUUID)))),
singletonList(
new HookTestStep(UUID.randomUUID(), AFTER_STEP,
new HookDefinitionMatch(CoreHookDefinition.create(new StubHookDefinition())))),
new HookDefinitionMatch(CoreHookDefinition.create(new StubHookDefinition(), UUID::randomUUID)))),
definitionMatch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,32 @@ void test_case_2() {
assertThat(loader.loadUuidGenerator(), instanceOf(RandomUuidGenerator.class));
}

@Test
void test_case_2_no_exception_when_calling_loadUuidGenerator_many_times() {
Options options = () -> null;
UuidGeneratorServiceLoader loader = new UuidGeneratorServiceLoader(
UuidGeneratorServiceLoaderTest.class::getClassLoader,
options);
UuidGenerator actual = null;
for (int i = 0; i < 1000; i++) {
actual = loader.loadUuidGenerator();
}
assertThat(actual, instanceOf(RandomUuidGenerator.class));
}

@Test
void test_case_2_no_exception_when_instantiating_UuidGeneratorServiceLoader_many_times() {
Options options = () -> null;
UuidGenerator actual = null;
for (int i = 0; i < 1000; i++) {
UuidGeneratorServiceLoader loader = new UuidGeneratorServiceLoader(
UuidGeneratorServiceLoaderTest.class::getClassLoader,
options);
actual = loader.loadUuidGenerator();
}
assertThat(actual, instanceOf(RandomUuidGenerator.class));
}

/**
* | 3 | RandomUuidGenerator | RandomUuidGenerator,
* IncrementingUuidGenerator | RandomUuidGenerator used |
Expand Down
1 change: 0 additions & 1 deletion cucumber-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<hamcrest.version>3.0</hamcrest.version>
<jackson.version>2.18.0</jackson.version>
<junit-jupiter.version>5.11.2</junit-jupiter.version>
<mockito.version>5.14.1</mockito.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Issue1970Test {

@Test
void issue1970() {
public void issue1970() {
ObjectFactory factory = new SpringFactory();
factory.addClass(GlueClass.class); // Add glue with Spring configuration
factory.start();
Expand Down

0 comments on commit 5af37c7

Please sign in to comment.