Remove obsolete Nashorn-based scripting tests

Since the Nashorn JavaScript engine was removed in Java 15, these tests
will never be run on a Java 17+ JDK which is required as of Spring
Framework 6.0.

See gh-27919
This commit is contained in:
Sam Brannen
2022-03-15 16:33:52 +01:00
parent e9655e8a7b
commit 4db2f8ea1b
11 changed files with 0 additions and 953 deletions

View File

@@ -1,71 +0,0 @@
/*
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.scripting.support;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.target.dynamic.Refreshable;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scripting.Messenger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.condition.JRE.JAVA_15;
/**
* {@link StandardScriptFactory} (lang:std) tests for JavaScript.
*
* @author Juergen Hoeller
* @since 4.2
*/
@DisabledForJreRange(min = JAVA_15) // Nashorn JavaScript engine removed in Java 15
public class StandardScriptFactoryTests {
@Test
public void testJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jsr223-with-xsd.xml", getClass());
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface");
assertThat(AopUtils.isAopProxy(messenger)).isFalse();
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
@Test
public void testRefreshableJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jsr223-with-xsd.xml", getClass());
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("refreshableMessengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("refreshableMessengerWithInterface");
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
boolean condition = messenger instanceof Refreshable;
assertThat(condition).isTrue();
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
@Test
public void testInlineJsr223FromTagWithInterface() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jsr223-with-xsd.xml", getClass());
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("inlineMessengerWithInterface")).isTrue();
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
assertThat(AopUtils.isAopProxy(messenger)).isFalse();
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
}
}

View File

@@ -1 +0,0 @@
function getMessage() { return "Hello World!" }

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/lang https://www.springframework.org/schema/lang/spring-lang-4.2.xsd">
<lang:std id="messengerWithInterface" script-source="classpath:org/springframework/scripting/support/Messenger.js"
script-interfaces="org.springframework.scripting.Messenger"/>
<lang:std id="refreshableMessengerWithInterface" refresh-check-delay="5000"
script-source="classpath:org/springframework/scripting/support/Messenger.js"
script-interfaces="org.springframework.scripting.Messenger">
</lang:std>
<lang:std id="inlineMessengerWithInterface" engine="JavaScript"
script-interfaces="org.springframework.scripting.Messenger">
<lang:inline-script>
function getMessage() { return "Hello World!" }
</lang:inline-script>
</lang:std>
</beans>