From: pombredanne Date: Sat, 29 Sep 2007 23:26:49 +0000 (+0000) Subject: Adding a new test fragment for xdebug unit tests. X-Git-Url: http://git.phpeclipse.com?hp=bc8b483d2b3c0d860629df43873adde098de8744 Adding a new test fragment for xdebug unit tests. --- diff --git a/net.sourceforge.phpeclipse.xdebug.test/.classpath b/net.sourceforge.phpeclipse.xdebug.test/.classpath new file mode 100644 index 0000000..ce73933 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/net.sourceforge.phpeclipse.xdebug.test/.cvsignore b/net.sourceforge.phpeclipse.xdebug.test/.cvsignore new file mode 100644 index 0000000..c5e82d7 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/.cvsignore @@ -0,0 +1 @@ +bin \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.xdebug.test/.project b/net.sourceforge.phpeclipse.xdebug.test/.project new file mode 100644 index 0000000..f491514 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/.project @@ -0,0 +1,28 @@ + + + net.sourceforge.phpeclipse.xdebug.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/net.sourceforge.phpeclipse.xdebug.test/.settings/org.eclipse.jdt.core.prefs b/net.sourceforge.phpeclipse.xdebug.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9d630b4 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Fri Sep 07 14:46:23 PDT 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/net.sourceforge.phpeclipse.xdebug.test/META-INF/MANIFEST.MF b/net.sourceforge.phpeclipse.xdebug.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000..74da33a --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Xdebug Test Fragment +Bundle-SymbolicName: net.sourceforge.phpeclipse.xdebug.test +Bundle-Version: 1.0.0 +Bundle-Vendor: PHPEclipse team +Fragment-Host: net.sourceforge.phpeclipse.xdebug.core;bundle-version="0.0.0" +Require-Bundle: org.junit +Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/net.sourceforge.phpeclipse.xdebug.test/build.properties b/net.sourceforge.phpeclipse.xdebug.test/build.properties new file mode 100644 index 0000000..34d2e4d --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/net.sourceforge.phpeclipse.xdebug.test/src/net/sourceforge/phpeclipse/xdebug/core/Base64Test.java b/net.sourceforge.phpeclipse.xdebug.test/src/net/sourceforge/phpeclipse/xdebug/core/Base64Test.java new file mode 100644 index 0000000..300a677 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.test/src/net/sourceforge/phpeclipse/xdebug/core/Base64Test.java @@ -0,0 +1,55 @@ +package net.sourceforge.phpeclipse.xdebug.core; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Random; + +import junit.framework.TestCase; + +public class Base64Test extends TestCase { + private static final long SEED = 12345678; + private static Random s_random = new Random(SEED); + + private byte[] createData(int length) throws Exception { + byte[] bytes = new byte[length]; + s_random.nextBytes(bytes); + return bytes; + } + + private void runStreamTest(int length) throws Exception { + byte[] data = createData(length); + ByteArrayOutputStream out_bytes = new ByteArrayOutputStream(); + OutputStream out = new Base64.OutputStream(out_bytes); + out.write(data); + out.close(); + byte[] encoded = out_bytes.toByteArray(); + byte[] decoded = Base64.decode(encoded, 0, encoded.length); + assertTrue(Arrays.equals(data, decoded)); + + Base64.InputStream in = new Base64.InputStream( + new ByteArrayInputStream(encoded)); + out_bytes = new ByteArrayOutputStream(); + byte[] buffer = new byte[3]; + for (int n = in.read(buffer); n > 0; n = in.read(buffer)) { + out_bytes.write(buffer, 0, n); + } + out_bytes.close(); + in.close(); + decoded = out_bytes.toByteArray(); + assertTrue(Arrays.equals(data, decoded)); + } + + public void testStreams() throws Exception { + for (int i = 0; i < 100; ++i) { + runStreamTest(i); + } + for (int i = 100; i < 2000; i += 250) { + runStreamTest(i); + } + for (int i = 2000; i < 80000; i += 1000) { + runStreamTest(i); + } + } +}