X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-directory-autodetect-adapter%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fstorage%2Fdirectory%2Fautodetect%2FAutodetectDirectoryPersisterTest.java;fp=opendaylight%2Fconfig%2Fconfig-persister-directory-autodetect-adapter%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fstorage%2Fdirectory%2Fautodetect%2FAutodetectDirectoryPersisterTest.java;h=0000000000000000000000000000000000000000;hb=0e4624c8b041722680ca406f65ee070aab7baa70;hp=bcade93352670fcae086cf75f776242d0886276e;hpb=029fc5247757e94a9430f22c0ed51702ea7b51a1;p=controller.git diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java deleted file mode 100644 index bcade93352..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.persist.storage.directory.autodetect; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import junit.framework.Assert; -import org.junit.Test; -import org.junit.matchers.JUnitMatchers; -import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; -import org.opendaylight.controller.config.persist.test.PropertiesProviderTest; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -public class AutodetectDirectoryPersisterTest { - - @Test - public void testCombined() throws Exception { - File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config"); - File parentFile = resourcePath.getParentFile(); - - AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter(); - - PropertiesProviderTest pp = new PropertiesProviderTest(); - pp.addProperty("directoryStorage",parentFile.getPath()); - AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp); - List configs = persister.loadLastConfigs(); - - Assert.assertEquals(2, configs.size()); - String snapFromTxt = configs.get(0).getConfigSnapshot(); - org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("txt")); - org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("txt")); - - String snapFromXml = configs.get(1).getConfigSnapshot(); - org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("xml")); - - Assert.assertEquals(configs.get(0).getCapabilities(), configs.get(1).getCapabilities()); - } - - @Test - public void testInvalidXml() throws Exception { - File resourcePath = FileTypeTest.getResourceAsFile("/bad_controller.xml.config"); - File parentFile = resourcePath.getParentFile(); - - AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter(); - - PropertiesProviderTest pp = new PropertiesProviderTest(); - pp.addProperty("directoryStorage",parentFile.getPath()); - AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp); - try { - List configs = persister.loadLastConfigs(); - fail("An exception of type " + IllegalStateException.class + " was expected"); - } catch (IllegalStateException ise){ - String message = ise.getMessage(); - assertThat(message, JUnitMatchers.containsString("Unable to restore configuration snapshot from ")); - } - - } - - @Test - public void testPersistConfig() throws Exception { - File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config"); - File parentFile = resourcePath.getParentFile(); - - AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter(); - - PropertiesProviderTest pp = new PropertiesProviderTest(); - pp.addProperty("directoryStorage",parentFile.getPath()); - AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp); - List configs = null; - try { - configs = persister.loadLastConfigs(); - } catch (IOException e) { - fail("An exception of type " + UnsupportedOperationException.class + " was expected"); - } - Assert.assertEquals(2, configs.size()); - try { - persister.persistConfig(configs.get(0)); - } catch (UnsupportedOperationException uoe){ - String message = uoe.getMessage(); - assertThat(message,JUnitMatchers.containsString("This adapter is read only. Please set readonly=true on class")); - } - } - -}