當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertiesProviderTest類代碼示例

本文整理匯總了Java中org.opendaylight.controller.config.persist.test.PropertiesProviderTest的典型用法代碼示例。如果您正苦於以下問題:Java PropertiesProviderTest類的具體用法?Java PropertiesProviderTest怎麽用?Java PropertiesProviderTest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PropertiesProviderTest類屬於org.opendaylight.controller.config.persist.test包,在下文中一共展示了PropertiesProviderTest類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testNewFile

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
@Test
public void testNewFile() throws Exception {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty("fileStorage",NON_EXISTENT_DIRECTORY+NON_EXISTENT_FILE);
    pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
    storage.instantiate(pp);

    final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
        @Override
        public String getConfigSnapshot() {
            return createConfig();
        }

        @Override
        public SortedSet<String> getCapabilities() {
            return createCaps();
        }
    };
    storage.persistConfig(holder);

    storage.persistConfig(holder);

    assertEquals(storage.toString().replace("\\","/"),"XmlFileStorageAdapter [storage="+NON_EXISTENT_DIRECTORY+NON_EXISTENT_FILE+"]");
    delete(new File(NON_EXISTENT_DIRECTORY));
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:26,代碼來源:FileStorageAdapterTest.java

示例2: instantiatePersisterFromAdapter

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
private Persister instantiatePersisterFromAdapter(final File file, final Optional<String> extensions) {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty(XmlDirectoryStorageAdapter.DIRECTORY_STORAGE_PROP, file.getPath());
    if (extensions.isPresent()) {
        pp.addProperty(XmlDirectoryStorageAdapter.INCLUDE_EXT_PROP, extensions.get());
    }

    XmlDirectoryStorageAdapter dsa = new XmlDirectoryStorageAdapter();
    return dsa.instantiate(pp);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:11,代碼來源:DirectoryStorageAdapterTest.java

示例3: testFileAdapter

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
@Test
public void testFileAdapter() throws Exception {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty("fileStorage",file.getPath());
    pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
    storage.instantiate(pp);

    final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
        @Override
        public String getConfigSnapshot() {
            return createConfig();
        }

        @Override
        public SortedSet<String> getCapabilities() {
            return createCaps();
        }
    };
    storage.persistConfig(holder);

    storage.persistConfig(holder);

    assertEquals(29, com.google.common.io.Files.readLines(file, StandardCharsets.UTF_8).size());
    List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
    assertEquals(1, lastConf.size());
    ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
    assertXMLEqual("<config>2</config>", configSnapshotHolder.getConfigSnapshot());
    assertEquals(createCaps(), configSnapshotHolder.getCapabilities());

    storage = new XmlFileStorageAdapter();
    storage.setFileStorage(file);
    storage.setNumberOfBackups(Integer.MAX_VALUE);

    List<ConfigSnapshotHolder> last = storage.loadLastConfigs();
    assertEquals(createCaps(), last.get(0).getCapabilities());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:37,代碼來源:FileStorageAdapterTest.java

示例4: testFileAdapterOneBackup

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
@Test
public void testFileAdapterOneBackup() throws Exception {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty("fileStorage",file.getPath());
    pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
    storage.instantiate(pp);

    final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
        @Override
        public String getConfigSnapshot() {
            return createConfig();
        }

        @Override
        public SortedSet<String> getCapabilities() {
            return createCaps();
        }
    };
    storage.persistConfig(holder);

    storage.persistConfig(holder);

    assertEquals(29, com.google.common.io.Files.readLines(file, StandardCharsets.UTF_8).size());

    List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
    assertEquals(1, lastConf.size());
    ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
    assertXMLEqual("<config>2</config>", configSnapshotHolder.getConfigSnapshot());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:30,代碼來源:FileStorageAdapterTest.java

示例5: testWithFeatures

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
@Test
public void testWithFeatures() throws Exception {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty("fileStorage",file.getPath());
    pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
    storage.instantiate(pp);

    final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
        @Override
        public String getConfigSnapshot() {
            return createConfig();
        }

        @Override
        public SortedSet<String> getCapabilities() {
            return createCaps();
        }
    };
    final FeatureListProvider mock = mock(FeatureListProvider.class);

    doReturn(Sets.newHashSet("f1-11", "f2-22")).when(mock).listFeatures();
    storage.setFeaturesService(mock);
    storage.persistConfig(holder);

    assertEquals(20, com.google.common.io.Files.readLines(file, StandardCharsets.UTF_8).size());

    List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
    assertEquals(1, lastConf.size());
    ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
    assertXMLEqual("<config>1</config>", configSnapshotHolder.getConfigSnapshot());
    assertEquals(Sets.newHashSet("f1-11", "f2-22"), storage.getPersistedFeatures());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:33,代碼來源:FileStorageAdapterTest.java

示例6: testNoFeaturesStored

import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; //導入依賴的package包/類
@Test
public void testNoFeaturesStored() throws Exception {
    PropertiesProviderTest pp = new PropertiesProviderTest();
    pp.addProperty("fileStorage",file.getPath());
    pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
    storage.instantiate(pp);

    com.google.common.io.Files.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<persisted-snapshots>\n" +
            "   <snapshots>\n" +
            "      <snapshot>\n" +
            "         <required-capabilities>\n" +
            "            <capability>cap12</capability>\n" +
            "         </required-capabilities>\n" +
            "         <configuration>\n" +
            "            <config>1</config>\n" +
            "         </configuration>\n" +
            "      </snapshot>\n" +
            "   </snapshots>\n" +
            "</persisted-snapshots>", file, StandardCharsets.UTF_8);

    List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
    assertEquals(1, lastConf.size());
    ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
    assertXMLEqual("<config>1</config>", configSnapshotHolder.getConfigSnapshot());
    assertTrue(storage.getPersistedFeatures().isEmpty());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:28,代碼來源:FileStorageAdapterTest.java


注:本文中的org.opendaylight.controller.config.persist.test.PropertiesProviderTest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。