From 3c9cca125ec2faa04c1f9c7e117ec7668ffbfa1e Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 19 May 2010 15:13:01 +0000 Subject: [PATCH] 312839: smaller class files --- .../weaver/patterns/AndOrNotTestCase.java | 5 +-- .../patterns/ConstantPoolSimulator.java | 35 +++++++++++++++++++ .../DeclareErrorOrWarningTestCase.java | 5 +-- .../patterns/ModifiersPatternTestCase.java | 9 +++-- .../weaver/patterns/NamePatternTestCase.java | 5 +-- .../SignaturePatternMatchSpeedTestCase.java | 5 +-- .../patterns/SignaturePatternTestCase.java | 6 ++-- .../patterns/TypePatternListTestCase.java | 5 +-- .../weaver/patterns/TypePatternTestCase.java | 5 +-- .../weaver/patterns/WithinTestCase.java | 6 ++-- 10 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ConstantPoolSimulator.java 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 44d8d2b04..909db8e6a 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java @@ -81,12 +81,13 @@ public class AndOrNotTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { Pointcut p = makePointcut(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ConstantPoolSimulator.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ConstantPoolSimulator.java new file mode 100644 index 000000000..57f971665 --- /dev/null +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ConstantPoolSimulator.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2010 Contributors + * 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: + * Andy Clement (SpringSource) - initial implementation + *******************************************************************************/ +package org.aspectj.weaver.patterns; + +import java.util.ArrayList; +import java.util.List; + +import org.aspectj.weaver.ConstantPoolReader; +import org.aspectj.weaver.ConstantPoolWriter; + +public class ConstantPoolSimulator implements ConstantPoolWriter, ConstantPoolReader { + List list = new ArrayList(); + + public int writeUtf8(String string) { + int i = list.indexOf(string); + if (i != -1) { + return i; + } + list.add(string); + return list.indexOf(string); + } + + public String readUtf8(int constantPoolIndex) { + return list.get(constantPoolIndex); + } + +} \ No newline at end of file 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 444db0c75..ab5f6e6f2 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java @@ -50,12 +50,13 @@ public class DeclareErrorOrWarningTestCase extends TestCase { private void checkSerialization(Declare declare) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); declare.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); Declare newDeclare = Declare.read(in, null); assertEquals("write/read", declare, newDeclare); 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 a82626336..fa561149e 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java @@ -16,8 +16,12 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ConstantPoolReader; +import org.aspectj.weaver.ConstantPoolWriter; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.reflect.ReflectionWorld; @@ -91,12 +95,13 @@ public class ModifiersPatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { ModifiersPattern p = makeModifiersPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); ModifiersPattern newP = ModifiersPattern.read(in); assertEquals("write/read", p, newP); 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 41685973c..e1876cc3b 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java @@ -90,12 +90,13 @@ public class NamePatternTestCase extends TestCase { private void checkSerialization(NamePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); NamePattern newP = NamePattern.read(in); 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 67cf5be98..52f82bfd7 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java @@ -152,12 +152,13 @@ public class SignaturePatternMatchSpeedTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); SignaturePattern newP = SignaturePattern.read(in, null); assertEquals("write/read", p, newP); 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 629e26719..6c6f1f985 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java @@ -16,7 +16,6 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; - import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.Member; import org.aspectj.weaver.TestUtils; @@ -171,12 +170,13 @@ public class SignaturePatternTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); SignaturePattern newP = SignaturePattern.read(in, null); assertEquals("write/read", p, newP); 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 15460d4cf..a141e2b0c 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java @@ -156,12 +156,13 @@ public class TypePatternListTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePatternList p = makeArgumentsPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); TypePatternList newP = TypePatternList.read(in, null); assertEquals("write/read", p, newP); 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 416ccc11c..4654fbd40 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java @@ -248,12 +248,13 @@ public class TypePatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePattern p = makeTypePattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); TypePattern newP = TypePattern.read(in, null); assertEquals("write/read", p, newP); 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 2665b6e96..b8138b067 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java @@ -15,7 +15,6 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; - import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IntMap; @@ -107,12 +106,13 @@ public class WithinTestCase extends PatternsTestCase { private void checkSerialization(Pointcut p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - CompressingDataOutputStream out = new CompressingDataOutputStream(bo); + ConstantPoolSimulator cps = new ConstantPoolSimulator(); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo, cps); p.write(out); out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi, cps); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); -- 2.39.5