-
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
f3bc377
commit 909e179
Showing
9 changed files
with
422 additions
and
194 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
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
package org.testng.internal.protocols; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
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; | ||
|
||
class BundledResourceProcessor extends Processor { | ||
@Override | ||
public List<String> process(Input input, URL url) { | ||
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.