コード例 #1
0
 @After
 public void tearDown() {
   MailboxSession session =
       mailboxManager.createSystemSession("test", LoggerFactory.getLogger("Test"));
   try {
     mailboxManager.deleteEverything(session);
   } catch (MailboxException e) {
     e.printStackTrace();
   }
   session.close();
 }
コード例 #2
0
  @Before
  public void setUp() throws MailboxException {

    HashMap<String, String> properties = new HashMap<String, String>();
    properties.put("openjpa.ConnectionDriverName", org.h2.Driver.class.getName());
    properties.put(
        "openjpa.ConnectionURL", "jdbc:h2:mem:mailboxintegrationstress;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="
            + JPAMailbox.class.getName()
            + ";"
            + AbstractJPAMailboxMessage.class.getName()
            + ";"
            + JPAMailboxMessage.class.getName()
            + ";"
            + JPAProperty.class.getName()
            + ";"
            + JPAUserFlag.class.getName()
            + ";"
            + JPASubscription.class.getName()
            + ")");
    properties.put("openjpa.LockTimeout", locktimeout + "");

    entityManagerFactory = OpenJPAPersistence.getEntityManagerFactory(properties);
    JVMMailboxPathLocker locker = new JVMMailboxPathLocker();
    JPAMailboxSessionMapperFactory mf =
        new JPAMailboxSessionMapperFactory(
            entityManagerFactory,
            new JPAUidProvider(locker, entityManagerFactory),
            new JPAModSeqProvider(locker, entityManagerFactory));

    MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
    GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();

    mailboxManager = new OpenJPAMailboxManager(mf, null, aclResolver, groupMembershipResolver);
    mailboxManager.init();

    // Set the lock timeout via SQL because of a bug in openJPA
    // https://issues.apache.org/jira/browse/OPENJPA-1656
    setH2LockTimeout();
  }