~pbeaman/akiban-persistit/fix-1157809-aioobe-on-append-key-segment

« back to all changes in this revision

Viewing changes to src/test/java/com/persistit/unit/SpringFrameworkConfigurationTest.java

merge pbeaman: Adds infrastructure needed to support Spring Framework.

https://code.launchpad.net/~pbeaman/akiban-persistit/support-spring-framework/+merge/135208

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright © 2011-2012 Akiban Technologies, Inc.  All rights reserved.
 
3
 * 
 
4
 * This program and the accompanying materials are made available
 
5
 * under the terms of the Eclipse Public License v1.0 which
 
6
 * accompanies this distribution, and is available at
 
7
 * http://www.eclipse.org/legal/epl-v10.html
 
8
 * 
 
9
 * This program may also be available under different license terms.
 
10
 * For more information, see www.akiban.com or contact licensing@akiban.com.
 
11
 * 
 
12
 * Contributors:
 
13
 * Akiban Technologies, Inc.
 
14
 */
 
15
 
 
16
package com.persistit.unit;
 
17
 
 
18
import static org.junit.Assert.assertTrue;
 
19
 
 
20
import org.junit.Test;
 
21
import org.springframework.context.ApplicationContext;
 
22
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
23
 
 
24
import com.persistit.Persistit;
 
25
import com.persistit.exception.PersistitException;
 
26
 
 
27
/**
 
28
 * Create a Persistit instance using Spring Framework.
 
29
 * 
 
30
 * @author peter
 
31
 * 
 
32
 */
 
33
public class SpringFrameworkConfigurationTest {
 
34
 
 
35
    public static class TestClient {
 
36
        final Persistit db;
 
37
 
 
38
        public TestClient(final Persistit db) {
 
39
            this.db = db;
 
40
        }
 
41
 
 
42
        private void test() {
 
43
            System.out.println(db.getVolumes());
 
44
            try {
 
45
                db.close();
 
46
            } catch (final PersistitException e) {
 
47
                e.printStackTrace();
 
48
            }
 
49
        }
 
50
    }
 
51
 
 
52
    @Test
 
53
    public void configurePersistitFromSpring() throws Exception {
 
54
        System.setProperty("com.persistit.datapath", UnitTestProperties.DATA_PATH);
 
55
        final ApplicationContext context = new ClassPathXmlApplicationContext(
 
56
                "com/persistit/unit/SpringFrameworkConfiguraitonTest.xml");
 
57
 
 
58
        final Persistit persistit = (Persistit) context.getBean("persistit");
 
59
        assertTrue("Persistit should be initialized", persistit.isInitialized());
 
60
 
 
61
        final TestClient testClient = (TestClient) context.getBean("testClient");
 
62
        testClient.test();
 
63
    }
 
64
 
 
65
}