This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 510dd6b73d7329d7f9971cc4ff49aaedd03145bb Author: Jan Bednář <m...@janbednar.eu> AuthorDate: Tue Jun 11 14:27:32 2019 +0200 CAMEL-13628: Karaf feature, Karaf itest, formatting --- .../component/file/watch/FileWatchConsumer.java | 12 ++++---- .../file/watch/SpringFileWatcherTest.java | 2 +- .../src/test/resources/log4j2.properties | 4 +-- .../karaf/features/src/main/resources/features.xml | 5 ++++ .../camel/itest/karaf/CamelFileWatchTest.java | 33 ++++++++++++++++++++++ 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java index 5b2b233..34bf7ac 100644 --- a/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java +++ b/components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java @@ -161,8 +161,8 @@ public class FileWatchConsumer extends DefaultConsumer { } return antPathMatcher.match( - getEndpoint().getAntInclude(), - PathUtils.normalizeToString(baseDirectory.relativize(fileEvent.getEventPath())) + getEndpoint().getAntInclude(), + PathUtils.normalizeToString(baseDirectory.relativize(fileEvent.getEventPath())) // match against relativized path ); } @@ -186,19 +186,19 @@ public class FileWatchConsumer extends DefaultConsumer { @Override public boolean isWatching() { - return isRunAllowed() && !isStoppingOrStopped() && !isSuspendingOrSuspended(); + return !isStoppingOrStopped() && !isSuspendingOrSuspended(); } @Override public void onException(Exception e) { - getExceptionHandler().handleException(e); + handleException(e); } } class PollRunnable implements Runnable { @Override public void run() { - while (isRunAllowed() && !isStoppingOrStopped() && !isSuspendingOrSuspended()) { + while (!isStoppingOrStopped() && !isSuspendingOrSuspended()) { FileEvent event; try { event = eventQueue.poll(1000, TimeUnit.MILLISECONDS); @@ -211,7 +211,7 @@ public class FileWatchConsumer extends DefaultConsumer { Exchange exchange = prepareExchange(event); getProcessor().process(exchange); } catch (Throwable t) { - getExceptionHandler().handleException(t); + handleException(t); } } } diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java index d870939..55d8b5f 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/SpringFileWatcherTest.java @@ -49,7 +49,7 @@ public class SpringFileWatcherTest extends CamelSpringTestSupport { Files.write(springTestFile.toPath(), "modification".getBytes(), StandardOpenOption.SYNC); Files.write(springTestFile.toPath(), "modification 2".getBytes(), StandardOpenOption.SYNC); MockEndpoint mock = getMockEndpoint("mock:springTest"); - mock.setExpectedCount(2); // one MODIFY event + mock.setExpectedCount(2); // two MODIFY events mock.setResultWaitTime(1000); mock.assertIsSatisfied(); diff --git a/components/camel-file-watch/src/test/resources/log4j2.properties b/components/camel-file-watch/src/test/resources/log4j2.properties index da384d1..4cadc83 100644 --- a/components/camel-file-watch/src/test/resources/log4j2.properties +++ b/components/camel-file-watch/src/test/resources/log4j2.properties @@ -23,7 +23,7 @@ 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 -logger.fileWatch.name=org.apache.camel.component.fileWatch -logger.fileWatch.level=DEBUG +#logger.fileWatch.name=org.apache.camel.component.file.watch +#logger.fileWatch.level=DEBUG rootLogger.level=INFO rootLogger.appenderRef.file.ref=file diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 7b11435..bcd39e1 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -965,6 +965,11 @@ <bundle dependency='true'>mvn:org.apache.camel/camel-fhir-api/${project.version}</bundle> <bundle>mvn:org.apache.camel/camel-fhir/${project.version}</bundle> </feature> + <feature name='camel-file-watch' version='${project.version}' start-level='50'> + <feature version='${project.version}'>camel-core</feature> + <bundle dependency='true'>wrap:mvn:io.methvin/directory-watcher/${directory-watcher-version}</bundle> + <bundle>mvn:org.apache.camel/camel-file-watch/${project.version}</bundle> + </feature> <feature name='camel-flatpack' version='${project.version}' start-level='50'> <feature version='${project.version}'>camel-core</feature> <bundle dependency='true'>mvn:net.sf.flatpack/flatpack/${flatpack-version}</bundle> diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelFileWatchTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelFileWatchTest.java new file mode 100644 index 0000000..806898e --- /dev/null +++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelFileWatchTest.java @@ -0,0 +1,33 @@ +/* + * 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 org.apache.camel.itest.karaf; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; + +@RunWith(PaxExam.class) +public class CamelFileWatchTest extends BaseKarafTest { + + public static final String COMPONENT = extractName(CamelFileWatchTest.class); + + @Test + public void test() throws Exception { + testComponent(COMPONENT); + } + +}