Skip to content

Commit e8ecb53

Browse files
PaulaRudyPaulaRudy
authored andcommitted
Cleaned up file references, removed some stuff as per JLLeitschuh's recommendation. Still not recognizing the steps though.
1 parent 6925e2b commit e8ecb53

4 files changed

Lines changed: 16 additions & 45 deletions

File tree

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package edu.wpi.grip.core.serialization;
22

3-
import com.google.common.base.Throwables;
43
import com.google.common.eventbus.EventBus;
54
import com.google.common.eventbus.Subscribe;
65
import com.google.inject.Guice;
@@ -9,25 +8,23 @@
98
import com.google.inject.TypeLiteral;
109
import edu.wpi.grip.core.*;
1110
import edu.wpi.grip.core.events.OperationAddedEvent;
12-
import edu.wpi.grip.core.operations.Operations;
1311
import edu.wpi.grip.core.sources.ImageFileSource;
14-
import edu.wpi.grip.core.util.MockExceptionWitness;
15-
import edu.wpi.grip.generated.CVOperations;
16-
import org.junit.After;
12+
import edu.wpi.grip.util.Files;
1713
import org.junit.Before;
1814
import org.junit.Test;
1915

2016
import java.io.*;
21-
import java.net.URL;
22-
import java.nio.file.Paths;
23-
import java.util.ArrayList;
17+
import java.net.URI;
2418
import java.util.List;
2519
import java.util.Optional;
2620

2721
import static junit.framework.TestCase.assertEquals;
2822

2923
public class CompatibilityTest {
3024

25+
private static final URI testphotoURI = Files.testphotoURI;
26+
private static final URI testprojectURI = Files.testprojectURI;
27+
3128
private Connection.Factory<Object> connectionFactory;
3229
private ImageFileSource.Factory imageSourceFactory;
3330
private Step.Factory stepFactory;
@@ -61,22 +58,9 @@ public void setUp() throws Exception {
6158
project = injector.getInstance(Project.class);
6259
stepFactory = injector.getInstance(Step.Factory.class);
6360

64-
//Set up stuff we need to add the operations
65-
this.operationList = new ArrayList<>();
66-
this.throwableOptional = Optional.empty();
67-
this.eventBus = new EventBus((exception, context) -> throwableOptional = Optional.of(exception));
68-
69-
//Set up the operation grabber to help us register the operations
70-
this.eventBus.register(new OperationGrabber());
71-
7261
//Set up the test project file to work with this machine
73-
URL location = CompatibilityTest.class.getProtectionDomain().getCodeSource().getLocation();
74-
75-
int numbOfFolders = Paths.get(location.toURI()).getNameCount();
76-
77-
78-
String fileName = "/"+ Paths.get(location.toURI()).subpath(0,(numbOfFolders-4)).toString()+ "/testALL.grip";
79-
String photoFileName = "/" + Paths.get(location.toURI()).subpath(0,(numbOfFolders-4)).toString()+ "/testphoto.png";
62+
String fileName = testprojectURI.toString().substring(5);
63+
String photoFileName = testphotoURI.toString().substring(5);
8064

8165
File file = new File(fileName);
8266

@@ -88,39 +72,20 @@ public void setUp() throws Exception {
8872
}
8973
reader.close();
9074
String newtext = oldtext.replaceAll("REPLACEME", photoFileName);
75+
9176
//TODO: replace "preferences" section to work with this machine
9277
FileWriter writer2 = new FileWriter(file);
9378
writer2.write(newtext);
9479
writer2.close();
9580

96-
//Add/register/create the operations
97-
CVOperations.addOperations(eventBus);
98-
for (Operation operation : operationList) {
99-
new Step.Factory(eventBus, (origin) -> new MockExceptionWitness(eventBus, origin)).create(operation);
100-
}
101-
102-
Operations.addOperations(eventBus);
103-
for (Operation operation : operationList) {
104-
new Step.Factory(eventBus, (origin) -> new MockExceptionWitness(eventBus, origin)).create(operation);
105-
}
106-
10781
//Open the test file as a project
10882
project.open(file);
10983
}
11084

111-
@After
112-
public void afterTest() {
113-
//Throw any exceptions that weren't handled during the test
114-
if (throwableOptional.isPresent()) {
115-
throw Throwables.propagate(throwableOptional.get());
116-
}
117-
}
118-
11985
@Test
12086
public void testFoo() throws Exception {
12187

122-
assertEquals("blarg",
123-
3, 3);
88+
assertEquals("blarg", 3, 3);
12489

12590
}
12691
}

core/src/test/java/edu/wpi/grip/util/Files.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package edu.wpi.grip.util;
22

33
import java.io.File;
4+
import java.net.URI;
45
import java.net.URISyntaxException;
56

67
/**
@@ -9,6 +10,8 @@
910
public class Files {
1011
public static final ImageWithData imageFile, gompeiJpegFile;
1112
public static final File textFile;
13+
public static final URI testphotoURI, testprojectURI;
14+
1215

1316
static {
1417
try {
@@ -17,6 +20,9 @@ public class Files {
1720
Files.class.getResource("/edu/wpi/grip/images/GRIP_Logo.png").toURI()), 183, 480);
1821
gompeiJpegFile = new ImageWithData(new File(
1922
Files.class.getResource("/edu/wpi/grip/images/gompei.jpeg").toURI()), 220, 225);
23+
testphotoURI = Files.class.getResource("/edu/wpi/grip/images/testphoto.png").toURI();
24+
testprojectURI = Files.class.getResource("/edu/wpi/grip/projects/testALL.grip").toURI();
25+
2026
} catch (URISyntaxException e) {
2127
throw new IllegalStateException("Could not load file from system", e);
2228
}

testphoto.png renamed to core/src/test/resources/edu/wpi/grip/images/testphoto.png

File renamed without changes.

testALL.grip renamed to core/src/test/resources/edu/wpi/grip/projects/testALL.grip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<grip:Pipeline>
22
<sources>
33
<grip:ImageFile>
4-
<property name="path" value="/home/arsenic/Documents/schoolwork/MQP/MyFork/GRIP/testphoto.png"/>
4+
<property name="path" value="REPLACEME"/>
55
</grip:ImageFile>
66
<grip:Camera>
77
<property name="deviceNumber" value="0"/>

0 commit comments

Comments
 (0)