Added svn props to new files

git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/java/trunk@996824 13f79535-47bb-0310-9956-ffa450edef68
master
Sian January 14 years ago
parent af3a2aeede
commit 1588d78053
  1. 1316
      src/test/java/org/apache/harmony/pack200/tests/PackingOptionsTest.java
  2. 512
      src/test/java/org/apache/harmony/unpack200/tests/NewAttributeBandsTest.java

@ -1,256 +1,256 @@
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0 * The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.harmony.unpack200.tests; package org.apache.harmony.unpack200.tests;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.harmony.pack200.Pack200Exception; import org.apache.harmony.pack200.Pack200Exception;
import org.apache.harmony.unpack200.AttributeLayout; import org.apache.harmony.unpack200.AttributeLayout;
import org.apache.harmony.unpack200.NewAttributeBands; import org.apache.harmony.unpack200.NewAttributeBands;
import org.apache.harmony.unpack200.NewAttributeBands.Call; import org.apache.harmony.unpack200.NewAttributeBands.Call;
import org.apache.harmony.unpack200.NewAttributeBands.Callable; import org.apache.harmony.unpack200.NewAttributeBands.Callable;
import org.apache.harmony.unpack200.NewAttributeBands.Integral; import org.apache.harmony.unpack200.NewAttributeBands.Integral;
import org.apache.harmony.unpack200.NewAttributeBands.Reference; import org.apache.harmony.unpack200.NewAttributeBands.Reference;
import org.apache.harmony.unpack200.NewAttributeBands.Replication; import org.apache.harmony.unpack200.NewAttributeBands.Replication;
import org.apache.harmony.unpack200.NewAttributeBands.Union; import org.apache.harmony.unpack200.NewAttributeBands.Union;
import org.apache.harmony.unpack200.NewAttributeBands.UnionCase; import org.apache.harmony.unpack200.NewAttributeBands.UnionCase;
import org.apache.harmony.unpack200.Segment; import org.apache.harmony.unpack200.Segment;
/** /**
* Tests for unpack200 support for non-predefined attributes * Tests for unpack200 support for non-predefined attributes
*/ */
public class NewAttributeBandsTest extends AbstractBandsTestCase { public class NewAttributeBandsTest extends AbstractBandsTestCase {
public void testEmptyLayout() throws IOException, Pack200Exception { public void testEmptyLayout() throws IOException, Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, "", 25)); AttributeLayout.CONTEXT_CLASS, "", 25));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(0, layoutElements.size()); assertEquals(0, layoutElements.size());
} }
public void testIntegralLayout() throws IOException, Pack200Exception { public void testIntegralLayout() throws IOException, Pack200Exception {
tryIntegral("B"); tryIntegral("B");
tryIntegral("FB"); tryIntegral("FB");
tryIntegral("SB"); tryIntegral("SB");
tryIntegral("H"); tryIntegral("H");
tryIntegral("FH"); tryIntegral("FH");
tryIntegral("SH"); tryIntegral("SH");
tryIntegral("I"); tryIntegral("I");
tryIntegral("FI"); tryIntegral("FI");
tryIntegral("SI"); tryIntegral("SI");
tryIntegral("PB"); tryIntegral("PB");
tryIntegral("OB"); tryIntegral("OB");
tryIntegral("OSB"); tryIntegral("OSB");
tryIntegral("POB"); tryIntegral("POB");
tryIntegral("PH"); tryIntegral("PH");
tryIntegral("OH"); tryIntegral("OH");
tryIntegral("OSH"); tryIntegral("OSH");
tryIntegral("POH"); tryIntegral("POH");
tryIntegral("PI"); tryIntegral("PI");
tryIntegral("OI"); tryIntegral("OI");
tryIntegral("OSI"); tryIntegral("OSI");
tryIntegral("POI"); tryIntegral("POI");
} }
public void tryIntegral(String layout) throws IOException, Pack200Exception { public void tryIntegral(String layout) throws IOException, Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, layout, 25)); AttributeLayout.CONTEXT_CLASS, layout, 25));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size()); assertEquals(1, layoutElements.size());
Integral element = (Integral) layoutElements.get(0); Integral element = (Integral) layoutElements.get(0);
assertEquals(layout, element.getTag()); assertEquals(layout, element.getTag());
} }
public void testReplicationLayout() throws IOException, Pack200Exception { public void testReplicationLayout() throws IOException, Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CLASS, "NH[PHOHRUHRSHH]", 25)); AttributeLayout.CONTEXT_CLASS, "NH[PHOHRUHRSHH]", 25));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size()); assertEquals(1, layoutElements.size());
Replication element = (Replication) layoutElements.get(0); Replication element = (Replication) layoutElements.get(0);
Integral countElement = element.getCountElement(); Integral countElement = element.getCountElement();
assertEquals("H", countElement.getTag()); assertEquals("H", countElement.getTag());
List replicatedElements = element.getLayoutElements(); List replicatedElements = element.getLayoutElements();
assertEquals(5, replicatedElements.size()); assertEquals(5, replicatedElements.size());
Integral firstElement = (Integral) replicatedElements.get(0); Integral firstElement = (Integral) replicatedElements.get(0);
assertEquals("PH", firstElement.getTag()); assertEquals("PH", firstElement.getTag());
Integral secondElement = (Integral) replicatedElements.get(1); Integral secondElement = (Integral) replicatedElements.get(1);
assertEquals("OH", secondElement.getTag()); assertEquals("OH", secondElement.getTag());
Reference thirdElement = (Reference) replicatedElements.get(2); Reference thirdElement = (Reference) replicatedElements.get(2);
assertEquals("RUH", thirdElement.getTag()); assertEquals("RUH", thirdElement.getTag());
Reference fourthElement = (Reference) replicatedElements.get(3); Reference fourthElement = (Reference) replicatedElements.get(3);
assertEquals("RSH", fourthElement.getTag()); assertEquals("RSH", fourthElement.getTag());
Integral fifthElement = (Integral) replicatedElements.get(4); Integral fifthElement = (Integral) replicatedElements.get(4);
assertEquals("H", fifthElement.getTag()); assertEquals("H", fifthElement.getTag());
} }
public void testReferenceLayouts() throws IOException, Pack200Exception { public void testReferenceLayouts() throws IOException, Pack200Exception {
tryReference("KIB"); tryReference("KIB");
tryReference("KIH"); tryReference("KIH");
tryReference("KII"); tryReference("KII");
tryReference("KINH"); tryReference("KINH");
tryReference("KJH"); tryReference("KJH");
tryReference("KDH"); tryReference("KDH");
tryReference("KSH"); tryReference("KSH");
tryReference("KQH"); tryReference("KQH");
tryReference("RCH"); tryReference("RCH");
tryReference("RSH"); tryReference("RSH");
tryReference("RDH"); tryReference("RDH");
tryReference("RFH"); tryReference("RFH");
tryReference("RMH"); tryReference("RMH");
tryReference("RIH"); tryReference("RIH");
tryReference("RUH"); tryReference("RUH");
tryReference("RQH"); tryReference("RQH");
tryReference("RQNH"); tryReference("RQNH");
tryReference("RQNI"); tryReference("RQNI");
} }
private void tryReference(String layout) throws IOException, private void tryReference(String layout) throws IOException,
Pack200Exception { Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CODE, layout, 26)); AttributeLayout.CONTEXT_CODE, layout, 26));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size()); assertEquals(1, layoutElements.size());
Reference element = (Reference) layoutElements.get(0); Reference element = (Reference) layoutElements.get(0);
assertEquals(layout, element.getTag()); assertEquals(layout, element.getTag());
} }
public void testUnionLayout() throws IOException, Pack200Exception { public void testUnionLayout() throws IOException, Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_CODE, AttributeLayout.CONTEXT_CODE,
"TB(55)[FH](23)[]()[RSH]", 26)); "TB(55)[FH](23)[]()[RSH]", 26));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(1, layoutElements.size()); assertEquals(1, layoutElements.size());
Union element = (Union) layoutElements.get(0); Union element = (Union) layoutElements.get(0);
Integral tag = element.getUnionTag(); Integral tag = element.getUnionTag();
assertEquals("B", tag.getTag()); assertEquals("B", tag.getTag());
List unionCases = element.getUnionCases(); List unionCases = element.getUnionCases();
assertEquals(2, unionCases.size()); assertEquals(2, unionCases.size());
UnionCase firstCase = (UnionCase) unionCases.get(0); UnionCase firstCase = (UnionCase) unionCases.get(0);
assertTrue(firstCase.hasTag(55)); assertTrue(firstCase.hasTag(55));
assertFalse(firstCase.hasTag(23)); assertFalse(firstCase.hasTag(23));
List body = firstCase.getBody(); List body = firstCase.getBody();
assertEquals(1, body.size()); assertEquals(1, body.size());
Integral bodyElement = (Integral) body.get(0); Integral bodyElement = (Integral) body.get(0);
assertEquals("FH", bodyElement.getTag()); assertEquals("FH", bodyElement.getTag());
UnionCase secondCase = (UnionCase) unionCases.get(1); UnionCase secondCase = (UnionCase) unionCases.get(1);
assertTrue(secondCase.hasTag(23)); assertTrue(secondCase.hasTag(23));
assertFalse(secondCase.hasTag(55)); assertFalse(secondCase.hasTag(55));
body = secondCase.getBody(); body = secondCase.getBody();
assertEquals(0, body.size()); assertEquals(0, body.size());
List defaultBody = element.getDefaultCaseBody(); List defaultBody = element.getDefaultCaseBody();
assertEquals(1, defaultBody.size()); assertEquals(1, defaultBody.size());
Reference ref = (Reference) defaultBody.get(0); Reference ref = (Reference) defaultBody.get(0);
assertEquals("RSH", ref.getTag()); assertEquals("RSH", ref.getTag());
} }
public void testLayoutWithCalls() throws IOException, Pack200Exception { public void testLayoutWithCalls() throws IOException, Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new MockSegment(),
new AttributeLayout( new AttributeLayout(
"test", "test",
AttributeLayout.CONTEXT_FIELD, AttributeLayout.CONTEXT_FIELD,
"[NH[(1)]][RSH NH[RUH(1)]][TB(66,67,73,83,90)[KIH](68)[KDH](70)[KFH](74)[KJH](99)[RSH](101)[RSH RUH](115)[RUH](91)[NH[(0)]](64)[RSH[RUH(0)]]()[]]", "[NH[(1)]][RSH NH[RUH(1)]][TB(66,67,73,83,90)[KIH](68)[KDH](70)[KFH](74)[KJH](99)[RSH](101)[RSH RUH](115)[RUH](91)[NH[(0)]](64)[RSH[RUH(0)]]()[]]",
26)); 26));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size()); assertEquals(3, layoutElements.size());
Callable firstCallable = (Callable) layoutElements.get(0); Callable firstCallable = (Callable) layoutElements.get(0);
Callable secondCallable = (Callable) layoutElements.get(1); Callable secondCallable = (Callable) layoutElements.get(1);
Callable thirdCallable = (Callable) layoutElements.get(2); Callable thirdCallable = (Callable) layoutElements.get(2);
List firstBody = firstCallable.getBody(); List firstBody = firstCallable.getBody();
assertEquals(1, firstBody.size()); assertEquals(1, firstBody.size());
Replication rep = (Replication) firstBody.get(0); Replication rep = (Replication) firstBody.get(0);
List repBody = rep.getLayoutElements(); List repBody = rep.getLayoutElements();
assertEquals(1, repBody.size()); assertEquals(1, repBody.size());
Call call = (Call) repBody.get(0); Call call = (Call) repBody.get(0);
assertEquals(1, call.getCallableIndex()); assertEquals(1, call.getCallableIndex());
assertEquals(secondCallable, call.getCallable()); assertEquals(secondCallable, call.getCallable());
assertFalse(firstCallable.isBackwardsCallable()); assertFalse(firstCallable.isBackwardsCallable());
assertFalse(secondCallable.isBackwardsCallable()); assertFalse(secondCallable.isBackwardsCallable());
assertFalse(thirdCallable.isBackwardsCallable()); assertFalse(thirdCallable.isBackwardsCallable());
} }
public void testLayoutWithBackwardsCall() throws IOException, public void testLayoutWithBackwardsCall() throws IOException,
Pack200Exception { Pack200Exception {
MockNewAttributeBands newAttributeBands = new MockNewAttributeBands( MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(
new MockSegment(), new AttributeLayout("test", new MockSegment(), new AttributeLayout("test",
AttributeLayout.CONTEXT_METHOD, "[NH[(1)]][KIH][(-1)]", AttributeLayout.CONTEXT_METHOD, "[NH[(1)]][KIH][(-1)]",
20)); 20));
List layoutElements = newAttributeBands.getLayoutElements(); List layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size()); assertEquals(3, layoutElements.size());
Callable firstCallable = (Callable) layoutElements.get(0); Callable firstCallable = (Callable) layoutElements.get(0);
Callable secondCallable = (Callable) layoutElements.get(1); Callable secondCallable = (Callable) layoutElements.get(1);
Callable thirdCallable = (Callable) layoutElements.get(2); Callable thirdCallable = (Callable) layoutElements.get(2);
List thirdBody = thirdCallable.getBody(); List thirdBody = thirdCallable.getBody();
assertEquals(1, thirdBody.size()); assertEquals(1, thirdBody.size());
Call call = (Call) thirdBody.get(0); Call call = (Call) thirdBody.get(0);
assertEquals(secondCallable, call.getCallable()); assertEquals(secondCallable, call.getCallable());
assertTrue(secondCallable.isBackwardsCallable()); assertTrue(secondCallable.isBackwardsCallable());
assertFalse(firstCallable.isBackwardsCallable()); assertFalse(firstCallable.isBackwardsCallable());
assertFalse(thirdCallable.isBackwardsCallable()); assertFalse(thirdCallable.isBackwardsCallable());
newAttributeBands = new MockNewAttributeBands(new MockSegment(), newAttributeBands = new MockNewAttributeBands(new MockSegment(),
new AttributeLayout("test", AttributeLayout.CONTEXT_METHOD, new AttributeLayout("test", AttributeLayout.CONTEXT_METHOD,
"[NH[(1)]][KIH][(-2)]", 20)); "[NH[(1)]][KIH][(-2)]", 20));
layoutElements = newAttributeBands.getLayoutElements(); layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size()); assertEquals(3, layoutElements.size());
firstCallable = (Callable) layoutElements.get(0); firstCallable = (Callable) layoutElements.get(0);
secondCallable = (Callable) layoutElements.get(1); secondCallable = (Callable) layoutElements.get(1);
thirdCallable = (Callable) layoutElements.get(2); thirdCallable = (Callable) layoutElements.get(2);
thirdBody = thirdCallable.getBody(); thirdBody = thirdCallable.getBody();
assertEquals(1, thirdBody.size()); assertEquals(1, thirdBody.size());
call = (Call) thirdBody.get(0); call = (Call) thirdBody.get(0);
assertEquals(firstCallable, call.getCallable()); assertEquals(firstCallable, call.getCallable());
assertTrue(firstCallable.isBackwardsCallable()); assertTrue(firstCallable.isBackwardsCallable());
assertFalse(secondCallable.isBackwardsCallable()); assertFalse(secondCallable.isBackwardsCallable());
assertFalse(thirdCallable.isBackwardsCallable()); assertFalse(thirdCallable.isBackwardsCallable());
newAttributeBands = new MockNewAttributeBands(new MockSegment(), newAttributeBands = new MockNewAttributeBands(new MockSegment(),
new AttributeLayout("test", AttributeLayout.CONTEXT_METHOD, new AttributeLayout("test", AttributeLayout.CONTEXT_METHOD,
"[NH[(1)]][KIH][(0)]", 20)); "[NH[(1)]][KIH][(0)]", 20));
layoutElements = newAttributeBands.getLayoutElements(); layoutElements = newAttributeBands.getLayoutElements();
assertEquals(3, layoutElements.size()); assertEquals(3, layoutElements.size());
firstCallable = (Callable) layoutElements.get(0); firstCallable = (Callable) layoutElements.get(0);
secondCallable = (Callable) layoutElements.get(1); secondCallable = (Callable) layoutElements.get(1);
thirdCallable = (Callable) layoutElements.get(2); thirdCallable = (Callable) layoutElements.get(2);
thirdBody = thirdCallable.getBody(); thirdBody = thirdCallable.getBody();
assertEquals(1, thirdBody.size()); assertEquals(1, thirdBody.size());
call = (Call) thirdBody.get(0); call = (Call) thirdBody.get(0);
assertEquals(thirdCallable, call.getCallable()); assertEquals(thirdCallable, call.getCallable());
assertTrue(thirdCallable.isBackwardsCallable()); assertTrue(thirdCallable.isBackwardsCallable());
assertFalse(firstCallable.isBackwardsCallable()); assertFalse(firstCallable.isBackwardsCallable());
assertFalse(secondCallable.isBackwardsCallable()); assertFalse(secondCallable.isBackwardsCallable());
assertFalse(firstCallable.isBackwardsCallable()); assertFalse(firstCallable.isBackwardsCallable());
} }
private class MockNewAttributeBands extends NewAttributeBands { private class MockNewAttributeBands extends NewAttributeBands {
public MockNewAttributeBands(Segment segment, AttributeLayout layout) public MockNewAttributeBands(Segment segment, AttributeLayout layout)
throws IOException { throws IOException {
super(segment, layout); super(segment, layout);
} }
public List getLayoutElements() { public List getLayoutElements() {
return attributeLayoutElements; return attributeLayoutElements;
} }
} }
} }

Loading…
Cancel
Save