Code example for Subject

0
    private NormalizedMessage message;
     
    private Subject subject;
     
    public void setUp() throws Exception { 
        subject = new Subject();
        message = new MessageUtil.NormalizedMessageImpl();
        message.setContent(new StringSource("<doc>s1<doc>"));
        message.addAttachment("a", new DataHandler(createDataSource("s2")));
        message.setProperty("p", "s3");
        message.setSecuritySubject(subject);
    } 
 
    public void tearDown() throws Exception { 
    } 
 
    public void testCopyContent() throws Exception { 
        MessageTransformer copier = new CopyTransformer(false, true, false, false);
        NormalizedMessage copy = copier.transform(null, message);
        String content = new SourceTransformer().toString(copy.getContent());
        assertEquals("wrong content", "<doc>s1<doc>", content);