Skip to content

Commit d5c2694

Browse files
committed
DLFS Browser tests
1 parent 7b343a2 commit d5c2694

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

convex-core/src/main/java/convex/dlfs/DLFileSystem.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
* A Data Lattice FileSystem has:
3030
* - A single root directory
3131
* - A method of snapshotting any path on the tree
32+
* - An efficient method of cloning the Drive with an immutable snapshot
3233
*/
33-
public abstract class DLFileSystem extends FileSystem {
34+
public abstract class DLFileSystem extends FileSystem implements Cloneable {
3435

3536
static final String SEP = "/";
3637

@@ -246,4 +247,7 @@ public void replicate(DLFileSystem other) {
246247
merge(other.getNode(other.getRoot()));
247248
}
248249

250+
@Override
251+
public abstract DLFileSystem clone();
252+
249253
}

convex-core/src/main/java/convex/dlfs/impl/DLFSLocal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* Local DLFS Drive implementation
3030
*/
31-
public class DLFSLocal extends DLFileSystem implements Cloneable {
31+
public class DLFSLocal extends DLFileSystem {
3232

3333
AVector<ACell> rootNode;
3434

convex-gui/src/main/java/convex/gui/dlfs/DLFSBrowser.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import convex.core.data.ACell;
1515
import convex.core.data.AVector;
1616
import convex.dlfs.DLFS;
17+
import convex.dlfs.DLFileSystem;
1718
import convex.dlfs.DLPath;
1819
import convex.dlfs.impl.DLFSLocal;
1920
import convex.gui.components.AbstractGUI;
@@ -24,17 +25,17 @@
2425
@SuppressWarnings("serial")
2526
public class DLFSBrowser extends AbstractGUI {
2627

27-
protected DLFSLocal drive;
28+
protected DLFileSystem drive;
2829

29-
protected static ArrayList<DLFSLocal> allDrives=new ArrayList<>();
30+
protected static ArrayList<DLFileSystem> allDrives=new ArrayList<>();
3031

3132
public JMenuBar menuBar=new JMenuBar();
3233
public JMenu fileMenu=new JMenu("File");
3334
public JMenu driveMenu=new JMenu("Drive");
3435
public JMenu helpMenu=new JMenu("Help");
3536
protected DLFSPanel panel;
3637

37-
public DLFSBrowser(DLFSLocal drive) {
38+
public DLFSBrowser(DLFileSystem drive) {
3839
allDrives.add(drive);
3940
setLayout(new MigLayout());
4041
this.drive=drive;
@@ -67,7 +68,7 @@ public DLFSBrowser(DLFSLocal drive) {
6768

6869
driveMenu.add(makeMenu("Clone",()->new DLFSBrowser(drive.clone()).run()));
6970
driveMenu.add(makeMenu("Sync",()->{
70-
for (DLFSLocal other: allDrives) {
71+
for (DLFileSystem other: allDrives) {
7172
if (other!=drive) {
7273
System.out.println("Replicating!!");
7374
drive.replicate(other);
@@ -78,7 +79,7 @@ public DLFSBrowser(DLFSLocal drive) {
7879
menuBar.add(driveMenu);
7980

8081
menuBar.add(makeMenu("Sync!",()->{
81-
for (DLFSLocal other: allDrives) {
82+
for (DLFileSystem other: allDrives) {
8283
if (other!=drive) {
8384
System.out.println("Replicating!!");
8485
drive.replicate(other);
@@ -91,6 +92,9 @@ public DLFSBrowser(DLFSLocal drive) {
9192

9293
}
9394

95+
public DLFileSystem getDrive() {
96+
return drive;
97+
}
9498

9599
public DLFSBrowser() {
96100
this(createDemoDrive());

convex-gui/src/test/java/convex/gui/GUITest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package convex.gui;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
35
import org.junit.jupiter.api.Test;
46

57
import convex.core.State;
68
import convex.core.crypto.AKeyPair;
79
import convex.core.exceptions.InvalidDataException;
10+
import convex.dlfs.DLFileSystem;
11+
import convex.gui.dlfs.DLFSBrowser;
812
import convex.gui.peer.PeerGUI;
913

1014
/**
@@ -23,4 +27,11 @@ public void testState() throws InvalidDataException {
2327
State s = manager.getLatestState();
2428
s.validate();
2529
}
30+
31+
@Test
32+
public void testDLFSBrowser() {
33+
DLFSBrowser browser=new DLFSBrowser();
34+
DLFileSystem drive=browser.getDrive();
35+
assertEquals(0,drive.getRoot().getNameCount());
36+
}
2637
}

0 commit comments

Comments
 (0)