Skip to content
Snippets Groups Projects
Commit b73390e5 authored by Emmanuel Bourg's avatar Emmanuel Bourg
Browse files

New upstream version 4.9

parent 5c2d98b1
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ This project uses a custom versioning scheme (and not [Semantic Versioning](http
### Changed
* make patch serializable
## [4.8]
### Changed
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId>
<version>4.8</version>
<version>4.9</version>
</parent>
<artifactId>java-diff-utils-jgit</artifactId>
<name>java-diff-utils-jgit</name>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId>
<version>4.8</version>
<version>4.9</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -15,6 +15,7 @@
*/
package com.github.difflib.patch;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
......@@ -22,7 +23,7 @@ import java.util.Objects;
* Abstract delta between a source and a target.
* @author Tobias Warneke (t.warneke@gmx.net)
*/
public abstract class AbstractDelta<T> {
public abstract class AbstractDelta<T> implements Serializable {
private final Chunk<T> source;
private final Chunk<T> target;
private final DeltaType type;
......
......@@ -15,6 +15,7 @@
*/
package com.github.difflib.patch;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -33,7 +34,7 @@ import java.util.Objects;
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
* @param <T> The type of the compared elements in the 'lines'.
*/
public final class Chunk<T> {
public final class Chunk<T> implements Serializable {
private final int position;
private List<T> lines;
......
......@@ -21,6 +21,8 @@ package com.github.difflib.patch;
import static java.util.Comparator.comparing;
import com.github.difflib.algorithm.Change;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -32,7 +34,7 @@ import java.util.ListIterator;
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param <T> The type of the compared elements in the 'lines'.
*/
public final class Patch<T> {
public final class Patch<T> implements Serializable {
private final List<AbstractDelta<T>> deltas;
......
package com.github.difflib.patch;
import com.github.difflib.DiffUtils;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import com.github.difflib.DiffUtils;
public class PatchTest {
@Test
......@@ -47,4 +55,27 @@ public class PatchTest {
fail(e.getMessage());
}
}
@Test
public void testPatch_Serializable() throws IOException, ClassNotFoundException {
final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd");
final List<String> changeTest_to = Arrays.asList("aaa", "bxb", "cxc", "ddd");
final Patch<String> patch = DiffUtils.diff(changeTest_from, changeTest_to);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(patch);
out.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bais);
Patch<String> result = (Patch<String>) in.readObject();
in.close();
try {
assertEquals(changeTest_to, DiffUtils.patch(changeTest_from, result));
} catch (PatchFailedException e) {
fail(e.getMessage());
}
}
}
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId>
<version>4.8</version>
<version>4.9</version>
<name>java-diff-utils-parent</name>
<packaging>pom</packaging>
<modules>
......@@ -29,7 +29,7 @@
<connection>scm:git:https://github.com/java-diff-utils/java-diff-utils.git</connection>
<developerConnection>scm:git:ssh://git@github.com:java-diff-utils/java-diff-utils.git</developerConnection>
<url>https://github.com/java-diff-utils/java-diff-utils.git</url>
<tag>java-diff-utils-parent-4.8</tag>
<tag>java-diff-utils-parent-4.9</tag>
</scm>
<issueManagement>
<system>GitHub Issues</system>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment