Skip to content

Commit

Permalink
DLFS Browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Apr 20, 2024
1 parent 7b343a2 commit d5c2694
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion convex-core/src/main/java/convex/dlfs/DLFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
* A Data Lattice FileSystem has:
* - A single root directory
* - A method of snapshotting any path on the tree
* - An efficient method of cloning the Drive with an immutable snapshot
*/
public abstract class DLFileSystem extends FileSystem {
public abstract class DLFileSystem extends FileSystem implements Cloneable {

static final String SEP = "/";

Expand Down Expand Up @@ -246,4 +247,7 @@ public void replicate(DLFileSystem other) {
merge(other.getNode(other.getRoot()));
}

@Override
public abstract DLFileSystem clone();

}
2 changes: 1 addition & 1 deletion convex-core/src/main/java/convex/dlfs/impl/DLFSLocal.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* Local DLFS Drive implementation
*/
public class DLFSLocal extends DLFileSystem implements Cloneable {
public class DLFSLocal extends DLFileSystem {

AVector<ACell> rootNode;

Expand Down
14 changes: 9 additions & 5 deletions convex-gui/src/main/java/convex/gui/dlfs/DLFSBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import convex.core.data.ACell;
import convex.core.data.AVector;
import convex.dlfs.DLFS;
import convex.dlfs.DLFileSystem;
import convex.dlfs.DLPath;
import convex.dlfs.impl.DLFSLocal;
import convex.gui.components.AbstractGUI;
Expand All @@ -24,17 +25,17 @@
@SuppressWarnings("serial")
public class DLFSBrowser extends AbstractGUI {

protected DLFSLocal drive;
protected DLFileSystem drive;

protected static ArrayList<DLFSLocal> allDrives=new ArrayList<>();
protected static ArrayList<DLFileSystem> allDrives=new ArrayList<>();

public JMenuBar menuBar=new JMenuBar();
public JMenu fileMenu=new JMenu("File");
public JMenu driveMenu=new JMenu("Drive");
public JMenu helpMenu=new JMenu("Help");
protected DLFSPanel panel;

public DLFSBrowser(DLFSLocal drive) {
public DLFSBrowser(DLFileSystem drive) {
allDrives.add(drive);
setLayout(new MigLayout());
this.drive=drive;
Expand Down Expand Up @@ -67,7 +68,7 @@ public DLFSBrowser(DLFSLocal drive) {

driveMenu.add(makeMenu("Clone",()->new DLFSBrowser(drive.clone()).run()));
driveMenu.add(makeMenu("Sync",()->{
for (DLFSLocal other: allDrives) {
for (DLFileSystem other: allDrives) {
if (other!=drive) {
System.out.println("Replicating!!");
drive.replicate(other);
Expand All @@ -78,7 +79,7 @@ public DLFSBrowser(DLFSLocal drive) {
menuBar.add(driveMenu);

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

}

public DLFileSystem getDrive() {
return drive;
}

public DLFSBrowser() {
this(createDemoDrive());
Expand Down
11 changes: 11 additions & 0 deletions convex-gui/src/test/java/convex/gui/GUITest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package convex.gui;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import convex.core.State;
import convex.core.crypto.AKeyPair;
import convex.core.exceptions.InvalidDataException;
import convex.dlfs.DLFileSystem;
import convex.gui.dlfs.DLFSBrowser;
import convex.gui.peer.PeerGUI;

/**
Expand All @@ -23,4 +27,11 @@ public void testState() throws InvalidDataException {
State s = manager.getLatestState();
s.validate();
}

@Test
public void testDLFSBrowser() {
DLFSBrowser browser=new DLFSBrowser();
DLFileSystem drive=browser.getDrive();
assertEquals(0,drive.getRoot().getNameCount());
}
}

0 comments on commit d5c2694

Please sign in to comment.