Skip to content

Commit

Permalink
Merge branch 'master' into BAEL-6242-move-code
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiklins authored Oct 13, 2024
2 parents 2c886db + 510dc41 commit 406338d
Show file tree
Hide file tree
Showing 33 changed files with 166 additions and 52 deletions.
5 changes: 5 additions & 0 deletions core-java-modules/core-java-io-5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>de.vandermeer</groupId>
<artifactId>asciitable</artifactId>
<version>0.3.2</version>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions lombok-modules/lombok-3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@
</plugins>
</build>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.baeldung.lombok.locked;

import lombok.Locked;

public class Counter {

private int counter = 0;

@Locked.Write
public void increment() {
counter++;
}

@Locked.Read
public int get() {
return counter;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.baeldung.lombok.locked;

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

import org.junit.jupiter.api.Test;

class CounterUnitTest {

@Test
void givenCounter_whenIncrementCalledMultipleTimes_thenReturnCorrectResult() throws InterruptedException {
Counter counter = new Counter();

Thread.Builder builder = Thread.ofVirtual()
.name("worker-", 0);
Runnable task = counter::increment;

Thread t1 = builder.start(task);
t1.join();

Thread t2 = builder.start(task);
t2.join();

assertEquals(2, counter.get());
}
}
File renamed without changes
9 changes: 7 additions & 2 deletions testing-modules/selenium-2/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
### Relevant Articles:
- [Running Selenium Scripts with JMeter](https://www.baeldung.com/selenium-jmeter)
- [Fixing Selenium WebDriver Executable Path Error](https://www.baeldung.com/java-selenium-webdriver-path-error)
- [Implicit Wait vs Explicit Wait in Selenium Webdriver](https://www.baeldung.com/selenium-implicit-explicit-wait)
- [Switching Between Frames Using Selenium WebDriver in Java](https://www.baeldung.com/java-selenium-change-frames)
- [Uploading File Using Selenium Webdriver in Java](https://www.baeldung.com/java-selenium-upload-file)
- [Using Cookies With Selenium WebDriver in Java](https://www.baeldung.com/java-selenium-webdriver-cookies)
- [StaleElementReferenceException in Selenium](https://www.baeldung.com/selenium-staleelementreferenceexception)
- [Retrieve the Value of an HTML Input in Selenium WebDriver](https://www.baeldung.com/java-selenium-html-input-value)
- [Clicking Elements in Selenium using JavaScript](https://www.baeldung.com/java-selenium-javascript)
- [Guide to Selenium with JUnit / TestNG](http://www.baeldung.com/java-selenium-with-junit-and-testng)
- [Finding Element by Attribute in Selenium](https://www.baeldung.com/selenium-find-element-by-attribute)
- [Automated Visual Regression Testing Over Scalable Cloud Grid](https://www.baeldung.com/automated-visual-regression-testing)
- [How to Handle Alerts and Popups in Selenium](https://www.baeldung.com/java-selenium-handle-alerts-popups)
- [Automated Accessibility Testing With Selenium](https://www.baeldung.com/java-selenium-accessibility-testing)


#### Notes:
- to run the live tests for the article *Fixing Selenium WebDriver Executable Path Error*, follow the manual setup described
[Fixing Selenium WebDriver Executable Path Error](https://www.baeldung.com/java-selenium-webdriver-path-error#manual-setup); download the 3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.baeldung.selenium.config;

import java.io.File;
import java.time.Duration;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumConfig {

private WebDriver driver;

public SeleniumConfig() {
driver = new FirefoxDriver();
driver.manage()
.timeouts()
.implicitlyWait(Duration.ofSeconds(5));
}

static {
System.setProperty("webdriver.gecko.driver", findFile("geckodriver.mac"));
}

private static String findFile(String filename) {
String[] paths = { "", "bin/", "target/classes" }; // if you have chromedriver somewhere else on the path, then put it here.
for (String path : paths) {
if (new File(path + filename).exists())
return path + filename;
}
return "";
}

public void close() {
driver.close();
}

public void navigateTo(String url) {
driver.navigate()
.to(url);
}

public void clickElement(WebElement element) {
element.click();
}

public WebDriver getDriver() {
return driver;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.baeldung.selenium.stale;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class RobustWebDriver implements WebDriver {

private final WebDriver originalWebDriver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.baeldung.selenium.stale;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.OutputType;
Expand All @@ -9,12 +15,6 @@
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

public class RobustWebElement implements WebElement {

private WebElement originalElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.baeldung.selenium.stale;

import org.openqa.selenium.WebElement;

import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

import org.openqa.selenium.WebElement;

public class WebElementUtils {

private WebElementUtils(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.baeldung.selenium.clickusingjavascript;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -11,13 +18,6 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

public class SeleniumJavaScriptClickLiveTest {

private WebDriver driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.io.File;
import java.time.Duration;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.baeldung.selenium.stale;

import io.github.bonigarcia.wdm.WebDriverManager;
import java.time.Duration;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -10,7 +11,7 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.time.Duration;
import io.github.bonigarcia.wdm.WebDriverManager;

final class RobustWebElementLiveTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.baeldung.selenium.stale;

import io.github.bonigarcia.wdm.WebDriverManager;
import java.time.Duration;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -12,7 +13,7 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.time.Duration;
import io.github.bonigarcia.wdm.WebDriverManager;

final class StaleElementReferenceLiveTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.baeldung.selenium.webdriver;

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

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -9,6 +10,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class SeleniumWebDriverLiveTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.baeldung.selenium.webdriver.fileupload;

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

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
10 changes: 4 additions & 6 deletions testing-modules/selenium/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
### Relevant Articles:

- [Guide to Selenium with JUnit / TestNG](http://www.baeldung.com/java-selenium-with-junit-and-testng)
- [Clicking Elements in Selenium using JavaScript](https://www.baeldung.com/java-selenium-javascript)
- [Retrieve the Value of an HTML Input in Selenium WebDriver](https://www.baeldung.com/java-selenium-html-input-value)
- [Testing with Selenium/WebDriver and the Page Object Pattern](http://www.baeldung.com/selenium-webdriver-page-object)
- [Using Cookies With Selenium WebDriver in Java](https://www.baeldung.com/java-selenium-webdriver-cookies)
- [Taking Screenshots With Selenium WebDriver](https://www.baeldung.com/java-selenium-screenshots)
- [Uploading File Using Selenium Webdriver in Java](https://www.baeldung.com/java-selenium-upload-file)
- [StaleElementReferenceException in Selenium](https://www.baeldung.com/selenium-staleelementreferenceexception)
- [How to Select Value From Dropdown Using Selenium Webdriver](https://www.baeldung.com/java-selenium-select-dropdown-value)
- [Fixing Selenium WebDriver Executable Path Error](https://www.baeldung.com/java-selenium-webdriver-path-error)
- [Implicit Wait vs Explicit Wait in Selenium Webdriver](https://www.baeldung.com/selenium-implicit-explicit-wait)
- [Automated Visual Regression Testing Over Scalable Cloud Grid](https://www.baeldung.com/automated-visual-regression-testing)
- [Finding Element by Attribute in Selenium](https://www.baeldung.com/selenium-find-element-by-attribute)


#### Notes:
Expand Down
5 changes: 5 additions & 0 deletions testing-modules/selenium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.File;
import java.time.Duration;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.baeldung.selenium.visualregression;

import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import static java.text.MessageFormat.format;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.util.HashMap;

import static java.text.MessageFormat.format;
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;

public class DriverManager {
private WebDriver driver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.baeldung.selenium.find;

import static org.testng.Assert.assertTrue;

import java.time.Duration;
import java.util.List;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -11,11 +16,6 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.List;

import static org.testng.Assert.assertTrue;

class CheckIfElementPresentManualTest {

private WebDriver driver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.baeldung.selenium.find;

import java.time.Duration;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Expand All @@ -9,8 +11,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.time.Duration;

public class FindElementByAttributeManualTest {

private WebDriver driver;
Expand Down
Loading

0 comments on commit 406338d

Please sign in to comment.