Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty committed Nov 24, 2024
1 parent b0a5e7d commit 06db4c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class ContainerGebRecordingExtension implements IGlobalExtension {

@Override
void visitSpec(SpecInfo spec) {
if (isContainerGebSpec(spec)) {
validateContainerGebSpec(spec)

if (isContainerGebSpec(spec) && validateContainerGebSpec(spec)) {
ContainerGebTestListener listener = new ContainerGebTestListener(holder, spec, LocalDateTime.now())
spec.addSetupInterceptor {
holder.reinitialize(it)
Expand All @@ -70,10 +68,12 @@ class ContainerGebRecordingExtension implements IGlobalExtension {
return false
}

private static void validateContainerGebSpec(SpecInfo specInfo) {
private static boolean validateContainerGebSpec(SpecInfo specInfo) {
if (!specInfo.annotations.find { it.annotationType() == Integration }) {
throw new IllegalArgumentException('ContainerGebSpec classes must be annotated with @Integration')
}

return true
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ package grails.plugin.geb
import groovy.transform.CompileStatic
import groovy.transform.Memoized
import groovy.util.logging.Slf4j
import org.testcontainers.containers.BrowserWebDriverContainer
import org.testcontainers.containers.VncRecordingContainer

import static org.testcontainers.containers.BrowserWebDriverContainer.*
import static org.testcontainers.containers.VncRecordingContainer.*
import static org.testcontainers.containers.BrowserWebDriverContainer.VncRecordingMode
import static org.testcontainers.containers.VncRecordingContainer.VncRecordingFormat

/**
* Handles parsing various recording configuration used by {@link grails.plugin.geb.ContainerGebRecordingExtension}
Expand All @@ -43,8 +41,12 @@ class RecordingSettings {

RecordingSettings() {
recordingDirectoryName = System.getProperty('grails.geb.recording.directory', 'build/recordings')
recordingMode = VncRecordingMode.valueOf(System.getProperty('grails.geb.recording.mode', DEFAULT_RECORDING_MODE.name()))
recordingFormat = VncRecordingFormat.valueOf(System.getProperty('grails.geb.recording.format', DEFAULT_RECORDING_FORMAT.name()))
recordingMode = VncRecordingMode.valueOf(
System.getProperty('grails.geb.recording.mode', DEFAULT_RECORDING_MODE.name())
)
recordingFormat = VncRecordingFormat.valueOf(
System.getProperty('grails.geb.recording.format', DEFAULT_RECORDING_FORMAT.name())
)
}

boolean isRecordingEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package grails.plugin.geb

import geb.Browser
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeOptions
Expand All @@ -35,6 +36,7 @@ import java.time.Duration
* @author James Daugherty
* @since 5.0
*/
@CompileStatic
class WebDriverContainerHolder {

RecordingSettings recordingSettings
Expand All @@ -49,14 +51,13 @@ class WebDriverContainerHolder {
currentContainer != null
}

boolean stop() {
void stop() {
if (!currentContainer) {
return false
return
}
currentContainer.stop()
currentContainer = null
configuration = null
return true
}

boolean matchesCurrentContainerConfiguration(WebDriverContainerConfiguration specConfiguration) {
Expand Down Expand Up @@ -123,6 +124,7 @@ class WebDriverContainerHolder {
currentContainer.getContainerInfo().getNetworkSettings().getNetworks().entrySet().first().value.ipAddress
}

@CompileStatic
@EqualsAndHashCode
private static class WebDriverContainerConfiguration {

Expand Down

0 comments on commit 06db4c7

Please sign in to comment.