Author: norman
Date: Mon Jan 10 12:00:55 2011
New Revision: 1057161

URL: http://svn.apache.org/viewvc?rev=1057161&view=rev
Log:
Add SubscriptionManager tests for JCR and JPA

Added:
    
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
    
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPASubscriptionManagerTest.java

Added: 
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java?rev=1057161&view=auto
==============================================================================
--- 
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
 (added)
+++ 
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
 Mon Jan 10 12:00:55 2011
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.apache.james.mailbox.jcr;
+
+import java.io.File;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.james.mailbox.AbstractSubscriptionManagerTest;
+import org.apache.james.mailbox.SubscriptionManager;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.xml.sax.InputSource;
+
+public class JCRSubscriptionManagerTest extends 
AbstractSubscriptionManagerTest{
+    private static final String JACKRABBIT_HOME = "target/jackrabbit";
+    
+    public static final String META_DATA_DIRECTORY = "target/user-meta-data";
+
+    private static RepositoryImpl repository;
+    private static String user = "user";
+    private static String pass = "pass";
+    private static String workspace = null;
+    @BeforeClass
+    public static void before() throws RepositoryException {
+       
+        RepositoryConfig  config = RepositoryConfig.create(new 
InputSource(JCRMailboxManagerTest.class.getClassLoader().getResourceAsStream("test-repository.xml")),
 JACKRABBIT_HOME);
+        repository = RepositoryImpl.create(config);
+       
+
+        // Register imap cnd file
+        JCRUtils.registerCnd(repository, workspace, user, pass);
+    }
+    
+    @AfterClass
+    public static void after() {
+        if (repository != null) {
+            repository.shutdown();
+        }
+        new File(JACKRABBIT_HOME).delete();
+    }
+    
+    @Override
+    public SubscriptionManager createSubscriptionManager() {
+
+        new File(JACKRABBIT_HOME).delete();
+        MailboxSessionJCRRepository sessionRepos = new 
GlobalMailboxSessionJCRRepository(repository, workspace, user, pass);
+        JCRMailboxSessionMapperFactory mf = new 
JCRMailboxSessionMapperFactory(sessionRepos);
+        JCRSubscriptionManager sm = new JCRSubscriptionManager(mf);
+        return sm;
+    }
+
+}

Added: 
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPASubscriptionManagerTest.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPASubscriptionManagerTest.java?rev=1057161&view=auto
==============================================================================
--- 
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPASubscriptionManagerTest.java
 (added)
+++ 
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPASubscriptionManagerTest.java
 Mon Jan 10 12:00:55 2011
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.apache.james.mailbox.jpa;
+
+import java.util.HashMap;
+
+import org.apache.james.mailbox.AbstractSubscriptionManagerTest;
+import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.jpa.mail.model.JPAHeader;
+import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
+import org.apache.james.mailbox.jpa.mail.model.JPAProperty;
+import 
org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMailboxMembership;
+import org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMessage;
+import org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMailboxMembership;
+import org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMessage;
+import org.apache.james.mailbox.jpa.user.model.JPASubscription;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.junit.After;
+import org.junit.Before;
+
+public class JPASubscriptionManagerTest extends 
AbstractSubscriptionManagerTest{
+
+    private OpenJPAEntityManagerFactory entityManagerFactory;
+
+    @Before
+    public void setUp() {
+
+        HashMap<String, String> properties = new HashMap<String, String>();
+        properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
+        properties.put("openjpa.ConnectionURL", 
"jdbc:h2:mem:imap;DB_CLOSE_DELAY=-1");
+        properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
+        properties.put("openjpa.ConnectionFactoryProperties", 
"PrettyPrint=true, PrettyPrintLineLength=72");
+        properties.put("openjpa.jdbc.SynchronizeMappings", 
"buildSchema(ForeignKeys=true)");
+        properties.put("openjpa.MetaDataFactory", "jpa(Types=" +
+                JPAHeader.class.getName() + ";" +
+                JPAMailbox.class.getName() + ";" +
+                AbstractJPAMailboxMembership.class.getName() + ";" +
+                JPAMailboxMembership.class.getName() + ";" +
+                AbstractJPAMessage.class.getName() + ";" +
+                JPAMessage.class.getName() + ";" +
+                JPAProperty.class.getName() + ";" +
+                JPASubscription.class.getName() + ")");
+       
+        entityManagerFactory = 
OpenJPAPersistence.getEntityManagerFactory(properties);
+    }
+    
+    @Override
+    public SubscriptionManager createSubscriptionManager() {
+        JPAMailboxSessionMapperFactory mf = new 
JPAMailboxSessionMapperFactory(entityManagerFactory);
+        JPASubscriptionManager sm = new JPASubscriptionManager(mf);
+        
+        return sm;
+    }
+
+    @After
+    public void tearDown() {
+        entityManagerFactory.close();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to