-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broke down the implementation into multiple Child classes powered by a factory method.
- Loading branch information
1 parent
bc23c47
commit e5ae7f7
Showing
7 changed files
with
387 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
testng-core-api/src/main/java/org/testng/internal/protocols/BundledResourceProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.testng.internal.protocols; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.Method; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.net.URLDecoder; | ||
import java.util.List; | ||
import org.testng.collections.Lists; | ||
|
||
public class BundledResourceProcessor extends Processor { | ||
@Override | ||
public List<String> process(Input input, URL url) throws IOException { | ||
return processBundledResources( | ||
url, | ||
input.getIncluded(), | ||
input.getExcluded(), | ||
input.getPackageWithoutWildCards(), | ||
input.isRecursive()); | ||
} | ||
|
||
private static List<String> processBundledResources( | ||
URL url, | ||
List<String> included, | ||
List<String> excluded, | ||
String packageOnly, | ||
boolean recursive) { | ||
try { | ||
Class<?>[] params = {}; | ||
// BundleURLConnection | ||
URLConnection connection = url.openConnection(); | ||
Method thisMethod = url.openConnection().getClass().getDeclaredMethod("getFileURL", params); | ||
Object[] paramsObj = {}; | ||
URL fileUrl = (URL) thisMethod.invoke(connection, paramsObj); | ||
return findClassesInDirPackage( | ||
packageOnly, included, excluded, URLDecoder.decode(fileUrl.getFile(), UTF_8), recursive); | ||
} catch (Exception ex) { | ||
// ignore - probably not an Eclipse OSGi bundle | ||
} | ||
return Lists.newArrayList(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
testng-core-api/src/main/java/org/testng/internal/protocols/FileProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.testng.internal.protocols; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
import java.net.URL; | ||
import java.net.URLDecoder; | ||
import java.util.List; | ||
|
||
class FileProcessor extends Processor { | ||
|
||
@Override | ||
public List<String> process(Input input, URL url) { | ||
return findClassesInDirPackage( | ||
input.getPackageWithoutWildCards(), | ||
input.getIncluded(), | ||
input.getExcluded(), | ||
URLDecoder.decode(url.getFile(), UTF_8), | ||
input.isRecursive()); | ||
} | ||
} |
Oops, something went wrong.