/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 * * http://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 jakarta.el;
import org.junit.Assert; import org.junit.Test;
publicclass TestELResolver {
@Test publicvoid testConvertToType01() {
ELContext context = new TesterELContext();
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "1", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("1", result);
}
@Test publicvoid testConvertToType02() {
ELContext context = new TesterELContext(new TesterELResolverOne());
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "1", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("ONE", result);
}
@Test publicvoid testConvertToType03() {
ELContext context = new TesterELContext(new TesterELResolverOne());
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "2", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("2", result);
}
@Test publicvoid testConvertToType04() {
CompositeELResolver resolver = new CompositeELResolver();
ELContext context = new TesterELContext(resolver);
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "2", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("2", result);
}
@Test publicvoid testConvertToType05() {
CompositeELResolver resolver = new CompositeELResolver();
resolver.add(new TesterELResolverOne());
resolver.add(new TesterELResolverTwo());
ELContext context = new TesterELContext(resolver);
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "1", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("ONE", result);
}
@Test publicvoid testConvertToType06() {
CompositeELResolver resolver = new CompositeELResolver();
resolver.add(new TesterELResolverOne());
resolver.add(new TesterELResolverTwo());
ELContext context = new TesterELContext(resolver);
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "2", String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals("TWO", result);
}
@Test publicvoid testConvertToType07() {
CompositeELResolver resolver = new CompositeELResolver();
resolver.add(new TesterELResolverOne());
resolver.add(new TesterELResolverTwo());
ELContext context = new TesterELContext(resolver);
ValueExpression ve = ELManager.getExpressionFactory().createValueExpression(context, "3", String.class);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.