Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsliebig2007-11-06 03:53:17 -0500
committersliebig2007-11-06 03:53:17 -0500
commitf59f7c40e91ad4795192740cc30d7a4238416e38 (patch)
treea74fd874a601f39f3da8b7621193eb814457a2b8
parent1d5257c7ef12f0bf60ae5f7531ffdb355cb13202 (diff)
downloadrt.equinox.p2-f59f7c40e91ad4795192740cc30d7a4238416e38.tar.gz
rt.equinox.p2-f59f7c40e91ad4795192740cc30d7a4238416e38.tar.xz
rt.equinox.p2-f59f7c40e91ad4795192740cc30d7a4238416e38.zip
Test the extended jbdiff library
-rw-r--r--bundles/ie.wombat.jbdiff.test/.classpath7
-rw-r--r--bundles/ie.wombat.jbdiff.test/.project28
-rw-r--r--bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF12
-rw-r--r--bundles/ie.wombat.jbdiff.test/build.properties4
-rw-r--r--bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java45
-rw-r--r--bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java112
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exebin0 -> 180224 bytes
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exebin0 -> 53248 bytes
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/null.data0
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/one.data1
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data1
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/onehundred.data1
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/onehundredX.data1
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jarbin0 -> 772717 bytes
-rw-r--r--bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jarbin0 -> 996050 bytes
16 files changed, 216 insertions, 0 deletions
diff --git a/bundles/ie.wombat.jbdiff.test/.classpath b/bundles/ie.wombat.jbdiff.test/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/ie.wombat.jbdiff.test/.project b/bundles/ie.wombat.jbdiff.test/.project
new file mode 100644
index 000000000..ac8a8a03f
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ie.wombat.jbdiff.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs b/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..0c5082bd7
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Thu Nov 01 14:26:02 CET 2007
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF b/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..d302fe5fa
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBDiff Test Plug-in
+Bundle-SymbolicName: ie.wombat.jbdiff.test
+Bundle-Version: 0.1.0.1
+Bundle-Activator: ie.wombat.jbdiff.test.Activator
+Import-Package: org.osgi.framework;version="1.3.0"
+Eclipse-LazyStart: true
+Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
+ J2SE-1.4
+Require-Bundle: org.junit,
+ ie.wombat.jbdiff
diff --git a/bundles/ie.wombat.jbdiff.test/build.properties b/bundles/ie.wombat.jbdiff.test/build.properties
new file mode 100644
index 000000000..34d2e4d2d
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java
new file mode 100644
index 000000000..0d0bb3f2a
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ *******************************************************************************/
+package ie.wombat.jbdiff.test;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ Activator.context = context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ Activator.context = null;
+ }
+
+ /**
+ * @return the context
+ */
+ public static BundleContext getContext() {
+ return context;
+ }
+
+}
diff --git a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java
new file mode 100644
index 000000000..5f5e7d8f7
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ *******************************************************************************/
+package ie.wombat.jbdiff.test;
+
+import ie.wombat.jbdiff.JBDiff;
+import ie.wombat.jbdiff.JBPatch;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+public class DiffPatchTest extends TestCase {
+
+ public void testNullData() throws Exception {
+ bench("null.data", "null.data");
+ }
+
+ public void testOneData() throws Exception {
+ bench("one.data", "one.data");
+ }
+
+ public void testOneHundredData() throws Exception {
+ bench("onehundred.data", "onehundred.data");
+ }
+
+ public void testOneHundredXData() throws Exception {
+ bench("onehundred.data", "onehundredX.data");
+ }
+
+ public void testOneXHundredXData() throws Exception {
+ bench("onehundred.data", "oneXhundredX.data");
+ }
+
+ public void testPdeCoreJar() throws Exception {
+ bench("org.eclipse.pde.core_3.2.jar", "org.eclipse.pde.core_3.3.jar");
+ }
+
+ public void testEclipse() throws Exception {
+ bench("eclipse-3.2.exe", "eclipse-3.3.exe");
+ }
+
+ private void bench(String resource1, String resource2) throws Exception {
+
+ byte[] oldData = getTestData(resource1);
+ byte[] newData = getTestData(resource2);
+
+ System.out.println(resource1 + "(" + (oldData.length / 1024)
+ + " kb) -> " + resource2 + "(" + (newData.length / 1024)
+ + " kb)");
+
+ diffAndPatchJBDiff(oldData, newData);
+
+ System.out.println("");
+ }
+
+ /**
+ * @param resource1
+ * @param resource2
+ * @throws IOException
+ */
+ private void diffAndPatchJBDiff(byte[] oldData, byte[] newData)
+ throws IOException {
+
+ try {
+
+ long start = System.currentTimeMillis();
+
+ byte[] diff = JBDiff.bsdiff(oldData, oldData.length, newData,
+ newData.length);
+
+ long diffEnd = System.currentTimeMillis();
+
+ byte[] patch = JBPatch.bspatch(oldData, oldData.length, diff);
+
+ long patchEnd = System.currentTimeMillis();
+
+ System.out.println("JBDiff: Size= " + diff.length + " b ("
+ + diff.length / 1024 + " kb), Diffing " + (diffEnd - start)
+ + " ms, Patching: " + (patchEnd - diffEnd) + " ms");
+
+ assertTrue(Arrays.equals(newData, patch));
+
+ } catch (RuntimeException re) {
+ System.err.println("JBDiff: error: " + re.getMessage());
+ }
+ }
+
+ private static byte[] getTestData(String name) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ InputStream input = new BufferedInputStream(Activator.getContext()
+ .getBundle().getEntry("testData/" + name).openStream());
+ int r;
+ while ((r = input.read()) != -1) {
+ out.write(r);
+ }
+ input.close();
+ out.close();
+ return out.toByteArray();
+ }
+} \ No newline at end of file
diff --git a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe
new file mode 100644
index 000000000..7826d1ed8
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe
Binary files differ
diff --git a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe
new file mode 100644
index 000000000..c5cd8f038
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe
Binary files differ
diff --git a/bundles/ie.wombat.jbdiff.test/testData/null.data b/bundles/ie.wombat.jbdiff.test/testData/null.data
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/null.data
diff --git a/bundles/ie.wombat.jbdiff.test/testData/one.data b/bundles/ie.wombat.jbdiff.test/testData/one.data
new file mode 100644
index 000000000..56a6051ca
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/one.data
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data b/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data
new file mode 100644
index 000000000..bb1077fd5
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data
@@ -0,0 +1 @@
+0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X \ No newline at end of file
diff --git a/bundles/ie.wombat.jbdiff.test/testData/onehundred.data b/bundles/ie.wombat.jbdiff.test/testData/onehundred.data
new file mode 100644
index 000000000..edd4e96b7
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/onehundred.data
@@ -0,0 +1 @@
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \ No newline at end of file
diff --git a/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data b/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data
new file mode 100644
index 000000000..cb96be8dd
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data
@@ -0,0 +1 @@
+012345678901234567890123456789012345678901234567890X234567890123456789012345678901234567890123456789 \ No newline at end of file
diff --git a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar
new file mode 100644
index 000000000..f772f865e
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar
Binary files differ
diff --git a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar
new file mode 100644
index 000000000..a78ea76fa
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar
Binary files differ

Back to the top