1 package org.apache.archiva.redback.keys.jdo;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.redback.keys.KeyManager;
23 import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
24 import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
25 import org.jpox.SchemaTool;
26 import org.junit.Before;
28 import javax.inject.Inject;
29 import javax.inject.Named;
30 import javax.jdo.PersistenceManager;
31 import javax.jdo.PersistenceManagerFactory;
34 import java.util.Properties;
39 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
42 public class JdoKeyManagerTest
43 extends KeyManagerTestCase
47 @Named(value = "jdoFactory#users")
48 DefaultConfigurableJdoFactory jdoFactory;
50 @Inject @Named(value = "keyManager#jdo")
51 KeyManager keyManager;
61 assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
63 jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); //$NON-NLS-1$
65 jdoFactory.setDriverName( "org.hsqldb.jdbcDriver" ); //$NON-NLS-1$
67 jdoFactory.setUrl( "jdbc:hsqldb:mem:" + getName() ); //$NON-NLS-1$
69 jdoFactory.setUserName( "sa" ); //$NON-NLS-1$
71 jdoFactory.setPassword( "" ); //$NON-NLS-1$
73 jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$
75 jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$
77 jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
79 jdoFactory.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" ); //$NON-NLS-1$ //$NON-NLS-2$
81 Properties properties = jdoFactory.getProperties();
83 for ( Map.Entry<Object,Object> entry : properties.entrySet() )
85 System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
88 SchemaTool.createSchemaTables( new URL[] { getClass()
89 .getResource( "/org/codehaus/plexus/redback/keys/jdo/package.jdo" ) }, new URL[] {}, null, false, null ); //$NON-NLS-1$
91 PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
95 PersistenceManager pm = pmf.getPersistenceManager();
98 keyManager.eraseDatabase();
99 setKeyManager( keyManager );