|
16 | 16 | import io.cucumber.core.gherkin.Feature;
|
17 | 17 | import io.cucumber.core.gherkin.Step;
|
18 | 18 | import io.cucumber.core.runtime.TimeServiceEventBus;
|
| 19 | +import io.cucumber.core.stepexpression.StepTypeRegistry; |
19 | 20 | import io.cucumber.cucumberexpressions.ParameterByTypeTransformer;
|
20 | 21 | import io.cucumber.cucumberexpressions.ParameterType;
|
21 | 22 | import io.cucumber.datatable.DataTable;
|
@@ -528,6 +529,94 @@ void parameterTypeDefinition_with_source_reference_emits_parameterType_with_non_
|
528 | 529 | assertNotNull(sourceReference.getJavaStackTraceElement());
|
529 | 530 | }
|
530 | 531 |
|
| 532 | + @Test |
| 533 | + void prepareGlue_cache_evicted_when_language_changes() { |
| 534 | + // Given |
| 535 | + glue.prepareGlue(LANGUAGE); |
| 536 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 537 | + |
| 538 | + // When |
| 539 | + glue.prepareGlue(Locale.FRENCH); |
| 540 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 541 | + |
| 542 | + // Then |
| 543 | + assertThat(stepTypeRegistry1!=stepTypeRegistry2, is(true)); |
| 544 | + } |
| 545 | + |
| 546 | + @Test |
| 547 | + void prepareGlue_cache_not_evicted_when_language_remains() { |
| 548 | + // Given |
| 549 | + glue.prepareGlue(LANGUAGE); |
| 550 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 551 | + |
| 552 | + // When |
| 553 | + glue.prepareGlue(LANGUAGE); |
| 554 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 555 | + |
| 556 | + // Then |
| 557 | + assertThat(stepTypeRegistry1==stepTypeRegistry2, is(true)); |
| 558 | + } |
| 559 | + |
| 560 | + @Test |
| 561 | + void prepareGlue_cache_evicted_when_stepDefinition_added() { |
| 562 | + // Given |
| 563 | + glue.prepareGlue(LANGUAGE); |
| 564 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 565 | + |
| 566 | + // When |
| 567 | + glue.addStepDefinition(new MockedStepDefinition("mock")); |
| 568 | + glue.prepareGlue(LANGUAGE); |
| 569 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 570 | + |
| 571 | + // Then |
| 572 | + assertThat(stepTypeRegistry1!=stepTypeRegistry2, is(true)); |
| 573 | + } |
| 574 | + |
| 575 | + @Test |
| 576 | + void prepareGlue_cache_evicted_when_parameterType_added() { |
| 577 | + // Given |
| 578 | + glue.prepareGlue(LANGUAGE); |
| 579 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 580 | + |
| 581 | + // When |
| 582 | + glue.addParameterType(new MockedParameterTypeDefinition()); |
| 583 | + glue.prepareGlue(LANGUAGE); |
| 584 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 585 | + |
| 586 | + // Then |
| 587 | + assertThat(stepTypeRegistry1!=stepTypeRegistry2, is(true)); |
| 588 | + } |
| 589 | + |
| 590 | + @Test |
| 591 | + void prepareGlue_cache_evicted_when_dataTableType_added() { |
| 592 | + // Given |
| 593 | + glue.prepareGlue(LANGUAGE); |
| 594 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 595 | + |
| 596 | + // When |
| 597 | + glue.addDataTableType(new MockedDataTableTypeDefinition()); |
| 598 | + glue.prepareGlue(LANGUAGE); |
| 599 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 600 | + |
| 601 | + // Then |
| 602 | + assertThat(stepTypeRegistry1!=stepTypeRegistry2, is(true)); |
| 603 | + } |
| 604 | + |
| 605 | + @Test |
| 606 | + void prepareGlue_cache_evicted_when_docString_added() { |
| 607 | + // Given |
| 608 | + glue.prepareGlue(LANGUAGE); |
| 609 | + StepTypeRegistry stepTypeRegistry1 = glue.getStepTypeRegistry(); |
| 610 | + |
| 611 | + // When |
| 612 | + glue.addDocStringType(new MockedDocStringTypeDefinition()); |
| 613 | + glue.prepareGlue(LANGUAGE); |
| 614 | + StepTypeRegistry stepTypeRegistry2 = glue.getStepTypeRegistry(); |
| 615 | + |
| 616 | + // Then |
| 617 | + assertThat(stepTypeRegistry1!=stepTypeRegistry2, is(true)); |
| 618 | + } |
| 619 | + |
531 | 620 | private static class MockedScenarioScopedStepDefinition extends StubStepDefinition implements ScenarioScoped {
|
532 | 621 |
|
533 | 622 | MockedScenarioScopedStepDefinition(String pattern, Type... types) {
|
|
0 commit comments