| /******************************************************************************* |
| * Copyright (c) 2007, 2008 IBM Corporation and others. |
| * 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.pde.api.tools.comparator.tests; |
| |
| import junit.framework.Test; |
| import junit.framework.TestSuite; |
| |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.pde.api.tools.internal.comparator.DeltaXmlVisitor; |
| import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; |
| import org.eclipse.pde.api.tools.internal.provisional.IApiComponent; |
| import org.eclipse.pde.api.tools.internal.provisional.IApiProfile; |
| import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers; |
| import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator; |
| import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaProcessor; |
| import org.eclipse.pde.api.tools.internal.provisional.comparator.DeltaVisitor; |
| import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; |
| |
| /** |
| * Delta tests for class |
| */ |
| public class ClassDeltaTests extends DeltaTestSetup { |
| |
| public static Test suite() { |
| if (true) return new TestSuite(ClassDeltaTests.class); |
| TestSuite suite = new TestSuite(ClassDeltaTests.class.getName()); |
| suite.addTest(new ClassDeltaTests("test50")); |
| return suite; |
| } |
| |
| public ClassDeltaTests(String name) { |
| super(name); |
| } |
| |
| public String getTestRoot() { |
| return "class"; |
| } |
| |
| /** |
| * delete API method |
| */ |
| public void test1() { |
| deployBundles("test1"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(delta)); |
| } |
| |
| /** |
| * delete API method |
| */ |
| public void test2() { |
| deployBundles("test2"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add constructor with no args in class without constructors |
| */ |
| public void test3() { |
| deployBundles("test3"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Add constructor with one arg in class without constructors |
| */ |
| public void test4() { |
| deployBundles("test4"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove the constructor with no arg in class with only this constructor |
| */ |
| public void test5() { |
| deployBundles("test5"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Add constructor with one arg in class without constructors |
| */ |
| public void test6() { |
| deployBundles("test6"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Delete field |
| */ |
| public void test7() { |
| deployBundles("test7"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Delete clinit |
| */ |
| public void test8() { |
| deployBundles("test8"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CLINIT, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of clinit |
| */ |
| public void test9() { |
| deployBundles("test9"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CLINIT, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Reorder of members |
| */ |
| public void test10() { |
| deployBundles("test10"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Removal of private field |
| */ |
| public void test11() { |
| deployBundles("test11"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of private field |
| */ |
| public void test12() { |
| deployBundles("test12"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Removal of default field |
| */ |
| public void test13() { |
| deployBundles("test13"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of default field |
| */ |
| public void test14() { |
| deployBundles("test14"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Removal of private method |
| */ |
| public void test15() { |
| deployBundles("test15"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of private method |
| */ |
| public void test16() { |
| deployBundles("test16"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Removal of default method |
| */ |
| public void test17() { |
| deployBundles("test17"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of default method |
| */ |
| public void test18() { |
| deployBundles("test18"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Removal of private constructor |
| */ |
| public void test19() { |
| deployBundles("test19"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of private constructor |
| */ |
| public void test20() { |
| deployBundles("test20"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Removal of default constructor |
| */ |
| public void test21() { |
| deployBundles("test21"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of default constructor |
| */ |
| public void test22() { |
| deployBundles("test22"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Abstract to non-abstract |
| */ |
| public void test23() { |
| deployBundles("test23"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ABSTRACT_TO_NON_ABSTRACT, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Non-abstract to abstract |
| */ |
| public void test24() { |
| deployBundles("test24"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.NON_ABSTRACT_TO_ABSTRACT, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * final to non-final |
| */ |
| public void test25() { |
| deployBundles("test25"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FINAL_TO_NON_FINAL, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Non-final to final |
| */ |
| public void test26() { |
| deployBundles("test26"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.NON_FINAL_TO_FINAL, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type parameter - no existing type parameter |
| */ |
| public void test27() { |
| deployBundles("test27"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_PARAMETERS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type parameter - existing type parameters |
| */ |
| public void test28() { |
| deployBundles("test28"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_PARAMETER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type parameter |
| */ |
| public void test29() { |
| deployBundles("test29"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_PARAMETERS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Rename type parameter |
| */ |
| public void test30() { |
| deployBundles("test30"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_PARAMETER_NAME, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * remove type parameter bound |
| */ |
| public void test31() { |
| deployBundles("test31"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CLASS_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INTERFACE_BOUNDS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type parameter bound (interface bound) |
| */ |
| public void test32() { |
| deployBundles("test32"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INTERFACE_BOUNDS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type parameter bound (class bound) |
| */ |
| public void test33() { |
| deployBundles("test33"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CLASS_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| } |
| |
| /** |
| * Decrease access |
| */ |
| public void test34() { |
| deployBundles("test34"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| } |
| |
| /** |
| * Decrease access |
| */ |
| public void test35() { |
| deployBundles("test35"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Decrease access |
| */ |
| public void test36() { |
| deployBundles("test36"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test37() { |
| deployBundles("test37"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test38() { |
| deployBundles("test38"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test39() { |
| deployBundles("test39"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test40() { |
| deployBundles("test40"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test41() { |
| deployBundles("test41"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Increase access |
| */ |
| public void test42() { |
| deployBundles("test42"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INCREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Decrease access |
| */ |
| public void test43() { |
| deployBundles("test43"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Decrease access |
| */ |
| public void test44() { |
| deployBundles("test44"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove class bound from type parameter |
| */ |
| public void test45() { |
| deployBundles("test45"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CLASS_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add interface bound from type parameter |
| */ |
| public void test46() { |
| deployBundles("test46"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INTERFACE_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove interface bound from type parameter |
| */ |
| public void test47() { |
| deployBundles("test47"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INTERFACE_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Reorder interface bound from type parameter |
| */ |
| public void test48() { |
| deployBundles("test48"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.INTERFACE_BOUND, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superclass |
| */ |
| public void test49() { |
| deployBundles("test49"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed indirect superclass |
| */ |
| public void test50() { |
| deployBundles("test50"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 3, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.EXPANDED_SUPERCLASS_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[2]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.EXPANDED_SUPERCLASS_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed indirect superclass |
| */ |
| public void test51() { |
| deployBundles("test51"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 3, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERCLASS_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERCLASS_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[2]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.SUPERCLASS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superinterface |
| */ |
| public void test52() { |
| deployBundles("test52"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superinterface |
| */ |
| public void test53() { |
| deployBundles("test53"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superinterface |
| */ |
| public void test54() { |
| deployBundles("test54"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.EXPANDED_SUPERINTERFACES_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superinterface |
| */ |
| public void test55() { |
| deployBundles("test55"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.EXPANDED_SUPERINTERFACES_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move method up in hierarchy |
| */ |
| public void test56() { |
| deployBundles("test56"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move field up in hierarchy |
| */ |
| public void test57() { |
| deployBundles("test57"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove an anonymous class - no delta |
| */ |
| public void test58() { |
| deployBundles("test58"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Remove a local class - no delta |
| */ |
| public void test59() { |
| deployBundles("test59"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Removal of synthetic method returns no delta |
| */ |
| public void test60() { |
| deployBundles("test60"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Addition of synthetic method returns no delta |
| */ |
| public void test61() { |
| deployBundles("test61"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Addition of a field in a class that cannot be subclassed |
| */ |
| public void test62() { |
| deployBundles("test62"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a field in a class that can be subclassed |
| */ |
| public void test63() { |
| deployBundles("test63"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a new member type |
| */ |
| public void test64() { |
| deployBundles("test64"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove of member types |
| */ |
| public void test65() { |
| deployBundles("test65"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add a member types |
| */ |
| public void test66() { |
| deployBundles("test66"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a member types |
| */ |
| public void test67() { |
| deployBundles("test67"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a field in a class that cannot be subclassed (protected field) |
| */ |
| public void test68() { |
| deployBundles("test68"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a field in a class that cannot be subclassed (protected field) |
| */ |
| public void test69() { |
| deployBundles("test69"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Decrease access (not in the default package) |
| */ |
| public void test70() { |
| deployBundles("test70"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.DECREASE_ACCESS, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move field up in hierarchy (protected field) |
| */ |
| public void test71() { |
| deployBundles("test71"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move method up in hierarchy (protected case) |
| */ |
| public void test72() { |
| deployBundles("test72"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move method up in hierarchy |
| */ |
| public void test73() { |
| deployBundles("test73"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a new member type (not subclass restriction) |
| */ |
| public void test74() { |
| deployBundles("test74"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add a member types |
| */ |
| public void test75() { |
| deployBundles("test75"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Test multiple methods with the same selector |
| */ |
| public void test76() { |
| deployBundles("test76"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| assertTrue("Not empty", delta.isEmpty()); |
| assertTrue("Different from NO_DELTA", delta == ApiComparator.NO_DELTA); |
| } |
| |
| /** |
| * Remove a method with multiple methods with the same selector |
| */ |
| public void test77() { |
| deployBundles("test77"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a method with multiple methods with the same selector |
| */ |
| public void test78() { |
| deployBundles("test78"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move method up in hierarchy |
| */ |
| public void test79() { |
| deployBundles("test79"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Move field up in hierarchy |
| */ |
| public void test80() { |
| deployBundles("test80"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD_MOVED_UP, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a new member type (private) |
| */ |
| public void test81() { |
| deployBundles("test81"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type member (protected) |
| */ |
| public void test82() { |
| deployBundles("test82"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Remove type member (package visibility) |
| */ |
| public void test83() { |
| deployBundles("test83"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type member (private visibility) |
| */ |
| public void test84() { |
| deployBundles("test84"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type member (protected visibility) |
| */ |
| public void test85() { |
| deployBundles("test85"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type member (package visibility) |
| */ |
| public void test86() { |
| deployBundles("test86"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove type member (private visibility) |
| */ |
| public void test87() { |
| deployBundles("test87"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (protected visibility) |
| */ |
| public void test88() { |
| deployBundles("test88"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (private visibility) |
| */ |
| public void test89() { |
| deployBundles("test89"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (package visibility) |
| */ |
| public void test90() { |
| deployBundles("test90"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (protected visibility) |
| */ |
| public void test91() { |
| deployBundles("test91"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (private visibility) |
| */ |
| public void test92() { |
| deployBundles("test92"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (package visibility) |
| */ |
| public void test93() { |
| deployBundles("test93"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (protected visibility) |
| */ |
| public void test94() { |
| deployBundles("test94"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (package visibility) |
| */ |
| public void test95() { |
| deployBundles("test95"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Add type member (private visibility) |
| */ |
| public void test96() { |
| deployBundles("test96"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE_MEMBER, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changed direct superinterface |
| */ |
| public void test97() { |
| deployBundles("test97"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 2, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONTRACTED_SUPERINTERFACES_SET, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Delta visitor test |
| */ |
| public void test98() { |
| deployBundles("test98"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| class MyDeltaVisitor extends DeltaVisitor { |
| StringBuffer buffer; |
| public MyDeltaVisitor() { |
| this.buffer = new StringBuffer(); |
| } |
| @Override |
| public boolean visit(IDelta delta) { |
| if (delta.getChildren().length != 0) { |
| this.buffer.append('['); |
| } else { |
| switch(delta.getKind()) { |
| case IDelta.REMOVED : |
| this.buffer.append("REMOVED"); |
| break; |
| case IDelta.CHANGED : |
| this.buffer.append("CHANGED"); |
| break; |
| } |
| } |
| return super.visit(delta); |
| } |
| @Override |
| public void endVisit(IDelta delta) { |
| if (delta.getChildren().length != 0) { |
| this.buffer.append(']'); |
| } |
| super.endVisit(delta); |
| } |
| } |
| MyDeltaVisitor visitor = new MyDeltaVisitor(); |
| delta.accept(visitor); |
| assertEquals("wrong value", "[REMOVED[CHANGED]]", String.valueOf(visitor.buffer)); |
| } |
| |
| /** |
| * Add static field in subclassable class |
| */ |
| public void test99() { |
| deployBundles("test99"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NOT_EXTEND_RESTRICTION_STATIC, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| try { |
| DeltaXmlVisitor xmlVisitor = new DeltaXmlVisitor(); |
| delta.accept(xmlVisitor); |
| assertNotNull("No XML", xmlVisitor.getXML()); |
| } catch (CoreException e) { |
| ApiPlugin.log(e); |
| } |
| } |
| |
| /** |
| * Delete protected field |
| */ |
| public void test100() { |
| deployBundles("test100"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Removing API type |
| */ |
| public void test101() { |
| deployBundles("test101"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after, VisibilityModifiers.API); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changing visibility of a non-api type |
| */ |
| public void test102() { |
| deployBundles("test102"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after, VisibilityModifiers.PRIVATE); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED_VISIBILITY, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Changing visibility of an api type (checking only private types) |
| */ |
| public void test103() { |
| deployBundles("test103"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after, VisibilityModifiers.PRIVATE); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.TYPE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.API_COMPONENT_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Addition of a field in a class that cannot implicitly be subclassed |
| */ |
| public void test104() { |
| deployBundles("test104"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a method with multiple methods with the same selector |
| * protected method with extend restrictions |
| */ |
| public void test105() { |
| deployBundles("test105"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a method with multiple methods with the same selector |
| * protected method with no extend restrictions |
| */ |
| public void test106() { |
| deployBundles("test106"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a constructor with multiple methods with the same selector |
| * protected constructor with extend restrictions |
| */ |
| public void test107() { |
| deployBundles("test107"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED_EXTEND_RESTRICTION, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| |
| /** |
| * Remove a constructor with multiple methods with the same selector |
| * protected constructor with no extend restrictions |
| */ |
| public void test108() { |
| deployBundles("test108"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.CONSTRUCTOR, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| /** |
| * Add a protected method in a class with extend restriction |
| */ |
| public void test109() { |
| deployBundles("test109"); |
| IApiProfile before = getBeforeState(); |
| IApiProfile after = getAfterState(); |
| IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", beforeApiComponent); |
| IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); |
| assertNotNull("no api component", afterApiComponent); |
| IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 1, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED_NON_VISIBLE, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Is binary compatible", DeltaProcessor.isBinaryCompatible(child)); |
| } |
| } |