Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "BUG 2317 : StatisticsManager does not unregister from yang notifications on...
[controller.git]
/
opendaylight
/
config
/
config-persister-directory-xml-adapter
/
src
/
test
/
java
/
org
/
opendaylight
/
controller
/
config
/
persist
/
storage
/
directory
/
xml
/
DirectoryStorageAdapterTest.java
diff --git
a/opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
b/opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
index da442ef4b2fb669b5b1bd0e9a389616cc6755b97..11c7e1253a18226a374b5c079130adcc23db92c6 100644
(file)
--- a/
opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
+++ b/
opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
@@
-8,27
+8,29
@@
package org.opendaylight.controller.config.persist.storage.directory.xml;
package org.opendaylight.controller.config.persist.storage.directory.xml;
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
import java.io.File;
import java.io.File;
+import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
-
-import com.google.common.base.Optional;
import org.junit.Test;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.junit.Test;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.xml.sax.SAXException;
public class DirectoryStorageAdapterTest {
public class DirectoryStorageAdapterTest {
+ private static final Logger LOG = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class);
Persister tested;
Persister tested;
- Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class.toString());
- private Persister instantiatePersisterFromAdapter(
File file,
Optional<String> extensions){
+ 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()) {
PropertiesProviderTest pp = new PropertiesProviderTest();
pp.addProperty(XmlDirectoryStorageAdapter.DIRECTORY_STORAGE_PROP,file.getPath());
if(extensions.isPresent()) {
@@
-39,7
+41,7
@@
public class DirectoryStorageAdapterTest {
return dsa.instantiate(pp);
}
return dsa.instantiate(pp);
}
- private Persister instantiatePersisterFromAdapter(File file){
+ private Persister instantiatePersisterFromAdapter(
final
File file){
return instantiatePersisterFromAdapter(file, Optional.<String>absent());
}
return instantiatePersisterFromAdapter(file, Optional.<String>absent());
}
@@
-69,7
+71,7
@@
public class DirectoryStorageAdapterTest {
}
}
}
}
- private File getFolder(String folderName) {
+ private File getFolder(
final
String folderName) {
File result = new File(("src/test/resources/" +
folderName).replace("/", File.separator));
assertTrue(result + " is not a directory", result.isDirectory());
File result = new File(("src/test/resources/" +
folderName).replace("/", File.separator));
assertTrue(result + " is not a directory", result.isDirectory());
@@
-81,7
+83,7
@@
public class DirectoryStorageAdapterTest {
File folder = getFolder("oneFile");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
File folder = getFolder("oneFile");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : {}", tested
);
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
ConfigSnapshotHolder result = results.get(0);
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
ConfigSnapshotHolder result = results.get(0);
@@
-92,11
+94,11
@@
public class DirectoryStorageAdapterTest {
public void testOneFileWrongExtension() throws Exception {
File folder = getFolder("oneFile");
tested = instantiatePersisterFromAdapter(folder, Optional.of("aa, bb"));
public void testOneFileWrongExtension() throws Exception {
File folder = getFolder("oneFile");
tested = instantiatePersisterFromAdapter(folder, Optional.of("aa, bb"));
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : {}", tested
);
}
}
- private void assertResult(
ConfigSnapshotHolder result, String s, String... caps)
{
- assert
Equals(s, result.getConfigSnapshot().replaceAll("\\s", ""
));
+ private void assertResult(
final ConfigSnapshotHolder result, final String s, final String... caps) throws SAXException, IOException
{
+ assert
XMLEqual(s, result.getConfigSnapshot(
));
int i = 0;
for (String capFromSnapshot : result.getCapabilities()) {
assertEquals(capFromSnapshot, caps[i++]);
int i = 0;
for (String capFromSnapshot : result.getCapabilities()) {
assertEquals(capFromSnapshot, caps[i++]);
@@
-107,7
+109,7
@@
public class DirectoryStorageAdapterTest {
public void testTwoFilesAllExtensions() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder);
public void testTwoFilesAllExtensions() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder);
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : {}", tested
);
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(2, results.size());
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(2, results.size());
@@
-119,7
+121,7
@@
public class DirectoryStorageAdapterTest {
public void testTwoFilesTwoExtensions() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml, xml2"));
public void testTwoFilesTwoExtensions() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml, xml2"));
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : {}", tested
);
assertEquals(2, tested.loadLastConfigs().size());
}
assertEquals(2, tested.loadLastConfigs().size());
}
@@
-127,7
+129,7
@@
public class DirectoryStorageAdapterTest {
public void testTwoFilesOnlyOneExtension() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
public void testTwoFilesOnlyOneExtension() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : ", tested
);
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
@@
-138,7
+140,7
@@
public class DirectoryStorageAdapterTest {
public void testTwoFilesOneInvalid() throws Exception {
File folder = getFolder("twoFiles_corrupt");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
public void testTwoFilesOneInvalid() throws Exception {
File folder = getFolder("twoFiles_corrupt");
tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
-
logger.info("Testing : " + tested.toString()
);
+
LOG.info("Testing : {}", tested
);
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());