You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2007/02/22 14:46:23 UTC
svn commit: r510511 - in /james/mime4j/trunk/src: main/java/org/mime4j/
main/java/org/mime4j/message/ main/java/org/mime4j/util/
test/java/org/mime4j/message/
Author: norman
Date: Thu Feb 22 05:46:22 2007
New Revision: 510511
URL: http://svn.apache.org/viewvc?view=rev&rev=510511
Log:
Fix tabs
Add missing license headers
Added:
james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java (with props)
Modified:
james/mime4j/trunk/src/main/java/org/mime4j/BodyDescriptor.java
james/mime4j/trunk/src/main/java/org/mime4j/message/Header.java
james/mime4j/trunk/src/main/java/org/mime4j/message/Message.java
james/mime4j/trunk/src/main/java/org/mime4j/message/Multipart.java
james/mime4j/trunk/src/main/java/org/mime4j/util/PartialInputStream.java
james/mime4j/trunk/src/main/java/org/mime4j/util/PositionInputStream.java
james/mime4j/trunk/src/main/java/org/mime4j/util/SimpleTempStorage.java
james/mime4j/trunk/src/main/java/org/mime4j/util/TempFile.java
james/mime4j/trunk/src/main/java/org/mime4j/util/TempPath.java
james/mime4j/trunk/src/main/java/org/mime4j/util/TempStorage.java
james/mime4j/trunk/src/test/java/org/mime4j/message/MessageParserTest.java
james/mime4j/trunk/src/test/java/org/mime4j/message/MessageTest.java
Modified: james/mime4j/trunk/src/main/java/org/mime4j/BodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/BodyDescriptor.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/BodyDescriptor.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/BodyDescriptor.java Thu Feb 22 05:46:22 2007
@@ -35,7 +35,6 @@
public class BodyDescriptor {
private static Log log = LogFactory.getLog(BodyDescriptor.class);
- private BodyDescriptor parent = null;
private String mimeType = "text/plain";
private String boundary = null;
private String charset = "us-ascii";
@@ -319,11 +318,7 @@
return result;
}
- /**
- * Ret
- * @param mimeType
- * @return
- */
+
public boolean isMimeType(String mimeType) {
return this.mimeType.equals(mimeType.toLowerCase());
}
Modified: james/mime4j/trunk/src/main/java/org/mime4j/message/Header.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/message/Header.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/message/Header.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/message/Header.java Thu Feb 22 05:46:22 2007
@@ -118,8 +118,8 @@
}
/**
- * Return Header Object as String representation. Each headerline is
- * seperated by "\r\n"
+ * Return Header Object as String representation. Each headerline is
+ * seperated by "\r\n"
*
* @return headers
*/
@@ -129,7 +129,9 @@
str.append(it.next().toString());
str.append("\r\n");
}
- str.append("\r\n");
+
+ // TODO: Check where the CLRFCLRF is handled
+ // str.append("\r\n");
return str.toString();
}
Modified: james/mime4j/trunk/src/main/java/org/mime4j/message/Message.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/message/Message.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/message/Message.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/message/Message.java Thu Feb 22 05:46:22 2007
@@ -83,17 +83,17 @@
* @see org.mime4j.message.Entity#writeTo(java.io.OutputStream)
*/
public void writeTo(OutputStream out) throws IOException {
-
- out.write(getHeader().toString().getBytes());
- out.write("\r\n".getBytes());
- Body body = getBody();
-
- if (body instanceof Multipart) {
- Multipart mp = (Multipart) body;
- mp.writeTo(out);
- } else {
- body.writeTo(out);
- }
+
+ out.write(getHeader().toString().getBytes());
+ out.write("\r\n".getBytes());
+ Body body = getBody();
+
+ if (body instanceof Multipart) {
+ Multipart mp = (Multipart) body;
+ mp.writeTo(out);
+ } else {
+ body.writeTo(out);
+ }
}
Modified: james/mime4j/trunk/src/main/java/org/mime4j/message/Multipart.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/message/Multipart.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/message/Multipart.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/message/Multipart.java Thu Feb 22 05:46:22 2007
@@ -163,24 +163,25 @@
* @see org.mime4j.message.Body#writeTo(java.io.OutputStream)
*/
public void writeTo(OutputStream out) throws IOException {
- String boundary = getBoundary();
- List bodyParts = getBodyParts();
-
- out.write((getPreamble() + "\r\n").getBytes());
-
- for (int i = 0; i < bodyParts.size();i++) {
- out.write((boundary + "\r\n").getBytes());
- ((BodyPart)bodyParts.get(i)).writeTo(out);
- }
-
- out.write((getEpilogue() + "\r\n").getBytes());
- out.write((boundary + "--" + "\r\n").getBytes());
+ String boundary = getBoundary();
+ List bodyParts = getBodyParts();
+
+ out.write((getPreamble() + "\r\n").getBytes());
+
+ for (int i = 0; i < bodyParts.size(); i++) {
+ out.write((boundary + "\r\n").getBytes());
+ ((BodyPart) bodyParts.get(i)).writeTo(out);
+ }
+
+ out.write((getEpilogue() + "\r\n").getBytes());
+ out.write((boundary + "--" + "\r\n").getBytes());
}
-
+
private String getBoundary() {
- Entity e = getParent();
- ContentTypeField cField = (ContentTypeField) e.getHeader().getField(Field.CONTENT_TYPE);
- return cField.getBoundary();
+ Entity e = getParent();
+ ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
+ Field.CONTENT_TYPE);
+ return cField.getBoundary();
}
}
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/PartialInputStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/PartialInputStream.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/PartialInputStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/PartialInputStream.java Thu Feb 22 05:46:22 2007
@@ -1,3 +1,23 @@
+/****************************************************************
+ * 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.mime4j.util;
import java.io.InputStream;
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/PositionInputStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/PositionInputStream.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/PositionInputStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/PositionInputStream.java Thu Feb 22 05:46:22 2007
@@ -1,3 +1,23 @@
+/****************************************************************
+ * 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.mime4j.util;
import java.io.InputStream;
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/SimpleTempStorage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/SimpleTempStorage.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/SimpleTempStorage.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/SimpleTempStorage.java Thu Feb 22 05:46:22 2007
@@ -34,8 +34,6 @@
/**
*
- *
- *
* @version $Id: SimpleTempStorage.java,v 1.2 2004/10/02 12:41:11 ntherning Exp $
*/
public class SimpleTempStorage extends TempStorage {
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/TempFile.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/TempFile.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/TempFile.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/TempFile.java Thu Feb 22 05:46:22 2007
@@ -24,9 +24,6 @@
import java.io.OutputStream;
/**
- *
- *
- *
* @version $Id: TempFile.java,v 1.3 2004/10/02 12:41:11 ntherning Exp $
*/
public interface TempFile {
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/TempPath.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/TempPath.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/TempPath.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/TempPath.java Thu Feb 22 05:46:22 2007
@@ -23,8 +23,6 @@
/**
*
- *
- *
* @version $Id: TempPath.java,v 1.2 2004/10/02 12:41:11 ntherning Exp $
*/
public interface TempPath {
Modified: james/mime4j/trunk/src/main/java/org/mime4j/util/TempStorage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/TempStorage.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/main/java/org/mime4j/util/TempStorage.java (original)
+++ james/mime4j/trunk/src/main/java/org/mime4j/util/TempStorage.java Thu Feb 22 05:46:22 2007
@@ -24,8 +24,6 @@
/**
*
- *
- *
* @version $Id: TempStorage.java,v 1.2 2004/10/02 12:41:11 ntherning Exp $
*/
public abstract class TempStorage {
Added: james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java?view=auto&rev=510511
==============================================================================
--- james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java (added)
+++ james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java Thu Feb 22 05:46:22 2007
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.mime4j.message;
+
+import org.mime4j.field.Field;
+
+import junit.framework.TestCase;
+
+public class HeaderTest extends TestCase {
+
+ public static final String SUBJECT = "Subject: test";
+
+ public static final String TO = "To: anyuser <an...@user>";
+
+ public void testHeader() {
+ Header header = new Header();
+ header.addField(Field.parse(SUBJECT));
+ header.addField(Field.parse(TO));
+
+ assertNotNull("Subject found", header.getField("Subject"));
+ assertNotNull("To found", header.getField("To"));
+
+ assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
+ .toString());
+ }
+}
Propchange: james/mime4j/trunk/src/test/java/org/mime4j/message/HeaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: james/mime4j/trunk/src/test/java/org/mime4j/message/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/mime4j/message/MessageParserTest.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/test/java/org/mime4j/message/MessageParserTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/mime4j/message/MessageParserTest.java Thu Feb 22 05:46:22 2007
@@ -33,7 +33,6 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.io.CopyUtils;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.BasicConfigurator;
import org.mime4j.EOLConvertingInputStream;
@@ -177,7 +176,7 @@
assertEquals(perlFile.getName(), s1, s2);
} else {
OutputStream out = new FileOutputStream(mime4jFile);
- CopyUtils.copy(((BinaryBody) b).getInputStream(), out);
+ IOUtils.copy(((BinaryBody) b).getInputStream(), out);
assertEqualsBinary(perlFile.getName(), expected, ((BinaryBody) b).getInputStream());
}
Modified: james/mime4j/trunk/src/test/java/org/mime4j/message/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/mime4j/message/MessageTest.java?view=diff&rev=510511&r1=510510&r2=510511
==============================================================================
--- james/mime4j/trunk/src/test/java/org/mime4j/message/MessageTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/mime4j/message/MessageTest.java Thu Feb 22 05:46:22 2007
@@ -126,59 +126,62 @@
}
public void testWriteTo() throws IOException {
- byte[] inputByte = getRawMessageAsByteArray();
+ byte[] inputByte = getRawMessageAsByteArray();
- Message m = new Message(new ByteArrayInputStream(inputByte));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- m.writeTo(out);
-
- InputStream output = new ByteArrayInputStream(out.toByteArray());
-
- int b = -1;
- int i = 0;
- while ((b = output.read() ) != -1) {
- assertEquals("same byte", b, inputByte[i]);
- i++;
- }
+ Message m = new Message(new ByteArrayInputStream(inputByte));
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ m.writeTo(out);
+
+ InputStream output = new ByteArrayInputStream(out.toByteArray());
+
+ int b = -1;
+ int i = 0;
+ while ((b = output.read()) != -1) {
+ assertEquals("same byte", b, inputByte[i]);
+ i++;
+ }
}
-
+
public void testAddHeaderWriteTo() throws IOException {
- String headerName = "testheader";
- String headerValue = "testvalue";
- String testheader = headerName + ": " + headerValue;
-
- byte[] inputByte = getRawMessageAsByteArray();
-
- Message m = new Message(new ByteArrayInputStream(inputByte));
- m.getHeader().addField(Field.parse(testheader));
-
- assertEquals("header added",m.getHeader().getField(headerName).getBody(),headerValue);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- m.writeTo(out);
- List lines = IOUtils.readLines((new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())))));
-
- assertTrue("header added",lines.contains(testheader));
+ String headerName = "testheader";
+ String headerValue = "testvalue";
+ String testheader = headerName + ": " + headerValue;
+
+ byte[] inputByte = getRawMessageAsByteArray();
+
+ Message m = new Message(new ByteArrayInputStream(inputByte));
+ m.getHeader().addField(Field.parse(testheader));
+
+ assertEquals("header added", m.getHeader().getField(headerName)
+ .getBody(), headerValue);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ m.writeTo(out);
+ List lines = IOUtils.readLines((new BufferedReader(
+ new InputStreamReader(new ByteArrayInputStream(out
+ .toByteArray())))));
+
+ assertTrue("header added", lines.contains(testheader));
}
-
+
private byte[] getRawMessageAsByteArray() {
- StringBuffer header = new StringBuffer();
- StringBuffer body = new StringBuffer();
- StringBuffer complete = new StringBuffer();
-
- header.append("Date: Wed, 21 Feb 2007 11:09:27 +0100\r\n");
- header.append("From: Test <te...@test>\r\n");
- header.append("To: Norman Maurer <nm...@byteaction.de>\r\n");
- header.append("Subject: Testmail\r\n");
- header.append("Content-Type: text/plain; charset=ISO-8859-15; format=flowed\r\n");
- header.append("Content-Transfer-Encoding: 8bit\r\n");
- body.append("\r\n");
- body.append("testbody\r\n");
- complete.append(header);
- complete.append(body);
-
- return complete.toString().getBytes();
+ StringBuffer header = new StringBuffer();
+ StringBuffer body = new StringBuffer();
+ StringBuffer complete = new StringBuffer();
+
+ header.append("Date: Wed, 21 Feb 2007 11:09:27 +0100\r\n");
+ header.append("From: Test <te...@test>\r\n");
+ header.append("To: Norman Maurer <nm...@byteaction.de>\r\n");
+ header.append("Subject: Testmail\r\n");
+ header
+ .append("Content-Type: text/plain; charset=ISO-8859-15; format=flowed\r\n");
+ header.append("Content-Transfer-Encoding: 8bit\r\n\r\n");
+ body.append("testbody\r\n");
+ complete.append(header);
+ complete.append(body);
+
+ return complete.toString().getBytes();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org