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);
--- /dev/null
+/*******************************************************************************
+ * 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<String> list = new ArrayList<String>();
+
+ 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
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);
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;
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);
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);
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);
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;
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);
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);
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);
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;
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);