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.notification;
19:
20: import org.apache.lenya.ac.Identifiable;
21: import org.apache.lenya.ac.User;
22: import org.apache.lenya.cms.observation.RepositoryEvent;
23: import org.apache.lenya.cms.observation.RepositoryEventFactory;
24: import org.apache.lenya.cms.repository.Session;
25: import org.apache.lenya.inbox.Inbox;
26:
27: /**
28: * Notification test.
29: */
30: public class NotificationTest extends AbstractNotificationTest {
31:
32: protected static final String SUBJECT = "hello";
33:
34: /**
35: * The test.
36: * @throws Exception
37: */
38: public void testNotification() throws Exception {
39:
40: login("lenya");
41:
42: Session session = getFactory().getSession();
43:
44: User lenya = getAccreditableManager().getUserManager().getUser(
45: "lenya");
46: User alice = getAccreditableManager().getUserManager().getUser(
47: "alice");
48:
49: Identifiable[] recipients = { alice };
50:
51: Message message = new Message(SUBJECT, new String[0], "body",
52: new String[0], lenya, recipients);
53: NotificationEventDescriptor descr = new NotificationEventDescriptor(
54: message);
55: RepositoryEvent event = RepositoryEventFactory.createEvent(
56: getManager(), session, getLogger(), descr);
57:
58: session.enqueueEvent(event);
59:
60: Inbox inbox = getInbox(alice);
61: cleanUp(inbox, SUBJECT);
62:
63: assertFalse(containsMessage(inbox, SUBJECT));
64: session.commit();
65: Thread.sleep(100);
66: assertTrue(containsMessage(inbox, SUBJECT));
67:
68: cleanUp(inbox, SUBJECT);
69:
70: }
71:
72: }
|