Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / AbstractActorTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.raft;
10
11 import akka.actor.ActorSystem;
12 import akka.testkit.javadsl.TestKit;
13 import java.io.File;
14 import java.io.IOException;
15 import org.apache.commons.io.FileUtils;
16 import org.junit.AfterClass;
17 import org.junit.BeforeClass;
18 import org.opendaylight.yangtools.util.AbstractStringIdentifier;
19
20 public abstract class AbstractActorTest {
21     protected static final class MockIdentifier extends AbstractStringIdentifier<MockIdentifier> {
22         private static final long serialVersionUID = 1L;
23
24         public MockIdentifier(final String string) {
25             super(string);
26         }
27     }
28
29     private static ActorSystem system;
30
31     @BeforeClass
32     public static void setUpClass() throws Exception {
33         deleteJournal();
34         System.setProperty("shard.persistent", "false");
35         system = ActorSystem.create("test");
36     }
37
38     @AfterClass
39     public static void tearDownClass() throws Exception {
40         deleteJournal();
41         TestKit.shutdownActorSystem(system);
42         system = null;
43     }
44
45     protected ActorSystem getSystem() {
46         return system;
47     }
48
49     protected static void deleteJournal() throws IOException {
50         File journal = new File("journal");
51
52         if (journal.exists()) {
53             FileUtils.deleteDirectory(journal);
54         }
55     }
56
57 }