7e423914c216c02c88c92f58e367d6818b0fa86c
[controller.git] / opendaylight / config / config-persister-directory-autodetect-adapter / src / test / java / org / opendaylight / controller / config / persist / storage / directory / autodetect / AutodetectDirectoryPersisterTest.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.controller.config.persist.storage.directory.autodetect;
9
10 import junit.framework.Assert;
11 import org.junit.Test;
12 import org.junit.matchers.JUnitMatchers;
13 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
14
15 import java.io.File;
16 import java.util.List;
17
18 public class AutodetectDirectoryPersisterTest {
19
20     @Test
21     public void testCombined() throws Exception {
22         File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
23
24         AutodetectDirectoryPersister persister = new AutodetectDirectoryPersister(resourcePath.getParentFile());
25         List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
26
27         Assert.assertEquals(2, configs.size());
28         String snapFromTxt = configs.get(0).getConfigSnapshot();
29         org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<config>txt</config>"));
30         org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<service>txt</service>"));
31
32         String snapFromXml = configs.get(1).getConfigSnapshot();
33         org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("<config>xml</config>"));
34
35         Assert.assertEquals(configs.get(0).getCapabilities(), configs.get(1).getCapabilities());
36     }
37 }