01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.lenya.inbox;
19:
20: import org.apache.lenya.ac.Identifiable;
21: import org.apache.lenya.ac.User;
22: import org.apache.lenya.inbox.xml.XmlSourceInbox;
23: import org.apache.lenya.notification.AbstractNotificationTest;
24: import org.apache.lenya.notification.Message;
25:
26: /**
27: * Inbox test.
28: */
29: public class InboxTest extends AbstractNotificationTest {
30:
31: protected static final String SUBJECT = "hello";
32:
33: /**
34: * The test.
35: * @throws Exception if an error occurs.
36: */
37: public void testInbox() throws Exception {
38:
39: User lenya = getAccreditableManager().getUserManager().getUser(
40: "lenya");
41: Inbox inbox = getInbox(lenya);
42:
43: cleanUp(inbox, SUBJECT);
44: assertFalse(containsMessage(inbox, SUBJECT));
45:
46: Identifiable[] recipients = { lenya };
47:
48: Message message = new Message(SUBJECT, new String[0], "body",
49: new String[0], lenya, recipients);
50: InboxMessage inboxMessage = inbox.add(message);
51:
52: assertEquals(inboxMessage.getMessage().getSubject(), SUBJECT);
53:
54: assertFalse(inboxMessage.isMarkedAsRead());
55: inboxMessage.markAsRead(true);
56: assertTrue(inboxMessage.isMarkedAsRead());
57:
58: XmlSourceInbox xmlInbox = new XmlSourceInbox(getManager(),
59: lenya);
60: assertTrue(containsMessage(xmlInbox, SUBJECT));
61:
62: InboxMessage xmlMessage = getMessage(xmlInbox, SUBJECT);
63: assertTrue(xmlMessage.isMarkedAsRead());
64:
65: cleanUp(inbox, SUBJECT);
66:
67: }
68:
69: }
|