Package org.apache.james.mime4j.message

Examples of org.apache.james.mime4j.message.Entity


    public void setMode(final HttpMultipartMode mode) {
        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
View Full Code Here


        }
        return charset;
    }
   
    protected String getBoundary() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        return cField.getBoundary();
    }
View Full Code Here

    public void setMode(final HttpMultipartMode mode) {
        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                FieldName.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
View Full Code Here

        }
        return charset;
    }
   
    protected String getBoundary() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                FieldName.CONTENT_TYPE);
        return cField.getBoundary();
    }
View Full Code Here

import junit.framework.TestCase;

public class EntityTest extends TestCase {

    public void testSetBody() throws Exception {
        Entity entity = new BodyPart();
        assertNull(entity.getBody());

        Body body = new BodyFactory().textBody("test");
        assertNull(body.getParent());

        entity.setBody(body);
        assertSame(body, entity.getBody());
        assertSame(entity, body.getParent());
    }
View Full Code Here

        assertSame(body, entity.getBody());
        assertSame(entity, body.getParent());
    }

    public void testSetBodyTwice() throws Exception {
        Entity entity = new BodyPart();

        Body b1 = new BodyFactory().textBody("foo");
        Body b2 = new BodyFactory().textBody("bar");

        entity.setBody(b1);
        try {
            entity.setBody(b2);
            fail();
        } catch (IllegalStateException expected) {
        }
    }
View Full Code Here

        } catch (IllegalStateException expected) {
        }
    }

    public void testRemoveBody() throws Exception {
        Entity entity = new BodyPart();
        Body body = new BodyFactory().textBody("test");
        entity.setBody(body);

        Body removed = entity.removeBody();
        assertSame(body, removed);

        assertNull(entity.getBody());
        assertNull(removed.getParent());
    }
View Full Code Here

        assertNull(entity.getBody());
        assertNull(removed.getParent());
    }

    public void testGetDispositionType() throws Exception {
        Entity entity = new BodyPart();

        assertNull(entity.getDispositionType());

        Header header = new Header();
        header.setField(AbstractField.parse("Content-Disposition: inline"));
        entity.setHeader(header);

        assertEquals("inline", entity.getDispositionType());
    }
View Full Code Here

        assertEquals("inline", entity.getDispositionType());
    }

    public void testSetContentDispositionType() throws Exception {
        Entity entity = new BodyPart();

        entity.setContentDisposition("attachment");

        assertEquals("attachment", entity.getHeader().getField(
                "Content-Disposition").getBody());
    }
View Full Code Here

        assertEquals("attachment", entity.getHeader().getField(
                "Content-Disposition").getBody());
    }

    public void testSetContentDispositionTypeFilename() throws Exception {
        Entity entity = new BodyPart();

        entity.setContentDisposition("attachment", "some file.dat");

        assertEquals("attachment; filename=\"some file.dat\"", entity
                .getHeader().getField("Content-Disposition").getBody());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.message.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.