Adding a new test fragment for xdebug unit tests.
authorpombredanne <pombredanne>
Sat, 29 Sep 2007 23:26:49 +0000 (23:26 +0000)
committerpombredanne <pombredanne>
Sat, 29 Sep 2007 23:26:49 +0000 (23:26 +0000)
net.sourceforge.phpeclipse.xdebug.test/.classpath [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/.cvsignore [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/.project [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/META-INF/MANIFEST.MF [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/build.properties [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.test/src/net/sourceforge/phpeclipse/xdebug/core/Base64Test.java [new file with mode: 0644]

diff --git a/net.sourceforge.phpeclipse.xdebug.test/.classpath b/net.sourceforge.phpeclipse.xdebug.test/.classpath
new file mode 100644 (file)
index 0000000..ce73933
--- /dev/null
@@ -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/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/net.sourceforge.phpeclipse.xdebug.test/.cvsignore b/net.sourceforge.phpeclipse.xdebug.test/.cvsignore
new file mode 100644 (file)
index 0000000..c5e82d7
--- /dev/null
@@ -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 (file)
index 0000000..f491514
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>net.sourceforge.phpeclipse.xdebug.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/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 (file)
index 0000000..9d630b4
--- /dev/null
@@ -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 (file)
index 0000000..74da33a
--- /dev/null
@@ -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 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -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 (file)
index 0000000..300a677
--- /dev/null
@@ -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);
+               }
+       }
+}