| /******************************************************************************* |
| * Copyright (c) 2007, 2009 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.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.IDelta; |
| import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline; |
| import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent; |
| |
| /** |
| * Delta tests for annotation |
| */ |
| public class AnnotationDeltaTests extends DeltaTestSetup { |
| |
| public static Test suite() { |
| return new TestSuite(AnnotationDeltaTests.class); |
| // TestSuite suite = new TestSuite(AnnotationDeltaTests.class.getName()); |
| // suite.addTest(new AnnotationDeltaTests("test9")); |
| // return suite; |
| } |
| |
| public AnnotationDeltaTests(String name) { |
| super(name); |
| } |
| |
| public String getTestRoot() { |
| return "annotation"; |
| } |
| |
| /** |
| * Add element to annotation type |
| */ |
| public void test1() { |
| deployBundles("test1"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * remove element to annotation type |
| */ |
| public void test2() { |
| deployBundles("test2"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Add element to annotation type |
| */ |
| public void test3() { |
| deployBundles("test3"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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.METHOD_WITHOUT_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Add elements with all different types |
| */ |
| public void test4() { |
| deployBundles("test4"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 11, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[2]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[3]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[4]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[5]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[6]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[7]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[8]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[9]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[10]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| /** |
| * Add elements with all different types (array) |
| */ |
| public void test5() { |
| deployBundles("test5"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 13, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[2]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[3]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[4]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[5]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[6]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[7]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[8]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[9]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[10]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[11]; |
| assertEquals("Wrong kind", IDelta.ADDED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[12]; |
| assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.METHOD_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Changed default values |
| */ |
| public void test6() { |
| deployBundles("test6"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| assertNotNull("No delta", delta); |
| IDelta[] allLeavesDeltas = collectLeaves(delta); |
| assertEquals("Wrong size", 12, allLeavesDeltas.length); |
| IDelta child = allLeavesDeltas[0]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[1]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[2]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child= allLeavesDeltas[3]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[4]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[5]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[6]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[7]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[8]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[9]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[10]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| child = allLeavesDeltas[11]; |
| assertEquals("Wrong kind", IDelta.CHANGED, child.getKind()); |
| assertEquals("Wrong flag", IDelta.ANNOTATION_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.METHOD_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Remove method with default value |
| */ |
| public void test7() { |
| deployBundles("test7"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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_WITH_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Remove method with no default value |
| */ |
| public void test8() { |
| deployBundles("test8"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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_WITHOUT_DEFAULT_VALUE, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| |
| /** |
| * Add a field |
| */ |
| public void test9() { |
| deployBundles("test9"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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.ALL_VISIBILITIES, null); |
| 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.FIELD, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); |
| } |
| /** |
| * Added deprecation |
| */ |
| public void test10() { |
| deployBundles("test10"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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, null); |
| 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.DEPRECATION, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| } |
| /** |
| * Removed deprecation |
| */ |
| public void test11() { |
| deployBundles("test11"); |
| IApiBaseline before = getBeforeState(); |
| IApiBaseline 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, null); |
| 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.DEPRECATION, child.getFlags()); |
| assertEquals("Wrong element type", IDelta.ANNOTATION_ELEMENT_TYPE, child.getElementType()); |
| assertTrue("Not compatible", DeltaProcessor.isCompatible(child)); |
| } |
| } |