Skip to content

Commit 05bb96e

Browse files
committed
Merge pull request #495 from ThomasJClark/serialization3
Fix deserializing ProjectSettings from previous GRIP versions
2 parents 5aba88e + d279ed4 commit 05bb96e

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

core/src/main/java/edu/wpi/grip/core/serialization/Project.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.common.annotations.VisibleForTesting;
44
import com.thoughtworks.xstream.XStream;
5+
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
56
import edu.wpi.grip.core.*;
67
import edu.wpi.grip.core.sources.CameraSource;
78
import edu.wpi.grip.core.sources.ImageFileSource;
@@ -22,7 +23,7 @@ public class Project {
2223
@Inject
2324
private Pipeline pipeline;
2425

25-
protected final XStream xstream = new XStream();
26+
protected final XStream xstream = new XStream(new PureJavaReflectionProvider());
2627
private Optional<File> file = Optional.empty();
2728

2829
@Inject

core/src/test/java/edu/wpi/grip/core/serialization/ProjectTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.StringWriter;
2525
import java.io.Writer;
2626

27+
import static junit.framework.Assert.assertNotNull;
2728
import static junit.framework.TestCase.assertEquals;
2829
import static org.bytedeco.javacpp.opencv_core.*;
2930

@@ -152,7 +153,7 @@ public void testPerformSerializedStep() throws Exception {
152153
serializeAndDeserialize();
153154

154155

155-
final Step fromPipeline = pipeline.getSteps().get(0);
156+
final Step fromPipeline = pipeline.getSteps().get(0);
156157
InputSocket<Number> a = (InputSocket<Number>) fromPipeline.getInputSockets()[0];
157158
InputSocket<Number> b = (InputSocket<Number>) fromPipeline.getInputSockets()[1];
158159
OutputSocket<Number> sum = (OutputSocket<Number>) fromPipeline.getOutputSockets()[0];
@@ -171,7 +172,7 @@ public void testPerformSerializedPythonStepFromURL() throws Exception {
171172
pipeline.addStep(stepFactory.create(pythonAdditionOperationFromURL));
172173
serializeAndDeserialize();
173174

174-
final Step fromPipeline = pipeline.getSteps().get(0);
175+
final Step fromPipeline = pipeline.getSteps().get(0);
175176
InputSocket<Number> a = (InputSocket<Number>) fromPipeline.getInputSockets()[0];
176177
InputSocket<Number> b = (InputSocket<Number>) fromPipeline.getInputSockets()[1];
177178
OutputSocket<Number> sum = (OutputSocket<Number>) fromPipeline.getOutputSockets()[0];
@@ -191,7 +192,7 @@ public void testPerformSerializedPythonStepFromSource() throws Exception {
191192
pipeline.addStep(stepFactory.create(pythonAdditionOperationFromSource));
192193
serializeAndDeserialize();
193194

194-
final Step fromPipeline = pipeline.getSteps().get(0);
195+
final Step fromPipeline = pipeline.getSteps().get(0);
195196
InputSocket<Number> a = (InputSocket<Number>) fromPipeline.getInputSockets()[0];
196197
InputSocket<Number> b = (InputSocket<Number>) fromPipeline.getInputSockets()[1];
197198
OutputSocket<Number> sum = (OutputSocket<Number>) fromPipeline.getOutputSockets()[0];
@@ -228,7 +229,6 @@ public void testPerformSerializedPipeline() throws Exception {
228229
OutputSocket<Number> sum2 = (OutputSocket<Number>) step2Out.getOutputSockets()[0];
229230

230231

231-
232232
a1.setValue(123);
233233
b1.setValue(456);
234234
b2.setValue(789);
@@ -250,7 +250,6 @@ public void testPerformSerializedPipelineWithMats() throws Exception {
250250
OutputSocket<Mat> sum = (OutputSocket<Mat>) step1.getOutputSockets()[0];
251251

252252

253-
254253
a.setValue(new Mat(1, 1, CV_32F, new Scalar(1234.5)));
255254
b.setValue(new Mat(1, 1, CV_32F, new Scalar(6789.0)));
256255

@@ -290,4 +289,18 @@ public void testSerializedProjectSettings() {
290289
assertEquals("Deploy address was not serialized/deserialized",
291290
"roborio-191-frc.local", pipeline.getProjectSettings().getDeployAddress());
292291
}
292+
293+
@Test
294+
public void testUnspecifiedProjectSettings() {
295+
Reader reader = new StringReader("<grip:Pipeline>" +
296+
" <sources/>" +
297+
" <steps/>" +
298+
" <connections/>" +
299+
" <settings/>" +
300+
"</grip:Pipeline>");
301+
302+
project.open(reader);
303+
304+
assertNotNull("Project setting was null", pipeline.getProjectSettings().getDeployJvmOptions());
305+
}
293306
}

0 commit comments

Comments
 (0)