MAILET-115 CharsetFromSubjectMailHeader is no more needed

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ae9b5d91
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ae9b5d91
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ae9b5d91

Branch: refs/heads/master
Commit: ae9b5d91316f3800ea7192bc2c44aab94480238d
Parents: 9eebd2c
Author: Benoit Tellier <[email protected]>
Authored: Wed Jan 11 10:05:24 2017 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Wed Jan 11 10:05:24 2017 +0700

----------------------------------------------------------------------
 .../utils/CharsetFromSubjectMailHeader.java     | 65 ---------------
 .../utils/CharsetFromSubjectMailHeaderTest.java | 85 --------------------
 2 files changed, 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9b5d91/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeader.java
----------------------------------------------------------------------
diff --git 
a/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeader.java
 
b/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeader.java
deleted file mode 100644
index fa1825a..0000000
--- 
a/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeader.java
+++ /dev/null
@@ -1,65 +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.transport.mailets.utils;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
-public class CharsetFromSubjectMailHeader {
-
-
-    /**
-     * It attempts to determine the charset used to encode an "unstructured" 
RFC
-     * 822 header (like Subject). The encoding is specified in RFC 2047. If it
-     * cannot determine or the the text is not encoded then it returns null.
-     * <p/>
-     * Here is an example raw text: Subject:
-     * =?iso-8859-2?Q?leg=FAjabb_pr=F3ba_l=F5elemmel?=
-     *
-     * @param subject the raw (not decoded) value of the header. Null means 
that the
-     *                header was not present (in this case it always return 
null).
-     * @return the MIME charset name or null if no encoding applied
-     */
-    public Optional<String> parse(String subject) {
-        if (Strings.isNullOrEmpty(subject)) {
-            return Optional.absent();
-        }
-        int iEncodingPrefix = subject.indexOf("=?");
-        if (iEncodingPrefix == -1) {
-            return Optional.absent();
-        }
-        int iCharsetBegin = iEncodingPrefix + 2;
-        int iSecondQuestionMark = subject.indexOf('?', iCharsetBegin);
-        if (iSecondQuestionMark == -1) {
-            return Optional.absent();
-        }
-        if (iSecondQuestionMark == iCharsetBegin) {
-            return Optional.absent();
-        }
-        int iThirdQuestionMark = subject.indexOf('?', iSecondQuestionMark + 1);
-        if (iThirdQuestionMark == -1) {
-            return Optional.absent();
-        }
-        if (subject.indexOf("?=", iThirdQuestionMark + 1) == -1) {
-            return Optional.absent();
-        }
-        return Optional.of(subject.substring(iCharsetBegin, 
iSecondQuestionMark));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9b5d91/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeaderTest.java
----------------------------------------------------------------------
diff --git 
a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeaderTest.java
 
b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeaderTest.java
deleted file mode 100644
index e3e0177..0000000
--- 
a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/CharsetFromSubjectMailHeaderTest.java
+++ /dev/null
@@ -1,85 +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.transport.mailets.utils;
-
-import static org.assertj.guava.api.Assertions.assertThat;
-
-import org.junit.Test;
-
-import com.google.common.base.Optional;
-
-public class CharsetFromSubjectMailHeaderTest {
-
-    @Test
-    public void parseShouldReturnAbsentWhenRawTextIsNull() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse(null);
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void parseShouldReturnAbsentWhenRawTextIsEmpty() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void 
parseShouldReturnAbsentWhenRawTextDoesNotContainEncodingPrefix() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("iso-8859-2?Q?leg=FAjabb_pr=F3ba_l=F5elemmel?=");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void 
parseShouldReturnAbsentWhenRawTextDoesNotContainSecondQuestionMark() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("=?iso-8859-2");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void parseShouldReturnAbsentWhenRawTextDoesNotContainCharset() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("=??");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void 
parseShouldReturnAbsentWhenRawTextDoesNotContainThirdQuestionMark() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("=?iso-8859-2?");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void parseShouldReturnAbsentWhenRawTextDoesNotContainClosingTag() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("=?iso-8859-2?Q?leg=FAjabb_pr=F3ba_l=F5elemmel");
-
-        assertThat(charset).isAbsent();
-    }
-
-    @Test
-    public void parseShouldReturnCharsetWhenRawTextIsWellFormatted() {
-        Optional<String> charset = new 
CharsetFromSubjectMailHeader().parse("=?iso-8859-2?Q?leg=FAjabb_pr=F3ba_l=F5elemmel?=");
-
-        assertThat(charset).contains("iso-8859-2");
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to