2 * Copyright (c) 2013 Cisco 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.config.persist.storage.directory.autodetect;
11 import java.util.List;
12 import junit.framework.Assert;
13 import org.junit.Test;
14 import org.junit.matchers.JUnitMatchers;
15 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
16 import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
18 public class AutodetectDirectoryPersisterTest {
21 public void testCombined() throws Exception {
22 File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
23 File parentFile = resourcePath.getParentFile();
25 AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
27 PropertiesProviderTest pp = new PropertiesProviderTest();
28 pp.addProperty("directoryStorage",parentFile.getPath());
29 AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
30 List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
32 Assert.assertEquals(2, configs.size());
33 String snapFromTxt = configs.get(0).getConfigSnapshot();
34 org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<config>txt</config>"));
35 org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<service>txt</service>"));
37 String snapFromXml = configs.get(1).getConfigSnapshot();
38 org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("<config>xml</config>"));
40 Assert.assertEquals(configs.get(0).getCapabilities(), configs.get(1).getCapabilities()); }