Skip to content
Open
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
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- test properties -->
<!-- For OAuth rollout testing, modify default user (put in username), endpoint (your url for env) and password manually or via script -->
<test.endpoint>https://testendpoint</test.endpoint>
<test.user.default>[email protected]</test.user.default>
<test.user.restricted>[email protected]</test.user.restricted>
Expand Down Expand Up @@ -177,6 +178,19 @@
<version>5.18.0</version>
<scope>test</scope>
</dependency>
<!-- Selenium WebDriver for OAuth testing -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.15.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.15.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
Expand Down Expand Up @@ -607,6 +621,11 @@
<phase>verify</phase>
<configuration>
<skipTests>!${skip-unit-tests}</skipTests>
<systemPropertyVariables>
<test.endpoint>${test.endpoint}</test.endpoint>
<test.user.default>${test.user.default}</test.user.default>
<test.password>${test.password}</test.password>
</systemPropertyVariables>
<excludes>
<exclude>**/action/**,
**/dao/**,
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/salesforce/dataloader/ui/URLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,36 @@

public class URLUtil {
private static Logger logger = DLLogManager.getLogger(URLUtil.class);
private static volatile UrlOpener testHook = null;

/**
* Set a test hook for URL opening (used by tests to inject Selenium).
* @param opener The UrlOpener implementation to use for tests
*/
public static void setTestHook(UrlOpener opener) {
testHook = opener;
}

/**
* Clear the test hook to restore normal URL opening behavior.
*/
public static void clearTestHook() {
testHook = null;
}

public static void openURL(String url) {
// Check for test hook first
if (testHook != null) {
try {
logger.debug("Using test hook for URL opening: " + url);
testHook.open(url);
return;
} catch (Exception e) {
logger.warn("Test hook failed, falling back to default behavior: " + e.getMessage());
}
}

// Default production behavior
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/salesforce/dataloader/ui/UrlOpener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2015, salesforce.com, inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.salesforce.dataloader.ui;

/**
* Interface for opening URLs, allowing test seams for browser automation.
* Production uses Desktop.browse(), tests can inject Selenium WebDriver.
*/
public interface UrlOpener {
/**
* Opens the specified URL.
* @param url The URL to open
* @throws Exception if the URL cannot be opened
*/
void open(String url) throws Exception;
}
Loading