Package net.gprussell.spel

Source Code of net.gprussell.spel.ArgumentConversionTest

package net.gprussell.spel;

import static org.junit.Assert.assertSame;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.expression.BeanFactoryResolver;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class ArgumentConversionTest {

  @Autowired
  private BeanFactory beanFactory;

  @Test
  public void testBytesNotCopied() throws Exception {
    Expression expression = new SpelExpressionParser().parseExpression("@service.handleBytes(#root)");
    byte[] bytes = new byte[100];
    StandardEvaluationContext evaluationContext = new StandardEvaluationContext(bytes);
    evaluationContext.setBeanResolver(new BeanFactoryResolver(this.beanFactory));
    byte[] outBytes = expression.getValue(evaluationContext, byte[].class);
    assertSame(bytes, outBytes);
  }

}
TOP

Related Classes of net.gprussell.spel.ArgumentConversionTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.