2 * Copyright (c) 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.persistence;
10 import akka.persistence.snapshot.SnapshotStoreSpec;
11 import com.typesafe.config.ConfigFactory;
13 import java.io.IOException;
14 import org.apache.commons.io.FileUtils;
15 import org.junit.runner.RunWith;
16 import org.scalatestplus.junit.JUnitRunner;
19 * Tests the LocalSnapshotStore using akka's standard test suite for snapshot store plugins via SnapshotStoreSpec.
20 * This class basically does the setup and tear down with SnapshotStoreSpec doing the rest. SnapshotStoreSpec uses
21 * ScalaTest so needs to be run with scala's JUnitRunner.
23 * @author Thomas Pantelis
25 @RunWith(JUnitRunner.class)
26 public class LocalSnapshotStoreSpecTest extends SnapshotStoreSpec {
27 private static final long serialVersionUID = 1L;
28 static final File SNAPSHOT_DIR = new File("target/snapshots");
30 public LocalSnapshotStoreSpecTest() {
31 super(ConfigFactory.load("LocalSnapshotStoreTest.conf"));
35 public void afterAll() {
37 FileUtils.deleteQuietly(SNAPSHOT_DIR);
40 static void cleanSnapshotDir() {
41 if (!SNAPSHOT_DIR.exists()) {
46 FileUtils.cleanDirectory(SNAPSHOT_DIR);
47 } catch (IOException e) {
52 static void createSnapshotDir() {
53 if (!SNAPSHOT_DIR.exists() && !SNAPSHOT_DIR.mkdirs()) {
54 throw new RuntimeException("Failed to create " + SNAPSHOT_DIR);