[java-shib-shared] branch main updated: Remove deprecated constructors and fix POM warning.
Scott Cantor
cantor.2 at osu.edu
Thu Sep 22 17:25:15 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=7daedf15a3d8eb45f3933cd5e28b6f80ef30c239
The following commit(s) were added to refs/heads/main by this push:
new 7daedf15 Remove deprecated constructors and fix POM warning.
7daedf15 is described below
commit 7daedf15a3d8eb45f3933cd5e28b6f80ef30c239
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Sep 22 13:25:12 2022 -0400
Remove deprecated constructors and fix POM warning.
---
pom.xml | 1 -
.../java/support/scripting/EvaluableScript.java | 186 ---------------------
.../support/scripting/EvaluableScriptTest.java | 66 +-------
3 files changed, 1 insertion(+), 252 deletions(-)
diff --git a/pom.xml b/pom.xml
index f0d84508..7525a73e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,6 @@
These were previously known as java-support and spring-extensions.
</description>
- <groupId>net.shibboleth</groupId>
<artifactId>shib-shared-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
diff --git a/shib-support/src/main/java/net/shibboleth/utilities/java/support/scripting/EvaluableScript.java b/shib-support/src/main/java/net/shibboleth/utilities/java/support/scripting/EvaluableScript.java
index fd1aa8a4..5ee522d0 100644
--- a/shib-support/src/main/java/net/shibboleth/utilities/java/support/scripting/EvaluableScript.java
+++ b/shib-support/src/main/java/net/shibboleth/utilities/java/support/scripting/EvaluableScript.java
@@ -37,15 +37,12 @@ import org.slf4j.LoggerFactory;
import com.google.common.io.Files;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.resource.Resource;
@@ -73,189 +70,6 @@ public final class EvaluableScript extends AbstractInitializableComponent {
public EvaluableScript() {
}
- /**
- * Constructor.
- *
- * @param engineName the JSR-223 scripting engine name
- * @param scriptSource the script source
- * @deprecated in 8.1
- * @throws ScriptException thrown if the scripting engine supports compilation and the script does not compile
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="engineName") @Nonnull @NotEmpty final String engineName,
- @ParameterName(name="scriptSource") @Nonnull @NotEmpty final String scriptSource)
- throws ScriptException {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "EvaluableScript(parameters...)",
- null, "by using the setters");
- scriptLanguage =
- Constraint.isNotNull(StringSupport.trimOrNull(engineName),
- "Scripting language can not be null or empty");
- script = Constraint.isNotNull(StringSupport.trimOrNull(scriptSource), "Script source can not be null or empty");
-
- initializeWithScriptException();
- }
-
- /**
- * Constructor.
- *
- * @param scriptSource the script source
- * @deprecated in 8.1
- * @throws ScriptException thrown if the scripting engine supports compilation and the script does not compile
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="scriptSource") @Nonnull @NotEmpty final String scriptSource)
- throws ScriptException {
- this("javascript", scriptSource);
- }
-
- /**
- * Constructor.
- *
- * @param engineName the JSR-223 scripting engine name
- * @param scriptSource the script source
- * @deprecated in 8.1
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- *
- * @since 8.0.0
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="engineName") @Nonnull @NotEmpty final String engineName,
- @ParameterName(name="scriptSource") @Nonnull final Resource scriptSource)
- throws ScriptException {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "EvaluableScript(parameters...)",
- null, "by using the setters");
- scriptLanguage = Constraint.isNotNull(StringSupport.trimOrNull(engineName),
- "Scripting language can not be null or empty");
-
- try (final InputStream in =
- Constraint.isNotNull(scriptSource, "Script source can not be null or empty").getInputStream()) {
- script = StringSupport.inputStreamToString(in, null);
- } catch (final IOException e) {
- throw new ScriptException(e);
- }
-
- initializeWithScriptException();
- }
-
- /**
- * Constructor.
- *
- * @param scriptSource the script source
- *
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- * @deprecated in 8.1
- * @since 8.0.0
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="scriptSource") @Nonnull final Resource scriptSource)
- throws ScriptException {
- this("javascript", scriptSource);
- }
-
- /**
- * Constructor. The provided stream is <strong>not</strong> closed.
- *
- * @param engineName the JSR-223 scripting engine name
- * @param scriptSource the script source
- * @deprecated in 8.1
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="engineName") @Nonnull @NotEmpty final String engineName,
- @ParameterName(name="scriptSource") @Nonnull final InputStream scriptSource)
- throws ScriptException {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "EvaluableScript(parameters...)",
- null, "by using the setters");
- scriptLanguage =
- Constraint.isNotNull(StringSupport.trimOrNull(engineName),
- "Scripting language can not be null or empty");
- try {
- script = StringSupport.inputStreamToString(
- Constraint.isNotNull(scriptSource, "Script source can not be null or empty"), null);
- } catch (final IOException e) {
- throw new ScriptException(e);
- }
-
- initializeWithScriptException();
- }
-
- /**
- * Constructor. The provided stream is <strong>not</strong> closed.
- *
- * @param scriptSource the script source
- *
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- * @deprecated in 8.1
- * @since 8.0.0
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="scriptSource") @Nonnull final InputStream scriptSource)
- throws ScriptException {
- this("javascript", scriptSource);
- }
-
- /**
- * Constructor.
- *
- * @param engineName the JSR-223 scripting engine name
- * @param scriptSource the script source
- * @deprecated in 8.1
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="engineName") @Nonnull @NotEmpty final String engineName,
- @ParameterName(name="scriptSource") @Nonnull final File scriptSource)
- throws ScriptException {
- DeprecationSupport.warnOnce(ObjectType.METHOD, "EvaluableScript(parameters...)",
- null, "by using the setters");
- scriptLanguage =
- Constraint.isNotNull(StringSupport.trimOrNull(engineName),
- "Scripting language can not be null or empty");
-
- Constraint.isNotNull(scriptSource, "Script source file can not be null");
-
- if (!scriptSource.exists()) {
- throw new ScriptException("Script source file " + scriptSource.getAbsolutePath() + " does not exist");
- }
-
- if (!scriptSource.canRead()) {
- throw new ScriptException("Script source file " + scriptSource.getAbsolutePath()
- + " exists but is not readable");
- }
-
- try {
- script =
- Constraint.isNotNull(
- StringSupport.trimOrNull(Files.asCharSource(scriptSource, Charset.defaultCharset()).read()),
- "Script source cannot be empty");
- } catch (final IOException e) {
- throw new ScriptException("Unable to read data from source file " + scriptSource.getAbsolutePath());
- }
-
- initializeWithScriptException();
- }
-
- /**
- * Constructor.
- *
- * @param scriptSource the script source
- *
- * @throws ScriptException thrown if the script source file can not be read or the scripting engine supports
- * compilation and the script does not compile
- * @deprecated in 8.1
- * @since 8.0.0
- */
- @Deprecated(forRemoval = true, since = "8.1.0")
- public EvaluableScript(@ParameterName(name="scriptSource") @Nonnull final File scriptSource)
- throws ScriptException {
- this("javascript", scriptSource);
- }
-
/**
* Gets the script source.
*
diff --git a/shib-support/src/test/java/net/shibboleth/utilities/java/support/scripting/EvaluableScriptTest.java b/shib-support/src/test/java/net/shibboleth/utilities/java/support/scripting/EvaluableScriptTest.java
index d9aa798b..c7136d3c 100644
--- a/shib-support/src/test/java/net/shibboleth/utilities/java/support/scripting/EvaluableScriptTest.java
+++ b/shib-support/src/test/java/net/shibboleth/utilities/java/support/scripting/EvaluableScriptTest.java
@@ -56,70 +56,6 @@ public class EvaluableScriptTest {
}
}
- @SuppressWarnings("removal")
- @Test public void testEvaluableScriptDeprecated() throws ScriptException, IOException {
-
- new EvaluableScript(SCRIPT_LANGUAGE, TEST_SIMPLE_SCRIPT);
-
- try {
- new EvaluableScript(" ", TEST_SIMPLE_SCRIPT);
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
-
- try {
- new EvaluableScript(SCRIPT_LANGUAGE, " ");
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
-
- try {
- new EvaluableScript(nullValue(), TEST_SIMPLE_SCRIPT);
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
-
- try {
- new EvaluableScript(SCRIPT_LANGUAGE, (String) nullValue());
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
-
- theFile = File.createTempFile("EvaluableScriptTest", ".js");
-
- try (final FileWriter s = new FileWriter(theFile)) {
- s.write(TEST_SIMPLE_SCRIPT, 0, TEST_SIMPLE_SCRIPT.length());
- }
-
- Assert.assertEquals((new EvaluableScript(SCRIPT_LANGUAGE, theFile)).getScriptLanguage(), SCRIPT_LANGUAGE);
-
- try (InputStream is = new FileInputStream(theFile)) {
- Assert.assertEquals((new EvaluableScript(SCRIPT_LANGUAGE, is)).getScriptLanguage(), SCRIPT_LANGUAGE);
- }
-
- try (InputStream is = new FileInputStream(theFile)) {
- Assert.assertEquals((new EvaluableScript(SCRIPT_LANGUAGE, resourceFor(is))).getScriptLanguage(), SCRIPT_LANGUAGE);
- }
-
- try {
- new EvaluableScript(nullValue(), theFile);
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
-
- try {
- new EvaluableScript(SCRIPT_LANGUAGE, (File) nullValue());
- Assert.fail();
- } catch (final ConstraintViolationException e) {
- // OK
- }
- }
-
private EvaluableScript testEvaluableScript(String language, String script) throws ComponentInitializationException {
final EvaluableScript ev = new EvaluableScript();
ev.setEngineName(language);
@@ -152,7 +88,7 @@ public class EvaluableScriptTest {
return ev;
}
- @Test public void testEvaluableScriptNonDeprecated() throws ScriptException, IOException, ComponentInitializationException {
+ @Test public void testEvaluableScript() throws ScriptException, IOException, ComponentInitializationException {
testEvaluableScript(SCRIPT_LANGUAGE, TEST_SIMPLE_SCRIPT);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list