mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02:06 +01:00
Renamed DefaultRosterStore to DirectoryRosterStore
This commit is contained in:
parent
1bf57cb6a1
commit
6b4c53bfc5
3 changed files with 16 additions and 16 deletions
|
@ -40,7 +40,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
* @author Lars Noschinski
|
* @author Lars Noschinski
|
||||||
* @author Fabian Schuetz
|
* @author Fabian Schuetz
|
||||||
*/
|
*/
|
||||||
public class DefaultRosterStore implements RosterStore {
|
public class DirectoryRosterStore implements RosterStore {
|
||||||
|
|
||||||
private final File fileDir;
|
private final File fileDir;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class DefaultRosterStore implements RosterStore {
|
||||||
* There is also one special file '__version__' that contains the
|
* There is also one special file '__version__' that contains the
|
||||||
* current version string.
|
* current version string.
|
||||||
*/
|
*/
|
||||||
private DefaultRosterStore(final File baseDir) {
|
private DirectoryRosterStore(final File baseDir) {
|
||||||
this.fileDir = baseDir;
|
this.fileDir = baseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ public class DefaultRosterStore implements RosterStore {
|
||||||
* @param baseDir
|
* @param baseDir
|
||||||
* The directory to create the store in. The directory should
|
* The directory to create the store in. The directory should
|
||||||
* be empty
|
* be empty
|
||||||
* @return A {@link DefaultRosterStore} instance if successful,
|
* @return A {@link DirectoryRosterStore} instance if successful,
|
||||||
* <code>null</code> else.
|
* <code>null</code> else.
|
||||||
*/
|
*/
|
||||||
public static DefaultRosterStore init(final File baseDir) {
|
public static DirectoryRosterStore init(final File baseDir) {
|
||||||
DefaultRosterStore store = new DefaultRosterStore(baseDir);
|
DirectoryRosterStore store = new DirectoryRosterStore(baseDir);
|
||||||
if (store.setRosterVersion("")) {
|
if (store.setRosterVersion("")) {
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
@ -92,11 +92,11 @@ public class DefaultRosterStore implements RosterStore {
|
||||||
* Opens a roster store
|
* Opens a roster store
|
||||||
* @param baseDir
|
* @param baseDir
|
||||||
* The directory containing the roster store.
|
* The directory containing the roster store.
|
||||||
* @return A {@link DefaultRosterStore} instance if successful,
|
* @return A {@link DirectoryRosterStore} instance if successful,
|
||||||
* <code>null</code> else.
|
* <code>null</code> else.
|
||||||
*/
|
*/
|
||||||
public static DefaultRosterStore open(final File baseDir) {
|
public static DirectoryRosterStore open(final File baseDir) {
|
||||||
DefaultRosterStore store = new DefaultRosterStore(baseDir);
|
DirectoryRosterStore store = new DirectoryRosterStore(baseDir);
|
||||||
String s = FileUtils.readFile(store.getVersionFile());
|
String s = FileUtils.readFile(store.getVersionFile());
|
||||||
if (s != null && s.startsWith(STORE_ID + "\n")) {
|
if (s != null && s.startsWith(STORE_ID + "\n")) {
|
||||||
return store;
|
return store;
|
|
@ -36,11 +36,11 @@ import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the implementation of {@link DefaultRosterStore}.
|
* Tests the implementation of {@link DirectoryRosterStore}.
|
||||||
*
|
*
|
||||||
* @author Lars Noschinski
|
* @author Lars Noschinski
|
||||||
*/
|
*/
|
||||||
public class DefaultRosterStoreTest {
|
public class DirectoryRosterStoreTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||||
|
@ -59,7 +59,7 @@ public class DefaultRosterStoreTest {
|
||||||
@Test
|
@Test
|
||||||
public void testStoreUninitialized() throws IOException {
|
public void testStoreUninitialized() throws IOException {
|
||||||
File storeDir = tmpFolder.newFolder();
|
File storeDir = tmpFolder.newFolder();
|
||||||
assertNull(DefaultRosterStore.open(storeDir));
|
assertNull(DirectoryRosterStore.open(storeDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +68,7 @@ public class DefaultRosterStoreTest {
|
||||||
@Test
|
@Test
|
||||||
public void testStoreInitializedEmpty() throws IOException {
|
public void testStoreInitializedEmpty() throws IOException {
|
||||||
File storeDir = tmpFolder.newFolder();
|
File storeDir = tmpFolder.newFolder();
|
||||||
DefaultRosterStore store = DefaultRosterStore.init(storeDir);
|
DirectoryRosterStore store = DirectoryRosterStore.init(storeDir);
|
||||||
assertNotNull("Initialization returns store", store);
|
assertNotNull("Initialization returns store", store);
|
||||||
assertEquals("Freshly initialized store must have empty version",
|
assertEquals("Freshly initialized store must have empty version",
|
||||||
"", store.getRosterVersion());
|
"", store.getRosterVersion());
|
||||||
|
@ -82,7 +82,7 @@ public class DefaultRosterStoreTest {
|
||||||
@Test
|
@Test
|
||||||
public void testStoreAddRemove() throws IOException {
|
public void testStoreAddRemove() throws IOException {
|
||||||
File storeDir = tmpFolder.newFolder();
|
File storeDir = tmpFolder.newFolder();
|
||||||
DefaultRosterStore store = DefaultRosterStore.init(storeDir);
|
DirectoryRosterStore store = DirectoryRosterStore.init(storeDir);
|
||||||
|
|
||||||
assertEquals("Initial roster version", "", store.getRosterVersion());
|
assertEquals("Initial roster version", "", store.getRosterVersion());
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public class DefaultRosterStoreTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAddEvilChars() throws IOException {
|
public void testAddEvilChars() throws IOException {
|
||||||
File storeDir = tmpFolder.newFolder();
|
File storeDir = tmpFolder.newFolder();
|
||||||
DefaultRosterStore store = DefaultRosterStore.init(storeDir);
|
DirectoryRosterStore store = DirectoryRosterStore.init(storeDir);
|
||||||
|
|
||||||
String user = "../_#;\"'\\&@example.com";
|
String user = "../_#;\"'\\&@example.com";
|
||||||
String name = "\n../_#\0\t;\"'&@\\";
|
String name = "\n../_#\0\t;\"'&@\\";
|
|
@ -59,7 +59,7 @@ public class RosterVersioningTest {
|
||||||
// Uncomment this to enable debug output
|
// Uncomment this to enable debug output
|
||||||
//XMPPConnection.DEBUG_ENABLED = true;
|
//XMPPConnection.DEBUG_ENABLED = true;
|
||||||
|
|
||||||
DefaultRosterStore store = DefaultRosterStore.init(tmpFolder.newFolder("store"));
|
DirectoryRosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder("store"));
|
||||||
populateStore(store);
|
populateStore(store);
|
||||||
|
|
||||||
ConnectionConfiguration conf = new ConnectionConfiguration("dummy");
|
ConnectionConfiguration conf = new ConnectionConfiguration("dummy");
|
||||||
|
@ -99,7 +99,7 @@ public class RosterVersioningTest {
|
||||||
for (RosterEntry entry : entries) {
|
for (RosterEntry entry : entries) {
|
||||||
items.add(RosterEntry.toRosterItem(entry));
|
items.add(RosterEntry.toRosterItem(entry));
|
||||||
}
|
}
|
||||||
RosterStore store = DefaultRosterStore.init(tmpFolder.newFolder());
|
RosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder());
|
||||||
populateStore(store);
|
populateStore(store);
|
||||||
assertEquals("Elements of the roster", new HashSet<Item>(store.getEntries()), items);
|
assertEquals("Elements of the roster", new HashSet<Item>(store.getEntries()), items);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue