Repository: james-mime4j Updated Branches: refs/heads/master cfd093ec6 -> 961263015
JSIEVE-73 correcting folder name Compilation under Eclipse is broken : ./james-utils/src/test/java/org.apache.james.mime4j.utils.search/MessageMatcherTest.java instead of ./james-utils/src/test/java/org/apache/james/mime4j/utils/search/MessageMatcherTest.java The maven tests pass, but compilation within an Eclipse workspace does not. Project: http://git-wip-us.apache.org/repos/asf/james-mime4j/repo Commit: http://git-wip-us.apache.org/repos/asf/james-mime4j/commit/96126301 Tree: http://git-wip-us.apache.org/repos/asf/james-mime4j/tree/96126301 Diff: http://git-wip-us.apache.org/repos/asf/james-mime4j/diff/96126301 Branch: refs/heads/master Commit: 96126301575fff168df0403588833daa42192c50 Parents: cfd093e Author: benwa <[email protected]> Authored: Mon May 23 09:46:04 2016 +0700 Committer: benwa <[email protected]> Committed: Mon May 23 09:46:16 2016 +0700 ---------------------------------------------------------------------- .../MessageMatcherTest.java | 163 ------------------- .../mime4j/utils/search/MessageMatcherTest.java | 163 +++++++++++++++++++ 2 files changed, 163 insertions(+), 163 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/96126301/james-utils/src/test/java/org.apache.james.mime4j.utils.search/MessageMatcherTest.java ---------------------------------------------------------------------- diff --git a/james-utils/src/test/java/org.apache.james.mime4j.utils.search/MessageMatcherTest.java b/james-utils/src/test/java/org.apache.james.mime4j.utils.search/MessageMatcherTest.java deleted file mode 100644 index 56e23df..0000000 --- a/james-utils/src/test/java/org.apache.james.mime4j.utils.search/MessageMatcherTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************** - * 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.james.mime4j.utils.search; - -import com.google.common.collect.Lists; -import com.sun.org.apache.bcel.internal.util.ClassLoader; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MessageMatcherTest { - - @Test - public void isFoundInShouldBeAbleToLocateTextFragments() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) - .caseInsensitive(true) - .includeHeaders(false) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void isFoundInShouldReturnFalseWhenTextIsAbsent() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("Not in the mail")) - .caseInsensitive(true) - .includeHeaders(false) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); - } - - @Test - public void isFoundInShouldReturnFalseWhenSearchingHeaderTextOutsideHeaders() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) - .caseInsensitive(true) - .includeHeaders(false) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); - } - - @Test - public void isFoundInShouldReturnFalseWhenSearchingTextLocatedInOtherMimeParts() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) - .caseInsensitive(true) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("invalid")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); - } - - @Test - public void isFoundInShouldReturnTrueWhenSearchingTextLocatedInSpecifiedMimePart() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) - .caseInsensitive(true) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("text/plain")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void isFoundInShouldBeAbleToRecognizedMimeTypes() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("")) - .caseInsensitive(true) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("text/plain")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void isFoundInShouldNotBeAffectedByInvalidMimeTypes() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) - .caseInsensitive(true) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("text/plain", "invalid")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void caseSensitivenessShouldBeTakenIntoAccountWhenTurnedOn() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as aTtAchment !")) - .caseInsensitive(true) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("text/plain", "invalid")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void caseSensitivenessShouldBeIgnoredWhenTurnedOff() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("as aTtAchment !")) - .caseInsensitive(false) - .includeHeaders(false) - .contentTypes(Lists.newArrayList("text/plain", "invalid")) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); - } - - @Test - public void headerShouldBeMatchedWhenHeaderMatchingIsTurnedOn() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) - .caseInsensitive(true) - .includeHeaders(true) - .contentTypes(Lists.<String>newArrayList()) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void headerShouldBeMatchedWhenIgnoringMime() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) - .ignoringMime(true) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void isFoundInIgnoringMimeShouldIgnoreMimeStructure() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("ail signature )\n\n--------------0004")) - .ignoringMime(true) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); - } - - @Test - public void isFoundInIgnoringMimeShouldReturnFalseOnNonContainedText() throws Exception { - MessageMatcher messageMatcher = MessageMatcher.builder() - .searchContents(Lists.<CharSequence>newArrayList("invalid")) - .ignoringMime(true) - .build(); - assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); - } - -} http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/96126301/james-utils/src/test/java/org/apache/james/mime4j/utils/search/MessageMatcherTest.java ---------------------------------------------------------------------- diff --git a/james-utils/src/test/java/org/apache/james/mime4j/utils/search/MessageMatcherTest.java b/james-utils/src/test/java/org/apache/james/mime4j/utils/search/MessageMatcherTest.java new file mode 100644 index 0000000..56e23df --- /dev/null +++ b/james-utils/src/test/java/org/apache/james/mime4j/utils/search/MessageMatcherTest.java @@ -0,0 +1,163 @@ +/**************************************************************** + * 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.james.mime4j.utils.search; + +import com.google.common.collect.Lists; +import com.sun.org.apache.bcel.internal.util.ClassLoader; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MessageMatcherTest { + + @Test + public void isFoundInShouldBeAbleToLocateTextFragments() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) + .caseInsensitive(true) + .includeHeaders(false) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void isFoundInShouldReturnFalseWhenTextIsAbsent() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("Not in the mail")) + .caseInsensitive(true) + .includeHeaders(false) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); + } + + @Test + public void isFoundInShouldReturnFalseWhenSearchingHeaderTextOutsideHeaders() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) + .caseInsensitive(true) + .includeHeaders(false) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); + } + + @Test + public void isFoundInShouldReturnFalseWhenSearchingTextLocatedInOtherMimeParts() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) + .caseInsensitive(true) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("invalid")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); + } + + @Test + public void isFoundInShouldReturnTrueWhenSearchingTextLocatedInSpecifiedMimePart() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) + .caseInsensitive(true) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("text/plain")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void isFoundInShouldBeAbleToRecognizedMimeTypes() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("")) + .caseInsensitive(true) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("text/plain")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void isFoundInShouldNotBeAffectedByInvalidMimeTypes() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as attachment !")) + .caseInsensitive(true) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("text/plain", "invalid")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void caseSensitivenessShouldBeTakenIntoAccountWhenTurnedOn() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as aTtAchment !")) + .caseInsensitive(true) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("text/plain", "invalid")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void caseSensitivenessShouldBeIgnoredWhenTurnedOff() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("as aTtAchment !")) + .caseInsensitive(false) + .includeHeaders(false) + .contentTypes(Lists.newArrayList("text/plain", "invalid")) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); + } + + @Test + public void headerShouldBeMatchedWhenHeaderMatchingIsTurnedOn() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) + .caseInsensitive(true) + .includeHeaders(true) + .contentTypes(Lists.<String>newArrayList()) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void headerShouldBeMatchedWhenIgnoringMime() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("message/rfc822")) + .ignoringMime(true) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void isFoundInIgnoringMimeShouldIgnoreMimeStructure() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("ail signature )\n\n--------------0004")) + .ignoringMime(true) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isTrue(); + } + + @Test + public void isFoundInIgnoringMimeShouldReturnFalseOnNonContainedText() throws Exception { + MessageMatcher messageMatcher = MessageMatcher.builder() + .searchContents(Lists.<CharSequence>newArrayList("invalid")) + .ignoringMime(true) + .build(); + assertThat(messageMatcher.messageMatches(ClassLoader.getSystemResourceAsStream("sampleMail.msg"))).isFalse(); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
