diff options
author | aclement <aclement> | 2010-05-18 16:20:12 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-05-18 16:20:12 +0000 |
commit | f4b1f8502f3a64c01374d15e4bf2c2830503c55b (patch) | |
tree | 210765f5943cbdfa0daf727a7790c9a5f23c938a /org.aspectj.matcher/testsrc | |
parent | 3b76e3c76c7518fe2ce1bb97a8201f08e5ef9382 (diff) | |
download | aspectj-f4b1f8502f3a64c01374d15e4bf2c2830503c55b.tar.gz aspectj-f4b1f8502f3a64c01374d15e4bf2c2830503c55b.zip |
change all relevant DataOutputStream usage to use CompressingDataOutputStream
Diffstat (limited to 'org.aspectj.matcher/testsrc')
9 files changed, 71 insertions, 125 deletions
diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java index 70e192afe..44d8d2b04 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java @@ -14,16 +14,11 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.AndPointcut; -import org.aspectj.weaver.patterns.NotPointcut; -import org.aspectj.weaver.patterns.OrPointcut; -import org.aspectj.weaver.patterns.PatternParser; -import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.reflect.ReflectionWorld; /** @@ -86,7 +81,7 @@ public class AndOrNotTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { Pointcut p = makePointcut(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java index bece96251..444db0c75 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java @@ -14,11 +14,11 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import junit.framework.TestCase; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; public class DeclareErrorOrWarningTestCase extends TestCase { @@ -50,7 +50,7 @@ public class DeclareErrorOrWarningTestCase extends TestCase { private void checkSerialization(Declare declare) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); declare.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java index b680376d7..a82626336 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java @@ -14,14 +14,12 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.ModifiersPattern; -import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.reflect.ReflectionWorld; public class ModifiersPatternTestCase extends PatternsTestCase { @@ -93,7 +91,7 @@ public class ModifiersPatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { ModifiersPattern p = makeModifiersPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java index 91858de88..41685973c 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java @@ -10,77 +10,61 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; -import org.aspectj.weaver.VersionedDataInputStream; -import org.aspectj.weaver.patterns.NamePattern; - import junit.framework.TestCase; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.VersionedDataInputStream; + /** * @author hugunin - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. + * + * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable + * and disable the creation of type comments go to Window>Preferences>Java>Code Generation. */ public class NamePatternTestCase extends TestCase { - static String[] matchAll = new String[] { - "*****", - "*" - }; - - - static String[] match1 = new String[] { - "abcde", "abc*", "abcd*", "abcde*", - "*e", "*cde", "*abcde", - "a*e", "ab*e", "abc*de", - "*a*b*c*d*e*", "a*c*e", "a***bcde", - "*d*", - }; - - static String[] match2 = new String[] { - "abababab", - "aba*", "abab*", "abababab*", - "*b", "*ab", "*ababab", "*abababab", - "a*b", "ab*b", "abab*abab", - "*a*b*a*b*a*b*a*b*", "a*****b", "a**b", "ab*b*b", - }; - + static String[] matchAll = new String[] { "*****", "*" }; + + static String[] match1 = new String[] { "abcde", "abc*", "abcd*", "abcde*", "*e", "*cde", "*abcde", "a*e", "ab*e", "abc*de", + "*a*b*c*d*e*", "a*c*e", "a***bcde", "*d*", }; + + static String[] match2 = new String[] { "abababab", "aba*", "abab*", "abababab*", "*b", "*ab", "*ababab", "*abababab", "a*b", + "ab*b", "abab*abab", "*a*b*a*b*a*b*a*b*", "a*****b", "a**b", "ab*b*b", }; + /** * Constructor for PatternTestCase. + * * @param name */ public NamePatternTestCase(String name) { super(name); } - + public void testMatch() { checkMatch("abcde", matchAll, true); checkMatch("abcde", match1, true); checkMatch("abcde", match2, false); - + checkMatch("abababab", matchAll, true); checkMatch("abababab", match1, false); checkMatch("abababab", match2, true); - + } /** * Method checkMatch. + * * @param string * @param matchAll * @param b */ private void checkMatch(String string, String[] patterns, boolean shouldMatch) { - for (int i=0, len=patterns.length; i < len; i++) { + for (int i = 0, len = patterns.length; i < len; i++) { NamePattern p = new NamePattern(patterns[i]); checkMatch(string, p, shouldMatch); } @@ -90,33 +74,31 @@ public class NamePatternTestCase extends TestCase { String msg = "matching " + string + " to " + p; assertEquals(msg, shouldMatch, p.matches(string)); } - - + public void testSerialization() throws IOException { checkSerialization(matchAll); checkSerialization(match1); checkSerialization(match2); } - + private void checkSerialization(String[] patterns) throws IOException { - for (int i=0, len=patterns.length; i < len; i++) { + for (int i = 0, len = patterns.length; i < len; i++) { NamePattern p = new NamePattern(patterns[i]); checkSerialization(p); } } - - + private void checkSerialization(NamePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); - + ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); VersionedDataInputStream in = new VersionedDataInputStream(bi); NamePattern newP = NamePattern.read(in); - - assertEquals("write/read", p, newP); + + assertEquals("write/read", p, newP); } } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java index 02058d898..67cf5be98 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java @@ -14,9 +14,9 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.Member; import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.VersionedDataInputStream; @@ -152,7 +152,7 @@ public class SignaturePatternMatchSpeedTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java index 110137cf9..629e26719 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java @@ -15,9 +15,9 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.Member; import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.VersionedDataInputStream; @@ -61,53 +61,34 @@ public class SignaturePatternTestCase extends PatternsTestCase { checkMatch(makeMethodPat("* *(..) throws *..IOException, !*..Clone*"), NONE, BOTH); checkMatch(makeMethodPat("* *(..) throws !*..IOException"), NO_EXCEPTIONS, M); } -/* - public void testInstanceMethodMatchSpeed() throws IOException { - // Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); - Member objectToString = TestUtils.methodFromString( - "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); - SignaturePattern signaturePattern = makeMethodPat("* *(..))"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - signaturePattern = makeMethodPat("* *())"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - } - - public void testInstanceMethodMatchSpeed2() throws IOException { - // Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); - Member objectToString = TestUtils.methodFromString( - "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); - SignaturePattern signaturePattern = makeMethodPat("!void *(..))"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - } -*/ + /* + * public void testInstanceMethodMatchSpeed() throws IOException { // Member objectToString = + * TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member objectToString = + * TestUtils.methodFromString( + * "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); SignaturePattern + * signaturePattern = makeMethodPat("* *(..))"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new + * FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } long stime = System.currentTimeMillis(); for (int i = 0; i < + * 2000000; i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } long etime = + * System.currentTimeMillis(); System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 + * + * signaturePattern = makeMethodPat("* *())"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new + * FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } stime = System.currentTimeMillis(); for (int i = 0; i < 2000000; + * i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } etime = System.currentTimeMillis(); + * System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 } + * + * public void testInstanceMethodMatchSpeed2() throws IOException { // Member objectToString = + * TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member objectToString = + * TestUtils.methodFromString( + * "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); SignaturePattern + * signaturePattern = makeMethodPat("!void *(..))"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, + * new FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } long stime = System.currentTimeMillis(); for (int i = 0; i < + * 2000000; i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } long etime = + * System.currentTimeMillis(); System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 } + */ public void testInstanceMethodMatch() throws IOException { Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member integerToString = TestUtils.methodFromString("java.lang.String java.lang.Integer.toString()"); @@ -190,7 +171,7 @@ public class SignaturePatternTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java index fd3e8f23e..15460d4cf 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java @@ -14,19 +14,14 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Arrays; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.Bindings; -import org.aspectj.weaver.patterns.PatternParser; -import org.aspectj.weaver.patterns.TestScope; -import org.aspectj.weaver.patterns.TypePattern; -import org.aspectj.weaver.patterns.TypePatternList; import org.aspectj.weaver.reflect.ReflectionWorld; /** @@ -161,7 +156,7 @@ public class TypePatternListTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePatternList p = makeArgumentsPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java index e4f5a4dbf..416ccc11c 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java @@ -14,10 +14,10 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -248,7 +248,7 @@ public class TypePatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePattern p = makeTypePattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java index ccc117b02..2665b6e96 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java @@ -14,10 +14,10 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TestShadow; @@ -25,11 +25,6 @@ import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.Bindings; -import org.aspectj.weaver.patterns.FormalBinding; -import org.aspectj.weaver.patterns.IScope; -import org.aspectj.weaver.patterns.Pointcut; -import org.aspectj.weaver.patterns.SimpleScope; import org.aspectj.weaver.reflect.ReflectionWorld; public class WithinTestCase extends PatternsTestCase { @@ -112,7 +107,7 @@ public class WithinTestCase extends PatternsTestCase { private void checkSerialization(Pointcut p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); |