-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support classpath resource for custom TestSource in dynamic tests
Issue #1178 introduced support for creating a UriSource (specifically a FileSource, DirectorySource, or DefaultUriSource) from a URI supplied for a dynamic container or dynamic test. This commit further extends that feature by introducing support for creating a ClasspathResourceSource from a URI supplied for a dynamic container or dynamic test if the URI contains the "classpath" scheme. Otherwise, the behavior introduced in #1178 is used. Issue: #1467
- Loading branch information
Showing
7 changed files
with
258 additions
and
45 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
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
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
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
48 changes: 48 additions & 0 deletions
48
...form-engine/src/main/java/org/junit/platform/engine/support/descriptor/ResourceUtils.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,48 @@ | ||
/* | ||
* Copyright 2015-2018 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.engine.support.descriptor; | ||
|
||
import java.net.URI; | ||
|
||
import org.junit.platform.commons.util.Preconditions; | ||
import org.junit.platform.commons.util.StringUtils; | ||
|
||
/** | ||
* Collection of static utility methods for working with resources. | ||
* | ||
* @since 1.3 | ||
*/ | ||
final class ResourceUtils { | ||
|
||
private ResourceUtils() { | ||
/* no-op */ | ||
} | ||
|
||
/** | ||
* Strip the {@link URI#getQuery() query} component from the supplied | ||
* {@link URI}. | ||
* | ||
* @param uri the {@code URI} from which to strip the query component | ||
* @return a new {@code URI} with the query component removed, or the | ||
* original {@code URI} unmodified if it does not have a query component | ||
*/ | ||
static URI stripQueryComponent(URI uri) { | ||
Preconditions.notNull(uri, "URI must not be null"); | ||
|
||
if (StringUtils.isBlank(uri.getQuery())) { | ||
return uri; | ||
} | ||
|
||
String uriAsString = uri.toString(); | ||
return URI.create(uriAsString.substring(0, uriAsString.indexOf('?'))); | ||
} | ||
|
||
} |
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
Oops, something went wrong.