This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new efef749 CAMEL-13474: Move dataformats out of camel-core. efef749 is described below commit efef74961a071c608e1496faad1740b376d6c650 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu May 2 08:06:59 2019 +0200 CAMEL-13474: Move dataformats out of camel-core. --- MIGRATION.md | 2 +- components/camel-zip-deflater/pom.xml | 28 ++++++++++++++++++++++ .../ZipDeflaterDataFormatFileDeleteTest.java | 19 +++++++++------ ...pDeflaterDataFormatFileUnmarshalDeleteTest.java | 11 +++++---- .../deflater}/ZipDeflaterDataFormatTest.java | 19 +++++++-------- .../src/test/resources/log4j2.properties | 28 ++++++++++++++++++++++ components/pom.xml | 2 +- core/camel-core/pom.xml | 4 ---- .../org/apache/camel/builder/DataFormatClause.java | 3 ++- .../camel/model/dataformat/GzipDataFormat.java | 2 +- .../model/dataformat/ZipDeflaterDataFormat.java | 6 +---- .../karaf/features/src/main/resources/features.xml | 5 +++- 12 files changed, 93 insertions(+), 36 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 424cbee..4e11297 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -170,7 +170,7 @@ The default JSon library with the JSon dataformat has changed from `XStream` to ### Zip and GZip DataFormat -The zip and gzip dataformat has been renamed to zipdeflater and gzipdeflater as they are for deflating using the zip/gzip compression; and not for working with zip/gzip files. Instead use camel-zipfile dataformat. Also these dataformats has been moved out of `camel-core` into `camel-zip-deflater` JAR. The XML and Java DSL has also been modified so you should migrate there too to use their new names. +The zip and gzip dataformat has been renamed to zipdeflater and gzipdeflater as they are for deflating using the zip/gzip compression; and not for working with zip/gzip files. Instead use camel-zipfile dataformat. Also these dataformats has been moved out of `camel-core` into `camel-zip-deflater` JAR. The XML and Java DSL has also been modified so you should migrate there too to use their new names. And if you use these data formats you need to add the `camel-zip-deflater` as dependency [...] ### Simple language diff --git a/components/camel-zip-deflater/pom.xml b/components/camel-zip-deflater/pom.xml index f563b24..25b6b64 100644 --- a/components/camel-zip-deflater/pom.xml +++ b/components/camel-zip-deflater/pom.xml @@ -41,5 +41,33 @@ <version>${project.version}</version> </dependency> + <!-- testing --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project> diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileDeleteTest.java b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileDeleteTest.java similarity index 79% rename from core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileDeleteTest.java rename to components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileDeleteTest.java index b651feb..1e78e96 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileDeleteTest.java +++ b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileDeleteTest.java @@ -14,16 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.impl; -import java.io.File; +package org.apache.camel.dataformat.deflater; -import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; +import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class ZipDeflaterDataFormatFileDeleteTest extends ContextTestSupport { +import java.io.File; + +public class ZipDeflaterDataFormatFileDeleteTest extends CamelTestSupport { @Override @Before @@ -34,18 +37,20 @@ public class ZipDeflaterDataFormatFileDeleteTest extends ContextTestSupport { @Test public void testZipFileDelete() throws Exception { + NotifyBuilder oneExchangeDone = new NotifyBuilder(context).whenDone(1).create(); + getMockEndpoint("mock:result").expectedMessageCount(1); template.sendBodyAndHeader("file:target/data/zip", "Hello World", Exchange.FILE_NAME, "hello.txt"); assertMockEndpointsSatisfied(); // wait till the exchange is done which means the file should then have been deleted - oneExchangeDone.matchesMockWaitTime(); + oneExchangeDone.matchesWaitTime(); File in = new File("target/data/zip/hello.txt"); - assertFalse("Should have been deleted " + in, in.exists()); + Assert.assertFalse("Should have been deleted " + in, in.exists()); File out = new File("target/data/zip/out/hello.txt.zip"); - assertTrue("Should have been created " + out, out.exists()); + Assert.assertTrue("Should have been created " + out, out.exists()); } @Override diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java similarity index 92% rename from core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java rename to components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java index e733b1f..5577cde 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java +++ b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatFileUnmarshalDeleteTest.java @@ -14,17 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.impl; -import java.io.File; +package org.apache.camel.dataformat.deflater; -import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Before; import org.junit.Test; -public class ZipDeflaterDataFormatFileUnmarshalDeleteTest extends ContextTestSupport { +import java.io.File; + +public class ZipDeflaterDataFormatFileUnmarshalDeleteTest extends CamelTestSupport { @Override @Before @@ -36,7 +37,7 @@ public class ZipDeflaterDataFormatFileUnmarshalDeleteTest extends ContextTestSup @Test public void testZipFileUnmarshalDelete() throws Exception { // there are 2 exchanges - NotifyBuilder event = event().whenDone(2).create(); + NotifyBuilder event = new NotifyBuilder(context).whenDone(2).create(); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); template.sendBodyAndHeader("file:target/data/zip", "Hello World", Exchange.FILE_NAME, "hello.txt"); diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatTest.java b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatTest.java similarity index 94% rename from core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatTest.java rename to components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatTest.java index c7a129b..ab9c6f8 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/ZipDeflaterDataFormatTest.java +++ b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/ZipDeflaterDataFormatTest.java @@ -14,29 +14,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.impl; +package org.apache.camel.dataformat.deflater; -import java.io.ByteArrayOutputStream; -import java.util.List; -import java.util.zip.Deflater; -import java.util.zip.Inflater; - -import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; import org.apache.camel.NoTypeConversionAvailableException; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.stream.InputStreamCache; -import org.apache.camel.dataformat.deflater.ZipDeflaterDataFormat; import org.apache.camel.spi.DataFormat; import org.apache.camel.support.DefaultExchange; +import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import java.io.ByteArrayOutputStream; +import java.util.List; +import java.util.zip.Deflater; +import java.util.zip.Inflater; + /** * Unit test of the zip data format. */ -public class ZipDeflaterDataFormatTest extends ContextTestSupport { +public class ZipDeflaterDataFormatTest extends CamelTestSupport { private static final String TEXT = "The Cow in Apple Time \n" + "by: Robert Frost \n\n" + "Something inspires the only cow of late\n" @@ -61,7 +60,7 @@ public class ZipDeflaterDataFormatTest extends ContextTestSupport { DataFormat dataFormat = new ZipDeflaterDataFormat(); try { - dataFormat.marshal(new DefaultExchange(new DefaultCamelContext()), new Object(), new ByteArrayOutputStream()); + dataFormat.marshal(new DefaultExchange(context), new Object(), new ByteArrayOutputStream()); fail("Should have thrown an exception"); } catch (NoTypeConversionAvailableException e) { // expected diff --git a/components/camel-zip-deflater/src/test/resources/log4j2.properties b/components/camel-zip-deflater/src/test/resources/log4j2.properties new file mode 100644 index 0000000..2bd574d --- /dev/null +++ b/components/camel-zip-deflater/src/test/resources/log4j2.properties @@ -0,0 +1,28 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/camel-zip-deflater-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type = Console +appender.out.name = out +appender.out.layout.type = PatternLayout +appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +rootLogger.level = INFO +rootLogger.appenderRef.file.ref = file diff --git a/components/pom.xml b/components/pom.xml index 52c6a19..487cd02 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -57,7 +57,6 @@ <module>camel-vm</module> <module>camel-xpath</module> <module>camel-xslt</module> - <module>camel-zip-deflater</module> <!-- we want to test these modules first to catch any errors early as possible --> <module>camel-test</module> @@ -334,6 +333,7 @@ <module>camel-xstream</module> <module>camel-yammer</module> <module>camel-zendesk</module> + <module>camel-zip-deflater</module> <module>camel-zipfile</module> <module>camel-zipkin</module> <module>camel-zookeeper</module> diff --git a/core/camel-core/pom.xml b/core/camel-core/pom.xml index ff05bb9..5515347 100644 --- a/core/camel-core/pom.xml +++ b/core/camel-core/pom.xml @@ -185,10 +185,6 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-xslt</artifactId> </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-zip-deflater</artifactId> - </dependency> <!-- required dependencies by camel-core --> <dependency> diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java b/core/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java index e143b7f..2da4dea 100644 --- a/core/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java +++ b/core/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java @@ -1202,7 +1202,8 @@ public class DataFormatClause<T extends ProcessorDefinition<?>> { * Uses the ZIP deflater data format */ public T zipDefalter(int compressionLevel) { - ZipDeflaterDataFormat zdf = new ZipDeflaterDataFormat(compressionLevel); + ZipDeflaterDataFormat zdf = new ZipDeflaterDataFormat(); + zdf.setCompressionLevel(compressionLevel); return dataFormat(zdf); } diff --git a/core/camel-core/src/main/java/org/apache/camel/model/dataformat/GzipDataFormat.java b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/GzipDataFormat.java index a8b2693..05c619b 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/dataformat/GzipDataFormat.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/GzipDataFormat.java @@ -29,7 +29,7 @@ import org.apache.camel.spi.Metadata; public class GzipDataFormat extends DataFormatDefinition { public GzipDataFormat() { - super("gzip-deflater"); + super("gzipdeflater"); } } diff --git a/core/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java index bff4337..8b426fc 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/dataformat/ZipDeflaterDataFormat.java @@ -35,11 +35,7 @@ public class ZipDeflaterDataFormat extends DataFormatDefinition { private Integer compressionLevel; public ZipDeflaterDataFormat() { - super("zip-deflater"); - } - - public ZipDeflaterDataFormat(int compressionLevel) { - this.compressionLevel = compressionLevel; + super("zipdeflater"); } public Integer getCompressionLevel() { diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 3fd657d..8dc791f 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -79,7 +79,6 @@ <bundle>mvn:org.apache.camel/camel-vm/${project.version}</bundle> <bundle>mvn:org.apache.camel/camel-xpath/${project.version}</bundle> <bundle>mvn:org.apache.camel/camel-xslt/${project.version}</bundle> - <bundle>mvn:org.apache.camel/camel-zip-deflater/${project.version}</bundle> <conditional> <condition>shell</condition> <bundle>mvn:org.apache.camel/camel-commands-core/${project.version}</bundle> @@ -2646,6 +2645,10 @@ <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson2-version}</bundle> <bundle>mvn:org.apache.camel/camel-zendesk/${project.version}</bundle> </feature> + <feature name='camel-zip-deflater' version='${project.version}' start-level='50'> + <feature version='${project.version}'>camel-core</feature> + <bundle>mvn:org.apache.camel/camel-zip-deflater/${project.version}</bundle> + </feature> <feature name='camel-zipfile' version='${project.version}' start-level='50'> <feature version='${project.version}'>camel-core</feature> <bundle>mvn:org.apache.camel/camel-zipfile/${project.version}</bundle>