Package org.springframework.expression.common

Examples of org.springframework.expression.common.LiteralExpression


*/
public class FileCopyDemoCommon {

  public static void displayDirectories(ApplicationContext context) {
    File inDir = (File) new DirectFieldAccessor(context.getBean(FileReadingMessageSource.class)).getPropertyValue("directory");
    LiteralExpression expression = (LiteralExpression) new DirectFieldAccessor(context.getBean(FileWritingMessageHandler.class)).getPropertyValue("destinationDirectoryExpression");
    File outDir = new File(expression.getValue());
    System.out.println("Input directory is: " + inDir.getAbsolutePath());
    System.out.println("Output directory is: " + outDir.getAbsolutePath());
    System.out.println("===================================================");
  }
View Full Code Here


*/
public class LiteralExpressionTests {

  @Test
  public void testGetValue() throws Exception {
    LiteralExpression lEx = new LiteralExpression("somevalue");
    checkString("somevalue", lEx.getValue());
    checkString("somevalue", lEx.getValue(String.class));
    EvaluationContext ctx = new StandardEvaluationContext();
    checkString("somevalue", lEx.getValue(ctx));
    checkString("somevalue", lEx.getValue(ctx, String.class));
    checkString("somevalue", lEx.getValue(new Rooty()));
    checkString("somevalue", lEx.getValue(new Rooty(), String.class));
    checkString("somevalue", lEx.getValue(ctx, new Rooty()));
    checkString("somevalue", lEx.getValue(ctx, new Rooty(),String.class));
    assertEquals("somevalue", lEx.getExpressionString());
    assertFalse(lEx.isWritable(new StandardEvaluationContext()));
    assertFalse(lEx.isWritable(new Rooty()));
    assertFalse(lEx.isWritable(new StandardEvaluationContext(), new Rooty()));
  }
View Full Code Here

  static class Rooty {}

  @Test
  public void testSetValue() {
    try {
      LiteralExpression lEx = new LiteralExpression("somevalue");
      lEx.setValue(new StandardEvaluationContext(), "flibble");
      fail("Should have got an exception that the value cannot be set");
    }
    catch (EvaluationException ee) {
      // success, not allowed - whilst here, check the expression value in the exception
      assertEquals(ee.getExpressionString(), "somevalue");
    }
    try {
      LiteralExpression lEx = new LiteralExpression("somevalue");
      lEx.setValue(new Rooty(), "flibble");
      fail("Should have got an exception that the value cannot be set");
    }
    catch (EvaluationException ee) {
      // success, not allowed - whilst here, check the expression value in the exception
      assertEquals(ee.getExpressionString(), "somevalue");
    }
    try {
      LiteralExpression lEx = new LiteralExpression("somevalue");
      lEx.setValue(new StandardEvaluationContext(), new Rooty(), "flibble");
      fail("Should have got an exception that the value cannot be set");
    }
    catch (EvaluationException ee) {
      // success, not allowed - whilst here, check the expression value in the exception
      assertEquals(ee.getExpressionString(), "somevalue");
View Full Code Here

    }
  }

  @Test
  public void testGetValueType() throws Exception {
    LiteralExpression lEx = new LiteralExpression("somevalue");
    assertEquals(String.class, lEx.getValueType());
    assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext()));
    assertEquals(String.class, lEx.getValueType(new Rooty()));
    assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext(), new Rooty()));
    assertEquals(String.class, lEx.getValueTypeDescriptor().getType());
    assertEquals(String.class, lEx.getValueTypeDescriptor(new StandardEvaluationContext()).getType());
    assertEquals(String.class, lEx.getValueTypeDescriptor(new Rooty()).getType());
    assertEquals(String.class, lEx.getValueTypeDescriptor(new StandardEvaluationContext(), new Rooty()).getType());
  }
View Full Code Here

  public String getComponentType() {
    return "voldemort:outbound-channel-adapter";
  }

  public void setKey(String key) {
    setKeyExpression( new LiteralExpression( key ) );
  }
View Full Code Here

  @Test
  public void testHandleFileContentMessage() throws Exception {
    File file = createNewFile("remote-target-dir/handlerContent.test");
    FileTransferringMessageHandler<?> handler = new FileTransferringMessageHandler<SmbFile>(smbSessionFactory);
    handler.setRemoteDirectoryExpression(new LiteralExpression("remote-target-dir"));
    handler.setFileNameGenerator(new FileNameGenerator() {
      public String generateFileName(Message<?> message) {
        return "handlerContent.test";
      }
    });
View Full Code Here

  @Test
  public void testHandleFileAsByte() throws Exception {
    File file = createNewFile("remote-target-dir/handlerContent.test");
    FileTransferringMessageHandler<?> handler = new FileTransferringMessageHandler<SmbFile>(smbSessionFactory);
    handler.setRemoteDirectoryExpression(new LiteralExpression("remote-target-dir"));
    handler.setFileNameGenerator(new FileNameGenerator() {
      public String generateFileName(Message<?> message) {
        return "handlerContent.test";
      }
    });
View Full Code Here

   */
  public FsShellWritingMessageHandler(String destinationDirectory,
      Configuration configuration) {
    Assert.notNull(destinationDirectory,
        "Destination directory must not be null.");
    this.destinationDirectoryExpression = new LiteralExpression(
        destinationDirectory);
    createFsShell(configuration);
  }
View Full Code Here

   */
  public FsShellWritingMessageHandler(String destinationDirectory,
      Configuration configuration) {
    Assert.notNull(destinationDirectory,
        "Destination directory must not be null.");   
    this.destinationDirectoryExpression = new LiteralExpression(
        destinationDirectory);
    createFsShell(configuration);
  }
View Full Code Here

  public void create() {
    final CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
    connectionFactory.setHost("localhost");
    connectionFactory.setPort(BrokerTestUtils.getPort());
    template = new RabbitTemplate(connectionFactory);
    template.setSendConnectionFactorySelectorExpression(new LiteralExpression("foo"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.expression.common.LiteralExpression

Copyright © 2018 www.massapicom. 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.