From 69979c9e5e4a2ace37b5e70344ad4fa154af5e3a Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 21 Feb 2008 22:55:51 +0000 Subject: [PATCH] Migrating adapters to spring-integration-adapters (INT-83). --- .../file/DefaultFileNameGeneratorTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 spring-integration-adapters/src/test/java/org/springframework/integration/adapter/file/DefaultFileNameGeneratorTests.java diff --git a/spring-integration-adapters/src/test/java/org/springframework/integration/adapter/file/DefaultFileNameGeneratorTests.java b/spring-integration-adapters/src/test/java/org/springframework/integration/adapter/file/DefaultFileNameGeneratorTests.java new file mode 100644 index 0000000000..adf525f8ca --- /dev/null +++ b/spring-integration-adapters/src/test/java/org/springframework/integration/adapter/file/DefaultFileNameGeneratorTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2002-2007 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 + * + * 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 org.springframework.integration.adapter.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import org.springframework.integration.message.GenericMessage; +import org.springframework.integration.message.Message; + +/** + * @author Mark Fisher + */ +public class DefaultFileNameGeneratorTests { + + @Test + public void testWithFileNamePropertyProvided() { + Message message = new GenericMessage("123", "testing"); + message.getHeader().setProperty(FileNameGenerator.FILENAME_PROPERTY_KEY, "foo.bar"); + FileNameGenerator generator = new DefaultFileNameGenerator(); + String filename = generator.generateFileName(message); + assertEquals("foo.bar", filename); + } + + @Test + public void testWithoutFileNamePropertyProvided() { + Message message = new GenericMessage("123", "testing"); + FileNameGenerator generator = new DefaultFileNameGenerator(); + String filename = generator.generateFileName(message); + assertTrue(filename.startsWith("123-")); + assertTrue(filename.endsWith(".msg")); + } + +}