0001: /*
0002: * Copyright (c) 2001-2007, Jean Tessier
0003: * All rights reserved.
0004: *
0005: * Redistribution and use in source and binary forms, with or without
0006: * modification, are permitted provided that the following conditions
0007: * are met:
0008: *
0009: * * Redistributions of source code must retain the above copyright
0010: * notice, this list of conditions and the following disclaimer.
0011: *
0012: * * Redistributions in binary form must reproduce the above copyright
0013: * notice, this list of conditions and the following disclaimer in the
0014: * documentation and/or other materials provided with the distribution.
0015: *
0016: * * Neither the name of Jean Tessier nor the names of his contributors
0017: * may be used to endorse or promote products derived from this software
0018: * without specific prior written permission.
0019: *
0020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
0024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0031: */
0032:
0033: package com.jeantessier.diff;
0034:
0035: import java.io.*;
0036: import java.util.*;
0037:
0038: import junit.framework.*;
0039:
0040: import com.jeantessier.classreader.*;
0041:
0042: public class TestIncompatibleDifferenceStrategyWithPublishedAPI extends
0043: TestCase {
0044: public static final String OLD_PUBLISHED_CLASSPATH = "tests"
0045: + File.separator + "JarJarDiff" + File.separator
0046: + "oldpublished";
0047: public static final String NEW_PUBLISHED_CLASSPATH = "tests"
0048: + File.separator + "JarJarDiff" + File.separator
0049: + "newpublished";
0050:
0051: private static PackageMapper oldPublishedPackages;
0052: private static PackageMapper newPublishedPackages;
0053:
0054: private static ClassfileLoader oldPublishedJar;
0055: private static ClassfileLoader newPublishedJar;
0056:
0057: public static PackageMapper getOldPublishedPackages() {
0058: if (oldPublishedPackages == null) {
0059: oldPublishedPackages = new PackageMapper();
0060: }
0061:
0062: return oldPublishedPackages;
0063: }
0064:
0065: public static PackageMapper getNewPublishedPackages() {
0066: if (newPublishedPackages == null) {
0067: newPublishedPackages = new PackageMapper();
0068: }
0069:
0070: return newPublishedPackages;
0071: }
0072:
0073: public static ClassfileLoader getOldPublishedJar() {
0074: if (oldPublishedJar == null) {
0075: oldPublishedJar = new AggregatingClassfileLoader();
0076: oldPublishedJar.addLoadListener(getOldPublishedPackages());
0077: oldPublishedJar.load(Collections
0078: .singleton(OLD_PUBLISHED_CLASSPATH));
0079: }
0080:
0081: return oldPublishedJar;
0082: }
0083:
0084: public static ClassfileLoader getNewPublishedJar() {
0085: if (newPublishedJar == null) {
0086: newPublishedJar = new AggregatingClassfileLoader();
0087: newPublishedJar.addLoadListener(getNewPublishedPackages());
0088: newPublishedJar.load(Collections
0089: .singleton(NEW_PUBLISHED_CLASSPATH));
0090: }
0091:
0092: return newPublishedJar;
0093: }
0094:
0095: private MockDifferenceStrategy mockStrategy;
0096: private IncompatibleDifferenceStrategy strategy;
0097:
0098: protected void setUp() throws Exception {
0099: super .setUp();
0100:
0101: mockStrategy = new MockDifferenceStrategy(
0102: new NoDifferenceStrategy());
0103: strategy = new IncompatibleDifferenceStrategy(mockStrategy);
0104: }
0105:
0106: /*
0107: * Classes
0108: */
0109:
0110: public void testPublicToPublicClass() {
0111: Classfile oldClass = getOldPublishedJar().getClassfile(
0112: "ModifiedPackage.PublicToPublicClass");
0113: Classfile newClass = getNewPublishedJar().getClassfile(
0114: "ModifiedPackage.PublicToPublicClass");
0115:
0116: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0117:
0118: assertEquals("package", 0, mockStrategy
0119: .getPackageDifferentCount());
0120: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0121: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0122: assertEquals("constant", 0, mockStrategy
0123: .getConstantValueDifferentCount());
0124: assertEquals("method", 0, mockStrategy
0125: .getMethodDifferentCount());
0126: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0127: }
0128:
0129: public void testPublicToPackageClass() {
0130: Classfile oldClass = getOldPublishedJar().getClassfile(
0131: "ModifiedPackage.PublicToPackageClass");
0132: Classfile newClass = getNewPublishedJar().getClassfile(
0133: "ModifiedPackage.PublicToPackageClass");
0134:
0135: assertTrue(strategy.isClassDifferent(oldClass, newClass));
0136:
0137: assertEquals("package", 0, mockStrategy
0138: .getPackageDifferentCount());
0139: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0140: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0141: assertEquals("constant", 0, mockStrategy
0142: .getConstantValueDifferentCount());
0143: assertEquals("method", 0, mockStrategy
0144: .getMethodDifferentCount());
0145: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0146: }
0147:
0148: public void testPackageToPublicClass() {
0149: Classfile oldClass = getOldPublishedJar().getClassfile(
0150: "ModifiedPackage.PackageToPublicClass");
0151: Classfile newClass = getNewPublishedJar().getClassfile(
0152: "ModifiedPackage.PackageToPublicClass");
0153:
0154: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0155:
0156: assertEquals("package", 0, mockStrategy
0157: .getPackageDifferentCount());
0158: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0159: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0160: assertEquals("constant", 0, mockStrategy
0161: .getConstantValueDifferentCount());
0162: assertEquals("method", 0, mockStrategy
0163: .getMethodDifferentCount());
0164: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0165: }
0166:
0167: public void testPackageToPackageClass() {
0168: Classfile oldClass = getOldPublishedJar().getClassfile(
0169: "ModifiedPackage.PackageToPackageClass");
0170: Classfile newClass = getNewPublishedJar().getClassfile(
0171: "ModifiedPackage.PackageToPackageClass");
0172:
0173: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0174:
0175: assertEquals("package", 0, mockStrategy
0176: .getPackageDifferentCount());
0177: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0178: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0179: assertEquals("constant", 0, mockStrategy
0180: .getConstantValueDifferentCount());
0181: assertEquals("method", 0, mockStrategy
0182: .getMethodDifferentCount());
0183: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0184: }
0185:
0186: public void testClassToClassClass() {
0187: Classfile oldClass = getOldPublishedJar().getClassfile(
0188: "ModifiedPackage.ClassToClassClass");
0189: Classfile newClass = getNewPublishedJar().getClassfile(
0190: "ModifiedPackage.ClassToClassClass");
0191:
0192: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0193:
0194: assertEquals("package", 0, mockStrategy
0195: .getPackageDifferentCount());
0196: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0197: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0198: assertEquals("constant", 0, mockStrategy
0199: .getConstantValueDifferentCount());
0200: assertEquals("method", 0, mockStrategy
0201: .getMethodDifferentCount());
0202: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0203: }
0204:
0205: public void testClassToInterfaceClass() {
0206: Classfile oldClass = getOldPublishedJar().getClassfile(
0207: "ModifiedPackage.ClassToInterfaceClass");
0208: Classfile newClass = getNewPublishedJar().getClassfile(
0209: "ModifiedPackage.ClassToInterfaceClass");
0210:
0211: assertTrue(strategy.isClassDifferent(oldClass, newClass));
0212:
0213: assertEquals("package", 0, mockStrategy
0214: .getPackageDifferentCount());
0215: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0216: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0217: assertEquals("constant", 0, mockStrategy
0218: .getConstantValueDifferentCount());
0219: assertEquals("method", 0, mockStrategy
0220: .getMethodDifferentCount());
0221: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0222: }
0223:
0224: public void testInterfaceToClassClass() {
0225: Classfile oldClass = getOldPublishedJar().getClassfile(
0226: "ModifiedPackage.InterfaceToClassClass");
0227: Classfile newClass = getNewPublishedJar().getClassfile(
0228: "ModifiedPackage.InterfaceToClassClass");
0229:
0230: assertTrue(strategy.isClassDifferent(oldClass, newClass));
0231:
0232: assertEquals("package", 0, mockStrategy
0233: .getPackageDifferentCount());
0234: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0235: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0236: assertEquals("constant", 0, mockStrategy
0237: .getConstantValueDifferentCount());
0238: assertEquals("method", 0, mockStrategy
0239: .getMethodDifferentCount());
0240: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0241: }
0242:
0243: public void testInterfaceToInterfaceClass() {
0244: Classfile oldClass = getOldPublishedJar().getClassfile(
0245: "ModifiedPackage.InterfaceToInterfaceClass");
0246: Classfile newClass = getNewPublishedJar().getClassfile(
0247: "ModifiedPackage.InterfaceToInterfaceClass");
0248:
0249: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0250:
0251: assertEquals("package", 0, mockStrategy
0252: .getPackageDifferentCount());
0253: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0254: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0255: assertEquals("constant", 0, mockStrategy
0256: .getConstantValueDifferentCount());
0257: assertEquals("method", 0, mockStrategy
0258: .getMethodDifferentCount());
0259: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0260: }
0261:
0262: public void testConcreteToConcreteClass() {
0263: Classfile oldClass = getOldPublishedJar().getClassfile(
0264: "ModifiedPackage.ConcreteToConcreteClass");
0265: Classfile newClass = getNewPublishedJar().getClassfile(
0266: "ModifiedPackage.ConcreteToConcreteClass");
0267:
0268: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0269:
0270: assertEquals("package", 0, mockStrategy
0271: .getPackageDifferentCount());
0272: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0273: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0274: assertEquals("constant", 0, mockStrategy
0275: .getConstantValueDifferentCount());
0276: assertEquals("method", 0, mockStrategy
0277: .getMethodDifferentCount());
0278: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0279: }
0280:
0281: public void testConcreteToAbstractClass() {
0282: Classfile oldClass = getOldPublishedJar().getClassfile(
0283: "ModifiedPackage.ConcreteToAbstractClass");
0284: Classfile newClass = getNewPublishedJar().getClassfile(
0285: "ModifiedPackage.ConcreteToAbstractClass");
0286:
0287: assertTrue(strategy.isClassDifferent(oldClass, newClass));
0288:
0289: assertEquals("package", 0, mockStrategy
0290: .getPackageDifferentCount());
0291: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0292: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0293: assertEquals("constant", 0, mockStrategy
0294: .getConstantValueDifferentCount());
0295: assertEquals("method", 0, mockStrategy
0296: .getMethodDifferentCount());
0297: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0298: }
0299:
0300: public void testAbstractToConcreteClass() {
0301: Classfile oldClass = getOldPublishedJar().getClassfile(
0302: "ModifiedPackage.AbstractToConcreteClass");
0303: Classfile newClass = getNewPublishedJar().getClassfile(
0304: "ModifiedPackage.AbstractToConcreteClass");
0305:
0306: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0307:
0308: assertEquals("package", 0, mockStrategy
0309: .getPackageDifferentCount());
0310: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0311: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0312: assertEquals("constant", 0, mockStrategy
0313: .getConstantValueDifferentCount());
0314: assertEquals("method", 0, mockStrategy
0315: .getMethodDifferentCount());
0316: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0317: }
0318:
0319: public void testAbstractToAbstractClass() {
0320: Classfile oldClass = getOldPublishedJar().getClassfile(
0321: "ModifiedPackage.AbstractToAbstractClass");
0322: Classfile newClass = getNewPublishedJar().getClassfile(
0323: "ModifiedPackage.AbstractToAbstractClass");
0324:
0325: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0326:
0327: assertEquals("package", 0, mockStrategy
0328: .getPackageDifferentCount());
0329: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0330: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0331: assertEquals("constant", 0, mockStrategy
0332: .getConstantValueDifferentCount());
0333: assertEquals("method", 0, mockStrategy
0334: .getMethodDifferentCount());
0335: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0336: }
0337:
0338: public void testNonFinalToNonFinalClass() {
0339: Classfile oldClass = getOldPublishedJar().getClassfile(
0340: "ModifiedPackage.NonFinalToNonFinalClass");
0341: Classfile newClass = getNewPublishedJar().getClassfile(
0342: "ModifiedPackage.NonFinalToNonFinalClass");
0343:
0344: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0345:
0346: assertEquals("package", 0, mockStrategy
0347: .getPackageDifferentCount());
0348: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0349: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0350: assertEquals("constant", 0, mockStrategy
0351: .getConstantValueDifferentCount());
0352: assertEquals("method", 0, mockStrategy
0353: .getMethodDifferentCount());
0354: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0355: }
0356:
0357: public void testNonFinalToFinalClass() {
0358: Classfile oldClass = getOldPublishedJar().getClassfile(
0359: "ModifiedPackage.NonFinalToFinalClass");
0360: Classfile newClass = getNewPublishedJar().getClassfile(
0361: "ModifiedPackage.NonFinalToFinalClass");
0362:
0363: assertTrue(strategy.isClassDifferent(oldClass, newClass));
0364:
0365: assertEquals("package", 0, mockStrategy
0366: .getPackageDifferentCount());
0367: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0368: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0369: assertEquals("constant", 0, mockStrategy
0370: .getConstantValueDifferentCount());
0371: assertEquals("method", 0, mockStrategy
0372: .getMethodDifferentCount());
0373: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0374: }
0375:
0376: public void testFinalToNonFinalClass() {
0377: Classfile oldClass = getOldPublishedJar().getClassfile(
0378: "ModifiedPackage.FinalToNonFinalClass");
0379: Classfile newClass = getNewPublishedJar().getClassfile(
0380: "ModifiedPackage.FinalToNonFinalClass");
0381:
0382: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0383:
0384: assertEquals("package", 0, mockStrategy
0385: .getPackageDifferentCount());
0386: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0387: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0388: assertEquals("constant", 0, mockStrategy
0389: .getConstantValueDifferentCount());
0390: assertEquals("method", 0, mockStrategy
0391: .getMethodDifferentCount());
0392: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0393: }
0394:
0395: public void testFinalToFinalClass() {
0396: Classfile oldClass = getOldPublishedJar().getClassfile(
0397: "ModifiedPackage.FinalToFinalClass");
0398: Classfile newClass = getNewPublishedJar().getClassfile(
0399: "ModifiedPackage.FinalToFinalClass");
0400:
0401: assertFalse(strategy.isClassDifferent(oldClass, newClass));
0402:
0403: assertEquals("package", 0, mockStrategy
0404: .getPackageDifferentCount());
0405: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0406: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0407: assertEquals("constant", 0, mockStrategy
0408: .getConstantValueDifferentCount());
0409: assertEquals("method", 0, mockStrategy
0410: .getMethodDifferentCount());
0411: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0412: }
0413:
0414: /*
0415: * Fields
0416: */
0417:
0418: public void testPrivateToPrivateField() {
0419: Field_info oldField = getOldPublishedJar().getClassfile(
0420: "ModifiedPackage.ModifiedClass").getField(
0421: "privateToPrivateField");
0422: Field_info newField = getNewPublishedJar().getClassfile(
0423: "ModifiedPackage.ModifiedClass").getField(
0424: "privateToPrivateField");
0425:
0426: assertFalse(strategy.isFieldDifferent(oldField, newField));
0427:
0428: assertEquals("package", 0, mockStrategy
0429: .getPackageDifferentCount());
0430: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0431: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0432: assertEquals("constant", 0, mockStrategy
0433: .getConstantValueDifferentCount());
0434: assertEquals("method", 0, mockStrategy
0435: .getMethodDifferentCount());
0436: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0437: }
0438:
0439: public void testPrivateToProtectedField() {
0440: Field_info oldField = getOldPublishedJar().getClassfile(
0441: "ModifiedPackage.ModifiedClass").getField(
0442: "privateToProtectedField");
0443: Field_info newField = getNewPublishedJar().getClassfile(
0444: "ModifiedPackage.ModifiedClass").getField(
0445: "privateToProtectedField");
0446:
0447: assertFalse(strategy.isFieldDifferent(oldField, newField));
0448:
0449: assertEquals("package", 0, mockStrategy
0450: .getPackageDifferentCount());
0451: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0452: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0453: assertEquals("constant", 0, mockStrategy
0454: .getConstantValueDifferentCount());
0455: assertEquals("method", 0, mockStrategy
0456: .getMethodDifferentCount());
0457: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0458: }
0459:
0460: public void testPrivateToPackageField() {
0461: Field_info oldField = getOldPublishedJar().getClassfile(
0462: "ModifiedPackage.ModifiedClass").getField(
0463: "privateToPackagedField");
0464: Field_info newField = getNewPublishedJar().getClassfile(
0465: "ModifiedPackage.ModifiedClass").getField(
0466: "privateToPackageField");
0467:
0468: assertFalse(strategy.isFieldDifferent(oldField, newField));
0469:
0470: assertEquals("package", 0, mockStrategy
0471: .getPackageDifferentCount());
0472: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0473: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0474: assertEquals("constant", 0, mockStrategy
0475: .getConstantValueDifferentCount());
0476: assertEquals("method", 0, mockStrategy
0477: .getMethodDifferentCount());
0478: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0479: }
0480:
0481: public void testPrivateToPublicField() {
0482: Field_info oldField = getOldPublishedJar().getClassfile(
0483: "ModifiedPackage.ModifiedClass").getField(
0484: "privateToPublicField");
0485: Field_info newField = getNewPublishedJar().getClassfile(
0486: "ModifiedPackage.ModifiedClass").getField(
0487: "privateToPublicField");
0488:
0489: assertFalse(strategy.isFieldDifferent(oldField, newField));
0490:
0491: assertEquals("package", 0, mockStrategy
0492: .getPackageDifferentCount());
0493: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0494: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0495: assertEquals("constant", 0, mockStrategy
0496: .getConstantValueDifferentCount());
0497: assertEquals("method", 0, mockStrategy
0498: .getMethodDifferentCount());
0499: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0500: }
0501:
0502: public void testProtectedToPrivateField() {
0503: Field_info oldField = getOldPublishedJar().getClassfile(
0504: "ModifiedPackage.ModifiedClass").getField(
0505: "protectedToPrivateField");
0506: Field_info newField = getNewPublishedJar().getClassfile(
0507: "ModifiedPackage.ModifiedClass").getField(
0508: "protectedToPrivateField");
0509:
0510: assertTrue(strategy.isFieldDifferent(oldField, newField));
0511:
0512: assertEquals("package", 0, mockStrategy
0513: .getPackageDifferentCount());
0514: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0515: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0516: assertEquals("constant", 0, mockStrategy
0517: .getConstantValueDifferentCount());
0518: assertEquals("method", 0, mockStrategy
0519: .getMethodDifferentCount());
0520: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0521: }
0522:
0523: public void testProtectedToProtectedField() {
0524: Field_info oldField = getOldPublishedJar().getClassfile(
0525: "ModifiedPackage.ModifiedClass").getField(
0526: "protectedToProtectedField");
0527: Field_info newField = getNewPublishedJar().getClassfile(
0528: "ModifiedPackage.ModifiedClass").getField(
0529: "protectedToProtectedField");
0530:
0531: assertFalse(strategy.isFieldDifferent(oldField, newField));
0532:
0533: assertEquals("package", 0, mockStrategy
0534: .getPackageDifferentCount());
0535: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0536: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0537: assertEquals("constant", 0, mockStrategy
0538: .getConstantValueDifferentCount());
0539: assertEquals("method", 0, mockStrategy
0540: .getMethodDifferentCount());
0541: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0542: }
0543:
0544: public void testProtectedToPackageField() {
0545: Field_info oldField = getOldPublishedJar().getClassfile(
0546: "ModifiedPackage.ModifiedClass").getField(
0547: "protectedToPackageField");
0548: Field_info newField = getNewPublishedJar().getClassfile(
0549: "ModifiedPackage.ModifiedClass").getField(
0550: "protectedToPackageField");
0551:
0552: assertTrue(strategy.isFieldDifferent(oldField, newField));
0553:
0554: assertEquals("package", 0, mockStrategy
0555: .getPackageDifferentCount());
0556: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0557: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0558: assertEquals("constant", 0, mockStrategy
0559: .getConstantValueDifferentCount());
0560: assertEquals("method", 0, mockStrategy
0561: .getMethodDifferentCount());
0562: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0563: }
0564:
0565: public void testProtectedToPublicField() {
0566: Field_info oldField = getOldPublishedJar().getClassfile(
0567: "ModifiedPackage.ModifiedClass").getField(
0568: "protectedToPublicField");
0569: Field_info newField = getNewPublishedJar().getClassfile(
0570: "ModifiedPackage.ModifiedClass").getField(
0571: "protectedToPublicField");
0572:
0573: assertFalse(strategy.isFieldDifferent(oldField, newField));
0574:
0575: assertEquals("package", 0, mockStrategy
0576: .getPackageDifferentCount());
0577: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0578: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0579: assertEquals("constant", 0, mockStrategy
0580: .getConstantValueDifferentCount());
0581: assertEquals("method", 0, mockStrategy
0582: .getMethodDifferentCount());
0583: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0584: }
0585:
0586: public void testPackageToPrivateField() {
0587: Field_info oldField = getOldPublishedJar().getClassfile(
0588: "ModifiedPackage.ModifiedClass").getField(
0589: "packageToPrivateField");
0590: Field_info newField = getNewPublishedJar().getClassfile(
0591: "ModifiedPackage.ModifiedClass").getField(
0592: "packageToPrivateField");
0593:
0594: assertFalse(strategy.isFieldDifferent(oldField, newField));
0595:
0596: assertEquals("package", 0, mockStrategy
0597: .getPackageDifferentCount());
0598: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0599: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0600: assertEquals("constant", 0, mockStrategy
0601: .getConstantValueDifferentCount());
0602: assertEquals("method", 0, mockStrategy
0603: .getMethodDifferentCount());
0604: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0605: }
0606:
0607: public void testPackageToProtectedField() {
0608: Field_info oldField = getOldPublishedJar().getClassfile(
0609: "ModifiedPackage.ModifiedClass").getField(
0610: "packageToProtectedField");
0611: Field_info newField = getNewPublishedJar().getClassfile(
0612: "ModifiedPackage.ModifiedClass").getField(
0613: "packageToProtectedField");
0614:
0615: assertFalse(strategy.isFieldDifferent(oldField, newField));
0616:
0617: assertEquals("package", 0, mockStrategy
0618: .getPackageDifferentCount());
0619: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0620: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0621: assertEquals("constant", 0, mockStrategy
0622: .getConstantValueDifferentCount());
0623: assertEquals("method", 0, mockStrategy
0624: .getMethodDifferentCount());
0625: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0626: }
0627:
0628: public void testPackageToPackageField() {
0629: Field_info oldField = getOldPublishedJar().getClassfile(
0630: "ModifiedPackage.ModifiedClass").getField(
0631: "packageToPackagedField");
0632: Field_info newField = getNewPublishedJar().getClassfile(
0633: "ModifiedPackage.ModifiedClass").getField(
0634: "packageToPackageField");
0635:
0636: assertFalse(strategy.isFieldDifferent(oldField, newField));
0637:
0638: assertEquals("package", 0, mockStrategy
0639: .getPackageDifferentCount());
0640: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0641: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0642: assertEquals("constant", 0, mockStrategy
0643: .getConstantValueDifferentCount());
0644: assertEquals("method", 0, mockStrategy
0645: .getMethodDifferentCount());
0646: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0647: }
0648:
0649: public void testPackageToPublicField() {
0650: Field_info oldField = getOldPublishedJar().getClassfile(
0651: "ModifiedPackage.ModifiedClass").getField(
0652: "packageToPublicField");
0653: Field_info newField = getNewPublishedJar().getClassfile(
0654: "ModifiedPackage.ModifiedClass").getField(
0655: "packageToPublicField");
0656:
0657: assertFalse(strategy.isFieldDifferent(oldField, newField));
0658:
0659: assertEquals("package", 0, mockStrategy
0660: .getPackageDifferentCount());
0661: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0662: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0663: assertEquals("constant", 0, mockStrategy
0664: .getConstantValueDifferentCount());
0665: assertEquals("method", 0, mockStrategy
0666: .getMethodDifferentCount());
0667: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0668: }
0669:
0670: public void testPublicToPrivateField() {
0671: Field_info oldField = getOldPublishedJar().getClassfile(
0672: "ModifiedPackage.ModifiedClass").getField(
0673: "publicToPrivateField");
0674: Field_info newField = getNewPublishedJar().getClassfile(
0675: "ModifiedPackage.ModifiedClass").getField(
0676: "publicToPrivateField");
0677:
0678: assertTrue(strategy.isFieldDifferent(oldField, newField));
0679:
0680: assertEquals("package", 0, mockStrategy
0681: .getPackageDifferentCount());
0682: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0683: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0684: assertEquals("constant", 0, mockStrategy
0685: .getConstantValueDifferentCount());
0686: assertEquals("method", 0, mockStrategy
0687: .getMethodDifferentCount());
0688: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0689: }
0690:
0691: public void testPublicToProtectedField() {
0692: Field_info oldField = getOldPublishedJar().getClassfile(
0693: "ModifiedPackage.ModifiedClass").getField(
0694: "publicToProtectedField");
0695: Field_info newField = getNewPublishedJar().getClassfile(
0696: "ModifiedPackage.ModifiedClass").getField(
0697: "publicToProtectedField");
0698:
0699: assertTrue(strategy.isFieldDifferent(oldField, newField));
0700:
0701: assertEquals("package", 0, mockStrategy
0702: .getPackageDifferentCount());
0703: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0704: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0705: assertEquals("constant", 0, mockStrategy
0706: .getConstantValueDifferentCount());
0707: assertEquals("method", 0, mockStrategy
0708: .getMethodDifferentCount());
0709: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0710: }
0711:
0712: public void testPublicToPackageField() {
0713: Field_info oldField = getOldPublishedJar().getClassfile(
0714: "ModifiedPackage.ModifiedClass").getField(
0715: "publicToPackageField");
0716: Field_info newField = getNewPublishedJar().getClassfile(
0717: "ModifiedPackage.ModifiedClass").getField(
0718: "publicToPackageField");
0719:
0720: assertTrue(strategy.isFieldDifferent(oldField, newField));
0721:
0722: assertEquals("package", 0, mockStrategy
0723: .getPackageDifferentCount());
0724: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0725: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0726: assertEquals("constant", 0, mockStrategy
0727: .getConstantValueDifferentCount());
0728: assertEquals("method", 0, mockStrategy
0729: .getMethodDifferentCount());
0730: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0731: }
0732:
0733: public void testPublicToPublicField() {
0734: Field_info oldField = getOldPublishedJar().getClassfile(
0735: "ModifiedPackage.ModifiedClass").getField(
0736: "publicToPublicField");
0737: Field_info newField = getNewPublishedJar().getClassfile(
0738: "ModifiedPackage.ModifiedClass").getField(
0739: "publicToPublicField");
0740:
0741: assertFalse(strategy.isFieldDifferent(oldField, newField));
0742:
0743: assertEquals("package", 0, mockStrategy
0744: .getPackageDifferentCount());
0745: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0746: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0747: assertEquals("constant", 0, mockStrategy
0748: .getConstantValueDifferentCount());
0749: assertEquals("method", 0, mockStrategy
0750: .getMethodDifferentCount());
0751: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0752: }
0753:
0754: public void testNonFinalToNonFinalField() {
0755: Field_info oldField = getOldPublishedJar().getClassfile(
0756: "ModifiedPackage.ModifiedClass").getField(
0757: "nonFinalToNonFinalField");
0758: Field_info newField = getNewPublishedJar().getClassfile(
0759: "ModifiedPackage.ModifiedClass").getField(
0760: "nonFinalToNonFinalField");
0761:
0762: assertFalse(strategy.isFieldDifferent(oldField, newField));
0763:
0764: assertEquals("package", 0, mockStrategy
0765: .getPackageDifferentCount());
0766: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0767: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0768: assertEquals("constant", 0, mockStrategy
0769: .getConstantValueDifferentCount());
0770: assertEquals("method", 0, mockStrategy
0771: .getMethodDifferentCount());
0772: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0773: }
0774:
0775: public void testNonFinalToFinalField() {
0776: Field_info oldField = getOldPublishedJar().getClassfile(
0777: "ModifiedPackage.ModifiedClass").getField(
0778: "nonFinalToFinalField");
0779: Field_info newField = getNewPublishedJar().getClassfile(
0780: "ModifiedPackage.ModifiedClass").getField(
0781: "nonFinalToFinalField");
0782:
0783: assertTrue(strategy.isFieldDifferent(oldField, newField));
0784:
0785: assertEquals("package", 0, mockStrategy
0786: .getPackageDifferentCount());
0787: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0788: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0789: assertEquals("constant", 0, mockStrategy
0790: .getConstantValueDifferentCount());
0791: assertEquals("method", 0, mockStrategy
0792: .getMethodDifferentCount());
0793: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0794: }
0795:
0796: public void testFinalToNonFinalField() {
0797: Field_info oldField = getOldPublishedJar().getClassfile(
0798: "ModifiedPackage.ModifiedClass").getField(
0799: "finalToNonFinalField");
0800: Field_info newField = getNewPublishedJar().getClassfile(
0801: "ModifiedPackage.ModifiedClass").getField(
0802: "finalToNonFinalField");
0803:
0804: assertFalse(strategy.isFieldDifferent(oldField, newField));
0805:
0806: assertEquals("package", 0, mockStrategy
0807: .getPackageDifferentCount());
0808: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0809: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0810: assertEquals("constant", 0, mockStrategy
0811: .getConstantValueDifferentCount());
0812: assertEquals("method", 0, mockStrategy
0813: .getMethodDifferentCount());
0814: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0815: }
0816:
0817: public void testFinalToFinalField() {
0818: Field_info oldField = getOldPublishedJar().getClassfile(
0819: "ModifiedPackage.ModifiedClass").getField(
0820: "finalToFinalField");
0821: Field_info newField = getNewPublishedJar().getClassfile(
0822: "ModifiedPackage.ModifiedClass").getField(
0823: "finalToFinalField");
0824:
0825: assertFalse(strategy.isFieldDifferent(oldField, newField));
0826:
0827: assertEquals("package", 0, mockStrategy
0828: .getPackageDifferentCount());
0829: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0830: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0831: assertEquals("constant", 0, mockStrategy
0832: .getConstantValueDifferentCount());
0833: assertEquals("method", 0, mockStrategy
0834: .getMethodDifferentCount());
0835: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0836: }
0837:
0838: public void testTypeToSameTypeField() {
0839: Field_info oldField = getOldPublishedJar().getClassfile(
0840: "ModifiedPackage.ModifiedClass").getField(
0841: "typeToSameTypeField");
0842: Field_info newField = getNewPublishedJar().getClassfile(
0843: "ModifiedPackage.ModifiedClass").getField(
0844: "typeToSameTypeField");
0845:
0846: assertFalse(strategy.isFieldDifferent(oldField, newField));
0847:
0848: assertEquals("package", 0, mockStrategy
0849: .getPackageDifferentCount());
0850: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0851: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0852: assertEquals("constant", 0, mockStrategy
0853: .getConstantValueDifferentCount());
0854: assertEquals("method", 0, mockStrategy
0855: .getMethodDifferentCount());
0856: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0857: }
0858:
0859: public void testTypeToDifferentTypeField() {
0860: Field_info oldField = getOldPublishedJar().getClassfile(
0861: "ModifiedPackage.ModifiedClass").getField(
0862: "typeToDifferentTypeField");
0863: Field_info newField = getNewPublishedJar().getClassfile(
0864: "ModifiedPackage.ModifiedClass").getField(
0865: "typeToDifferentTypeField");
0866:
0867: assertTrue(strategy.isFieldDifferent(oldField, newField));
0868:
0869: assertEquals("package", 0, mockStrategy
0870: .getPackageDifferentCount());
0871: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0872: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
0873: assertEquals("constant", 0, mockStrategy
0874: .getConstantValueDifferentCount());
0875: assertEquals("method", 0, mockStrategy
0876: .getMethodDifferentCount());
0877: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0878: }
0879:
0880: /*
0881: * Constructors
0882: */
0883:
0884: public void testPrivateToPrivateConstructor() {
0885: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0886: "ModifiedPackage.ModifiedClass").getMethod(
0887: "ModifiedClass(int)");
0888: Method_info newConstructor = getNewPublishedJar().getClassfile(
0889: "ModifiedPackage.ModifiedClass").getMethod(
0890: "ModifiedClass(int)");
0891:
0892: assertFalse(strategy.isMethodDifferent(oldConstructor,
0893: newConstructor));
0894:
0895: assertEquals("package", 0, mockStrategy
0896: .getPackageDifferentCount());
0897: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0898: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
0899: assertEquals("constant", 0, mockStrategy
0900: .getConstantValueDifferentCount());
0901: assertEquals("method", 0, mockStrategy
0902: .getMethodDifferentCount());
0903: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0904: }
0905:
0906: public void testPrivateToProtectedConstructor() {
0907: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0908: "ModifiedPackage.ModifiedClass").getMethod(
0909: "ModifiedClass(long");
0910: Method_info newConstructor = getNewPublishedJar().getClassfile(
0911: "ModifiedPackage.ModifiedClass").getMethod(
0912: "ModifiedClass(long)");
0913:
0914: assertFalse(strategy.isMethodDifferent(oldConstructor,
0915: newConstructor));
0916:
0917: assertEquals("package", 0, mockStrategy
0918: .getPackageDifferentCount());
0919: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0920: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
0921: assertEquals("constant", 0, mockStrategy
0922: .getConstantValueDifferentCount());
0923: assertEquals("method", 0, mockStrategy
0924: .getMethodDifferentCount());
0925: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0926: }
0927:
0928: public void testPrivateToPackageConstructor() {
0929: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0930: "ModifiedPackage.ModifiedClass").getMethod(
0931: "ModifiedClass(float)");
0932: Method_info newConstructor = getNewPublishedJar().getClassfile(
0933: "ModifiedPackage.ModifiedClass").getMethod(
0934: "ModifiedClass(float)");
0935:
0936: assertFalse(strategy.isMethodDifferent(oldConstructor,
0937: newConstructor));
0938:
0939: assertEquals("package", 0, mockStrategy
0940: .getPackageDifferentCount());
0941: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0942: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
0943: assertEquals("constant", 0, mockStrategy
0944: .getConstantValueDifferentCount());
0945: assertEquals("method", 0, mockStrategy
0946: .getMethodDifferentCount());
0947: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0948: }
0949:
0950: public void testPrivateToPublicConstructor() {
0951: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0952: "ModifiedPackage.ModifiedClass").getMethod(
0953: "ModifiedClass(double)");
0954: Method_info newConstructor = getNewPublishedJar().getClassfile(
0955: "ModifiedPackage.ModifiedClass").getMethod(
0956: "ModifiedClass(double)");
0957:
0958: assertFalse(strategy.isMethodDifferent(oldConstructor,
0959: newConstructor));
0960:
0961: assertEquals("package", 0, mockStrategy
0962: .getPackageDifferentCount());
0963: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0964: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
0965: assertEquals("constant", 0, mockStrategy
0966: .getConstantValueDifferentCount());
0967: assertEquals("method", 0, mockStrategy
0968: .getMethodDifferentCount());
0969: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0970: }
0971:
0972: public void testProtectedToPrivateConstructor() {
0973: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0974: "ModifiedPackage.ModifiedClass").getMethod(
0975: "ModifiedClass(int, int)");
0976: Method_info newConstructor = getNewPublishedJar().getClassfile(
0977: "ModifiedPackage.ModifiedClass").getMethod(
0978: "ModifiedClass(int, int)");
0979:
0980: assertTrue(strategy.isMethodDifferent(oldConstructor,
0981: newConstructor));
0982:
0983: assertEquals("package", 0, mockStrategy
0984: .getPackageDifferentCount());
0985: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
0986: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
0987: assertEquals("constant", 0, mockStrategy
0988: .getConstantValueDifferentCount());
0989: assertEquals("method", 0, mockStrategy
0990: .getMethodDifferentCount());
0991: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
0992: }
0993:
0994: public void testProtectedToProtectedConstructor() {
0995: Method_info oldConstructor = getOldPublishedJar().getClassfile(
0996: "ModifiedPackage.ModifiedClass").getMethod(
0997: "ModifiedClass(long, long)");
0998: Method_info newConstructor = getNewPublishedJar().getClassfile(
0999: "ModifiedPackage.ModifiedClass").getMethod(
1000: "ModifiedClass(long, long)");
1001:
1002: assertFalse(strategy.isMethodDifferent(oldConstructor,
1003: newConstructor));
1004:
1005: assertEquals("package", 0, mockStrategy
1006: .getPackageDifferentCount());
1007: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1008: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1009: assertEquals("constant", 0, mockStrategy
1010: .getConstantValueDifferentCount());
1011: assertEquals("method", 0, mockStrategy
1012: .getMethodDifferentCount());
1013: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1014: }
1015:
1016: public void testProtectedToPackageConstructor() {
1017: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1018: "ModifiedPackage.ModifiedClass").getMethod(
1019: "ModifiedClass(float, float)");
1020: Method_info newConstructor = getNewPublishedJar().getClassfile(
1021: "ModifiedPackage.ModifiedClass").getMethod(
1022: "ModifiedClass(float, float)");
1023:
1024: assertTrue(strategy.isMethodDifferent(oldConstructor,
1025: newConstructor));
1026:
1027: assertEquals("package", 0, mockStrategy
1028: .getPackageDifferentCount());
1029: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1030: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1031: assertEquals("constant", 0, mockStrategy
1032: .getConstantValueDifferentCount());
1033: assertEquals("method", 0, mockStrategy
1034: .getMethodDifferentCount());
1035: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1036: }
1037:
1038: public void testProtectedToPublicConstructor() {
1039: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1040: "ModifiedPackage.ModifiedClass").getMethod(
1041: "ModifiedClass(double, double)");
1042: Method_info newConstructor = getNewPublishedJar().getClassfile(
1043: "ModifiedPackage.ModifiedClass").getMethod(
1044: "ModifiedClass(double, double)");
1045:
1046: assertFalse(strategy.isMethodDifferent(oldConstructor,
1047: newConstructor));
1048:
1049: assertEquals("package", 0, mockStrategy
1050: .getPackageDifferentCount());
1051: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1052: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1053: assertEquals("constant", 0, mockStrategy
1054: .getConstantValueDifferentCount());
1055: assertEquals("method", 0, mockStrategy
1056: .getMethodDifferentCount());
1057: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1058: }
1059:
1060: public void testPackageToPrivateConstructor() {
1061: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1062: "ModifiedPackage.ModifiedClass").getMethod(
1063: "ModifiedClass(int, int, int)");
1064: Method_info newConstructor = getNewPublishedJar().getClassfile(
1065: "ModifiedPackage.ModifiedClass").getMethod(
1066: "ModifiedClass(int, int, int)");
1067:
1068: assertFalse(strategy.isMethodDifferent(oldConstructor,
1069: newConstructor));
1070:
1071: assertEquals("package", 0, mockStrategy
1072: .getPackageDifferentCount());
1073: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1074: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1075: assertEquals("constant", 0, mockStrategy
1076: .getConstantValueDifferentCount());
1077: assertEquals("method", 0, mockStrategy
1078: .getMethodDifferentCount());
1079: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1080: }
1081:
1082: public void testPackageToProtectedConstructor() {
1083: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1084: "ModifiedPackage.ModifiedClass").getMethod(
1085: "ModifiedClass(long, long, long)");
1086: Method_info newConstructor = getNewPublishedJar().getClassfile(
1087: "ModifiedPackage.ModifiedClass").getMethod(
1088: "ModifiedClass(long, long, long)");
1089:
1090: assertFalse(strategy.isMethodDifferent(oldConstructor,
1091: newConstructor));
1092:
1093: assertEquals("package", 0, mockStrategy
1094: .getPackageDifferentCount());
1095: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1096: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1097: assertEquals("constant", 0, mockStrategy
1098: .getConstantValueDifferentCount());
1099: assertEquals("method", 0, mockStrategy
1100: .getMethodDifferentCount());
1101: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1102: }
1103:
1104: public void testPackageToPackageConstructor() {
1105: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1106: "ModifiedPackage.ModifiedClass").getMethod(
1107: "ModifiedClass(float, float, float)");
1108: Method_info newConstructor = getNewPublishedJar().getClassfile(
1109: "ModifiedPackage.ModifiedClass").getMethod(
1110: "ModifiedClass(float, float, float)");
1111:
1112: assertFalse(strategy.isMethodDifferent(oldConstructor,
1113: newConstructor));
1114:
1115: assertEquals("package", 0, mockStrategy
1116: .getPackageDifferentCount());
1117: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1118: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1119: assertEquals("constant", 0, mockStrategy
1120: .getConstantValueDifferentCount());
1121: assertEquals("method", 0, mockStrategy
1122: .getMethodDifferentCount());
1123: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1124: }
1125:
1126: public void testPackageToPublicConstructor() {
1127: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1128: "ModifiedPackage.ModifiedClass").getMethod(
1129: "ModifiedClass(double, double, double)");
1130: Method_info newConstructor = getNewPublishedJar().getClassfile(
1131: "ModifiedPackage.ModifiedClass").getMethod(
1132: "ModifiedClass(double, double, double)");
1133:
1134: assertFalse(strategy.isMethodDifferent(oldConstructor,
1135: newConstructor));
1136:
1137: assertEquals("package", 0, mockStrategy
1138: .getPackageDifferentCount());
1139: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1140: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1141: assertEquals("constant", 0, mockStrategy
1142: .getConstantValueDifferentCount());
1143: assertEquals("method", 0, mockStrategy
1144: .getMethodDifferentCount());
1145: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1146: }
1147:
1148: public void testPublicToPrivateConstructor() {
1149: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1150: "ModifiedPackage.ModifiedClass").getMethod(
1151: "ModifiedClass(int, int, int, int)");
1152: Method_info newConstructor = getNewPublishedJar().getClassfile(
1153: "ModifiedPackage.ModifiedClass").getMethod(
1154: "ModifiedClass(int, int, int, int)");
1155:
1156: assertTrue(strategy.isMethodDifferent(oldConstructor,
1157: newConstructor));
1158:
1159: assertEquals("package", 0, mockStrategy
1160: .getPackageDifferentCount());
1161: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1162: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1163: assertEquals("constant", 0, mockStrategy
1164: .getConstantValueDifferentCount());
1165: assertEquals("method", 0, mockStrategy
1166: .getMethodDifferentCount());
1167: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1168: }
1169:
1170: public void testPublicToProtectedConstructor() {
1171: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1172: "ModifiedPackage.ModifiedClass").getMethod(
1173: "ModifiedClass(long, long, long, long)");
1174: Method_info newConstructor = getNewPublishedJar().getClassfile(
1175: "ModifiedPackage.ModifiedClass").getMethod(
1176: "ModifiedClass(long, long, long, long)");
1177:
1178: assertTrue(strategy.isMethodDifferent(oldConstructor,
1179: newConstructor));
1180:
1181: assertEquals("package", 0, mockStrategy
1182: .getPackageDifferentCount());
1183: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1184: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1185: assertEquals("constant", 0, mockStrategy
1186: .getConstantValueDifferentCount());
1187: assertEquals("method", 0, mockStrategy
1188: .getMethodDifferentCount());
1189: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1190: }
1191:
1192: public void testPublicToPackageConstructor() {
1193: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1194: "ModifiedPackage.ModifiedClass").getMethod(
1195: "ModifiedClass(float, float, float, float)");
1196: Method_info newConstructor = getNewPublishedJar().getClassfile(
1197: "ModifiedPackage.ModifiedClass").getMethod(
1198: "ModifiedClass(float, float, float, float)");
1199:
1200: assertTrue(strategy.isMethodDifferent(oldConstructor,
1201: newConstructor));
1202:
1203: assertEquals("package", 0, mockStrategy
1204: .getPackageDifferentCount());
1205: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1206: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1207: assertEquals("constant", 0, mockStrategy
1208: .getConstantValueDifferentCount());
1209: assertEquals("method", 0, mockStrategy
1210: .getMethodDifferentCount());
1211: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1212: }
1213:
1214: public void testPublicToPublicConstructor() {
1215: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1216: "ModifiedPackage.ModifiedClass").getMethod(
1217: "ModifiedClass(double, double, double, double)");
1218: Method_info newConstructor = getNewPublishedJar().getClassfile(
1219: "ModifiedPackage.ModifiedClass").getMethod(
1220: "ModifiedClass(double, double, double, double)");
1221:
1222: assertFalse(strategy.isMethodDifferent(oldConstructor,
1223: newConstructor));
1224:
1225: assertEquals("package", 0, mockStrategy
1226: .getPackageDifferentCount());
1227: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1228: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1229: assertEquals("constant", 0, mockStrategy
1230: .getConstantValueDifferentCount());
1231: assertEquals("method", 0, mockStrategy
1232: .getMethodDifferentCount());
1233: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1234: }
1235:
1236: public void testThrowsToSameThrowsConstructor() {
1237: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1238: "ModifiedPackage.ModifiedClass").getMethod(
1239: "ModifiedClass(java.lang.Object)");
1240: Method_info newConstructor = getNewPublishedJar().getClassfile(
1241: "ModifiedPackage.ModifiedClass").getMethod(
1242: "ModifiedClass(java.lang.Object)");
1243:
1244: assertFalse(strategy.isMethodDifferent(oldConstructor,
1245: newConstructor));
1246:
1247: assertEquals("package", 0, mockStrategy
1248: .getPackageDifferentCount());
1249: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1250: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1251: assertEquals("constant", 0, mockStrategy
1252: .getConstantValueDifferentCount());
1253: assertEquals("method", 0, mockStrategy
1254: .getMethodDifferentCount());
1255: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1256: }
1257:
1258: public void testThrowsToDifferentThrowsConstructor() {
1259: Method_info oldConstructor = getOldPublishedJar().getClassfile(
1260: "ModifiedPackage.ModifiedClass").getMethod(
1261: "ModifiedClass(java.lang.Object, java.lang.Object)");
1262: Method_info newConstructor = getNewPublishedJar().getClassfile(
1263: "ModifiedPackage.ModifiedClass").getMethod(
1264: "ModifiedClass(java.lang.Object, java.lang.Object)");
1265:
1266: assertTrue(strategy.isMethodDifferent(oldConstructor,
1267: newConstructor));
1268:
1269: assertEquals("package", 0, mockStrategy
1270: .getPackageDifferentCount());
1271: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1272: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1273: assertEquals("constant", 0, mockStrategy
1274: .getConstantValueDifferentCount());
1275: assertEquals("method", 0, mockStrategy
1276: .getMethodDifferentCount());
1277: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1278: }
1279:
1280: /*
1281: * Methods
1282: */
1283:
1284: public void testPrivateToPrivateMethod() {
1285: Method_info oldMethod = getOldPublishedJar().getClassfile(
1286: "ModifiedPackage.ModifiedClass").getMethod(
1287: "privateToPrivateMethod()");
1288: Method_info newMethod = getNewPublishedJar().getClassfile(
1289: "ModifiedPackage.ModifiedClass").getMethod(
1290: "privateToPrivateMethod()");
1291:
1292: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1293:
1294: assertEquals("package", 0, mockStrategy
1295: .getPackageDifferentCount());
1296: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1297: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1298: assertEquals("constant", 0, mockStrategy
1299: .getConstantValueDifferentCount());
1300: assertEquals("method", 0, mockStrategy
1301: .getMethodDifferentCount());
1302: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1303: }
1304:
1305: public void testPrivateToProtectedMethod() {
1306: Method_info oldMethod = getOldPublishedJar().getClassfile(
1307: "ModifiedPackage.ModifiedClass").getMethod(
1308: "privateToProtectedMethod()");
1309: Method_info newMethod = getNewPublishedJar().getClassfile(
1310: "ModifiedPackage.ModifiedClass").getMethod(
1311: "privateToProtectedMethod()");
1312:
1313: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1314:
1315: assertEquals("package", 0, mockStrategy
1316: .getPackageDifferentCount());
1317: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1318: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1319: assertEquals("constant", 0, mockStrategy
1320: .getConstantValueDifferentCount());
1321: assertEquals("method", 0, mockStrategy
1322: .getMethodDifferentCount());
1323: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1324: }
1325:
1326: public void testPrivateToPackageMethod() {
1327: Method_info oldMethod = getOldPublishedJar().getClassfile(
1328: "ModifiedPackage.ModifiedClass").getMethod(
1329: "privateToPackagedMethod()");
1330: Method_info newMethod = getNewPublishedJar().getClassfile(
1331: "ModifiedPackage.ModifiedClass").getMethod(
1332: "privateToPackageMethod()");
1333:
1334: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1335:
1336: assertEquals("package", 0, mockStrategy
1337: .getPackageDifferentCount());
1338: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1339: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1340: assertEquals("constant", 0, mockStrategy
1341: .getConstantValueDifferentCount());
1342: assertEquals("method", 0, mockStrategy
1343: .getMethodDifferentCount());
1344: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1345: }
1346:
1347: public void testPrivateToPublicMethod() {
1348: Method_info oldMethod = getOldPublishedJar().getClassfile(
1349: "ModifiedPackage.ModifiedClass").getMethod(
1350: "privateToPublicMethod()");
1351: Method_info newMethod = getNewPublishedJar().getClassfile(
1352: "ModifiedPackage.ModifiedClass").getMethod(
1353: "privateToPublicMethod()");
1354:
1355: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1356:
1357: assertEquals("package", 0, mockStrategy
1358: .getPackageDifferentCount());
1359: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1360: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1361: assertEquals("constant", 0, mockStrategy
1362: .getConstantValueDifferentCount());
1363: assertEquals("method", 0, mockStrategy
1364: .getMethodDifferentCount());
1365: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1366: }
1367:
1368: public void testProtectedToPrivateMethod() {
1369: Method_info oldMethod = getOldPublishedJar().getClassfile(
1370: "ModifiedPackage.ModifiedClass").getMethod(
1371: "protectedToPrivateMethod()");
1372: Method_info newMethod = getNewPublishedJar().getClassfile(
1373: "ModifiedPackage.ModifiedClass").getMethod(
1374: "protectedToPrivateMethod()");
1375:
1376: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1377:
1378: assertEquals("package", 0, mockStrategy
1379: .getPackageDifferentCount());
1380: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1381: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1382: assertEquals("constant", 0, mockStrategy
1383: .getConstantValueDifferentCount());
1384: assertEquals("method", 0, mockStrategy
1385: .getMethodDifferentCount());
1386: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1387: }
1388:
1389: public void testProtectedToProtectedMethod() {
1390: Method_info oldMethod = getOldPublishedJar().getClassfile(
1391: "ModifiedPackage.ModifiedClass").getMethod(
1392: "protectedToProtectedMethod()");
1393: Method_info newMethod = getNewPublishedJar().getClassfile(
1394: "ModifiedPackage.ModifiedClass").getMethod(
1395: "protectedToProtectedMethod()");
1396:
1397: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1398:
1399: assertEquals("package", 0, mockStrategy
1400: .getPackageDifferentCount());
1401: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1402: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1403: assertEquals("constant", 0, mockStrategy
1404: .getConstantValueDifferentCount());
1405: assertEquals("method", 0, mockStrategy
1406: .getMethodDifferentCount());
1407: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1408: }
1409:
1410: public void testProtectedToPackageMethod() {
1411: Method_info oldMethod = getOldPublishedJar().getClassfile(
1412: "ModifiedPackage.ModifiedClass").getMethod(
1413: "protectedToPackageMethod()");
1414: Method_info newMethod = getNewPublishedJar().getClassfile(
1415: "ModifiedPackage.ModifiedClass").getMethod(
1416: "protectedToPackageMethod()");
1417:
1418: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1419:
1420: assertEquals("package", 0, mockStrategy
1421: .getPackageDifferentCount());
1422: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1423: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1424: assertEquals("constant", 0, mockStrategy
1425: .getConstantValueDifferentCount());
1426: assertEquals("method", 0, mockStrategy
1427: .getMethodDifferentCount());
1428: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1429: }
1430:
1431: public void testProtectedToPublicMethod() {
1432: Method_info oldMethod = getOldPublishedJar().getClassfile(
1433: "ModifiedPackage.ModifiedClass").getMethod(
1434: "protectedToPublicMethod()");
1435: Method_info newMethod = getNewPublishedJar().getClassfile(
1436: "ModifiedPackage.ModifiedClass").getMethod(
1437: "protectedToPublicMethod()");
1438:
1439: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1440:
1441: assertEquals("package", 0, mockStrategy
1442: .getPackageDifferentCount());
1443: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1444: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1445: assertEquals("constant", 0, mockStrategy
1446: .getConstantValueDifferentCount());
1447: assertEquals("method", 0, mockStrategy
1448: .getMethodDifferentCount());
1449: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1450: }
1451:
1452: public void testPackageToPrivateMethod() {
1453: Method_info oldMethod = getOldPublishedJar().getClassfile(
1454: "ModifiedPackage.ModifiedClass").getMethod(
1455: "packageToPrivateMethod()");
1456: Method_info newMethod = getNewPublishedJar().getClassfile(
1457: "ModifiedPackage.ModifiedClass").getMethod(
1458: "packageToPrivateMethod()");
1459:
1460: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1461:
1462: assertEquals("package", 0, mockStrategy
1463: .getPackageDifferentCount());
1464: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1465: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1466: assertEquals("constant", 0, mockStrategy
1467: .getConstantValueDifferentCount());
1468: assertEquals("method", 0, mockStrategy
1469: .getMethodDifferentCount());
1470: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1471: }
1472:
1473: public void testPackageToProtectedMethod() {
1474: Method_info oldMethod = getOldPublishedJar().getClassfile(
1475: "ModifiedPackage.ModifiedClass").getMethod(
1476: "packageToProtectedMethod()");
1477: Method_info newMethod = getNewPublishedJar().getClassfile(
1478: "ModifiedPackage.ModifiedClass").getMethod(
1479: "packageToProtectedMethod()");
1480:
1481: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1482:
1483: assertEquals("package", 0, mockStrategy
1484: .getPackageDifferentCount());
1485: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1486: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1487: assertEquals("constant", 0, mockStrategy
1488: .getConstantValueDifferentCount());
1489: assertEquals("method", 0, mockStrategy
1490: .getMethodDifferentCount());
1491: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1492: }
1493:
1494: public void testPackageToPackageMethod() {
1495: Method_info oldMethod = getOldPublishedJar().getClassfile(
1496: "ModifiedPackage.ModifiedClass").getMethod(
1497: "packageToPackagedMethod()");
1498: Method_info newMethod = getNewPublishedJar().getClassfile(
1499: "ModifiedPackage.ModifiedClass").getMethod(
1500: "packageToPackageMethod()");
1501:
1502: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1503:
1504: assertEquals("package", 0, mockStrategy
1505: .getPackageDifferentCount());
1506: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1507: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1508: assertEquals("constant", 0, mockStrategy
1509: .getConstantValueDifferentCount());
1510: assertEquals("method", 0, mockStrategy
1511: .getMethodDifferentCount());
1512: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1513: }
1514:
1515: public void testPackageToPublicMethod() {
1516: Method_info oldMethod = getOldPublishedJar().getClassfile(
1517: "ModifiedPackage.ModifiedClass").getMethod(
1518: "packageToPublicMethod()");
1519: Method_info newMethod = getNewPublishedJar().getClassfile(
1520: "ModifiedPackage.ModifiedClass").getMethod(
1521: "packageToPublicMethod()");
1522:
1523: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1524:
1525: assertEquals("package", 0, mockStrategy
1526: .getPackageDifferentCount());
1527: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1528: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1529: assertEquals("constant", 0, mockStrategy
1530: .getConstantValueDifferentCount());
1531: assertEquals("method", 0, mockStrategy
1532: .getMethodDifferentCount());
1533: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1534: }
1535:
1536: public void testPublicToPrivateMethod() {
1537: Method_info oldMethod = getOldPublishedJar().getClassfile(
1538: "ModifiedPackage.ModifiedClass").getMethod(
1539: "publicToPrivateMethod()");
1540: Method_info newMethod = getNewPublishedJar().getClassfile(
1541: "ModifiedPackage.ModifiedClass").getMethod(
1542: "publicToPrivateMethod()");
1543:
1544: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1545:
1546: assertEquals("package", 0, mockStrategy
1547: .getPackageDifferentCount());
1548: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1549: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1550: assertEquals("constant", 0, mockStrategy
1551: .getConstantValueDifferentCount());
1552: assertEquals("method", 0, mockStrategy
1553: .getMethodDifferentCount());
1554: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1555: }
1556:
1557: public void testPublicToProtectedMethod() {
1558: Method_info oldMethod = getOldPublishedJar().getClassfile(
1559: "ModifiedPackage.ModifiedClass").getMethod(
1560: "publicToProtectedMethod()");
1561: Method_info newMethod = getNewPublishedJar().getClassfile(
1562: "ModifiedPackage.ModifiedClass").getMethod(
1563: "publicToProtectedMethod()");
1564:
1565: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1566:
1567: assertEquals("package", 0, mockStrategy
1568: .getPackageDifferentCount());
1569: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1570: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1571: assertEquals("constant", 0, mockStrategy
1572: .getConstantValueDifferentCount());
1573: assertEquals("method", 0, mockStrategy
1574: .getMethodDifferentCount());
1575: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1576: }
1577:
1578: public void testPublicToPackageMethod() {
1579: Method_info oldMethod = getOldPublishedJar().getClassfile(
1580: "ModifiedPackage.ModifiedClass").getMethod(
1581: "publicToPackageMethod()");
1582: Method_info newMethod = getNewPublishedJar().getClassfile(
1583: "ModifiedPackage.ModifiedClass").getMethod(
1584: "publicToPackageMethod()");
1585:
1586: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1587:
1588: assertEquals("package", 0, mockStrategy
1589: .getPackageDifferentCount());
1590: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1591: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1592: assertEquals("constant", 0, mockStrategy
1593: .getConstantValueDifferentCount());
1594: assertEquals("method", 0, mockStrategy
1595: .getMethodDifferentCount());
1596: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1597: }
1598:
1599: public void testPublicToPublicMethod() {
1600: Method_info oldMethod = getOldPublishedJar().getClassfile(
1601: "ModifiedPackage.ModifiedClass").getMethod(
1602: "publicToPublicMethod()");
1603: Method_info newMethod = getNewPublishedJar().getClassfile(
1604: "ModifiedPackage.ModifiedClass").getMethod(
1605: "publicToPublicMethod()");
1606:
1607: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1608:
1609: assertEquals("package", 0, mockStrategy
1610: .getPackageDifferentCount());
1611: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1612: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1613: assertEquals("constant", 0, mockStrategy
1614: .getConstantValueDifferentCount());
1615: assertEquals("method", 0, mockStrategy
1616: .getMethodDifferentCount());
1617: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1618: }
1619:
1620: public void testConcreteToConcreteMethod() {
1621: Method_info oldMethod = getOldPublishedJar().getClassfile(
1622: "ModifiedPackage.ModifiedClass").getMethod(
1623: "concreteToConcreteMethod()");
1624: Method_info newMethod = getNewPublishedJar().getClassfile(
1625: "ModifiedPackage.ModifiedClass").getMethod(
1626: "concreteToConcreteMethod()");
1627:
1628: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1629:
1630: assertEquals("package", 0, mockStrategy
1631: .getPackageDifferentCount());
1632: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1633: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1634: assertEquals("constant", 0, mockStrategy
1635: .getConstantValueDifferentCount());
1636: assertEquals("method", 0, mockStrategy
1637: .getMethodDifferentCount());
1638: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1639: }
1640:
1641: public void testConcreteToAbstractMethod() {
1642: Method_info oldMethod = getOldPublishedJar().getClassfile(
1643: "ModifiedPackage.ModifiedClass").getMethod(
1644: "concreteToAbstractMethod()");
1645: Method_info newMethod = getNewPublishedJar().getClassfile(
1646: "ModifiedPackage.ModifiedClass").getMethod(
1647: "concreteToAbstractMethod()");
1648:
1649: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1650:
1651: assertEquals("package", 0, mockStrategy
1652: .getPackageDifferentCount());
1653: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1654: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1655: assertEquals("constant", 0, mockStrategy
1656: .getConstantValueDifferentCount());
1657: assertEquals("method", 0, mockStrategy
1658: .getMethodDifferentCount());
1659: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1660: }
1661:
1662: public void testAbstractToConcreteMethod() {
1663: Method_info oldMethod = getOldPublishedJar().getClassfile(
1664: "ModifiedPackage.ModifiedClass").getMethod(
1665: "abstractToConcreteMethod()");
1666: Method_info newMethod = getNewPublishedJar().getClassfile(
1667: "ModifiedPackage.ModifiedClass").getMethod(
1668: "abstractToConcreteMethod()");
1669:
1670: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1671:
1672: assertEquals("package", 0, mockStrategy
1673: .getPackageDifferentCount());
1674: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1675: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1676: assertEquals("constant", 0, mockStrategy
1677: .getConstantValueDifferentCount());
1678: assertEquals("method", 0, mockStrategy
1679: .getMethodDifferentCount());
1680: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1681: }
1682:
1683: public void testAbstractToAbstractMethod() {
1684: Method_info oldMethod = getOldPublishedJar().getClassfile(
1685: "ModifiedPackage.ModifiedClass").getMethod(
1686: "abstractToAbstractMethod()");
1687: Method_info newMethod = getNewPublishedJar().getClassfile(
1688: "ModifiedPackage.ModifiedClass").getMethod(
1689: "abstractToAbstractMethod()");
1690:
1691: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1692:
1693: assertEquals("package", 0, mockStrategy
1694: .getPackageDifferentCount());
1695: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1696: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1697: assertEquals("constant", 0, mockStrategy
1698: .getConstantValueDifferentCount());
1699: assertEquals("method", 0, mockStrategy
1700: .getMethodDifferentCount());
1701: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1702: }
1703:
1704: public void testNonStaticToNonStaticMethod() {
1705: Method_info oldMethod = getOldPublishedJar().getClassfile(
1706: "ModifiedPackage.ModifiedClass").getMethod(
1707: "nonStaticToNonStaticMethod()");
1708: Method_info newMethod = getNewPublishedJar().getClassfile(
1709: "ModifiedPackage.ModifiedClass").getMethod(
1710: "nonStaticToNonStaticMethod()");
1711:
1712: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1713:
1714: assertEquals("package", 0, mockStrategy
1715: .getPackageDifferentCount());
1716: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1717: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1718: assertEquals("constant", 0, mockStrategy
1719: .getConstantValueDifferentCount());
1720: assertEquals("method", 0, mockStrategy
1721: .getMethodDifferentCount());
1722: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1723: }
1724:
1725: public void testNonStaticToStaticMethod() {
1726: Method_info oldMethod = getOldPublishedJar().getClassfile(
1727: "ModifiedPackage.ModifiedClass").getMethod(
1728: "nonStaticToStaticMethod()");
1729: Method_info newMethod = getNewPublishedJar().getClassfile(
1730: "ModifiedPackage.ModifiedClass").getMethod(
1731: "nonStaticToStaticMethod()");
1732:
1733: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1734:
1735: assertEquals("package", 0, mockStrategy
1736: .getPackageDifferentCount());
1737: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1738: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1739: assertEquals("constant", 0, mockStrategy
1740: .getConstantValueDifferentCount());
1741: assertEquals("method", 0, mockStrategy
1742: .getMethodDifferentCount());
1743: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1744: }
1745:
1746: public void testStaticToNonStaticMethod() {
1747: Method_info oldMethod = getOldPublishedJar().getClassfile(
1748: "ModifiedPackage.ModifiedClass").getMethod(
1749: "staticToNonStaticMethod()");
1750: Method_info newMethod = getNewPublishedJar().getClassfile(
1751: "ModifiedPackage.ModifiedClass").getMethod(
1752: "staticToNonStaticMethod()");
1753:
1754: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1755:
1756: assertEquals("package", 0, mockStrategy
1757: .getPackageDifferentCount());
1758: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1759: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1760: assertEquals("constant", 0, mockStrategy
1761: .getConstantValueDifferentCount());
1762: assertEquals("method", 0, mockStrategy
1763: .getMethodDifferentCount());
1764: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1765: }
1766:
1767: public void testStaticToStaticMethod() {
1768: Method_info oldMethod = getOldPublishedJar().getClassfile(
1769: "ModifiedPackage.ModifiedClass").getMethod(
1770: "staticToStaticMethod()");
1771: Method_info newMethod = getNewPublishedJar().getClassfile(
1772: "ModifiedPackage.ModifiedClass").getMethod(
1773: "staticToStaticMethod()");
1774:
1775: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1776:
1777: assertEquals("package", 0, mockStrategy
1778: .getPackageDifferentCount());
1779: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1780: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1781: assertEquals("constant", 0, mockStrategy
1782: .getConstantValueDifferentCount());
1783: assertEquals("method", 0, mockStrategy
1784: .getMethodDifferentCount());
1785: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1786: }
1787:
1788: public void testNonFinalToNonFinalMethod() {
1789: Method_info oldMethod = getOldPublishedJar().getClassfile(
1790: "ModifiedPackage.ModifiedClass").getMethod(
1791: "nonFinalToNonFinalMethod()");
1792: Method_info newMethod = getNewPublishedJar().getClassfile(
1793: "ModifiedPackage.ModifiedClass").getMethod(
1794: "nonFinalToNonFinalMethod()");
1795:
1796: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1797:
1798: assertEquals("package", 0, mockStrategy
1799: .getPackageDifferentCount());
1800: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1801: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1802: assertEquals("constant", 0, mockStrategy
1803: .getConstantValueDifferentCount());
1804: assertEquals("method", 0, mockStrategy
1805: .getMethodDifferentCount());
1806: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1807: }
1808:
1809: public void testNonFinalToFinalMethod() {
1810: Method_info oldMethod = getOldPublishedJar().getClassfile(
1811: "ModifiedPackage.ModifiedClass").getMethod(
1812: "nonFinalToFinalMethod()");
1813: Method_info newMethod = getNewPublishedJar().getClassfile(
1814: "ModifiedPackage.ModifiedClass").getMethod(
1815: "nonFinalToFinalMethod()");
1816:
1817: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1818:
1819: assertEquals("package", 0, mockStrategy
1820: .getPackageDifferentCount());
1821: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1822: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1823: assertEquals("constant", 0, mockStrategy
1824: .getConstantValueDifferentCount());
1825: assertEquals("method", 0, mockStrategy
1826: .getMethodDifferentCount());
1827: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1828: }
1829:
1830: public void testFinalToNonFinalMethod() {
1831: Method_info oldMethod = getOldPublishedJar().getClassfile(
1832: "ModifiedPackage.ModifiedClass").getMethod(
1833: "finalToNonFinalMethod()");
1834: Method_info newMethod = getNewPublishedJar().getClassfile(
1835: "ModifiedPackage.ModifiedClass").getMethod(
1836: "finalToNonFinalMethod()");
1837:
1838: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1839:
1840: assertEquals("package", 0, mockStrategy
1841: .getPackageDifferentCount());
1842: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1843: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1844: assertEquals("constant", 0, mockStrategy
1845: .getConstantValueDifferentCount());
1846: assertEquals("method", 0, mockStrategy
1847: .getMethodDifferentCount());
1848: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1849: }
1850:
1851: public void testFinalToFinalMethod() {
1852: Method_info oldMethod = getOldPublishedJar().getClassfile(
1853: "ModifiedPackage.ModifiedClass").getMethod(
1854: "finalToFinalMethod()");
1855: Method_info newMethod = getNewPublishedJar().getClassfile(
1856: "ModifiedPackage.ModifiedClass").getMethod(
1857: "finalToFinalMethod()");
1858:
1859: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1860:
1861: assertEquals("package", 0, mockStrategy
1862: .getPackageDifferentCount());
1863: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1864: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1865: assertEquals("constant", 0, mockStrategy
1866: .getConstantValueDifferentCount());
1867: assertEquals("method", 0, mockStrategy
1868: .getMethodDifferentCount());
1869: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1870: }
1871:
1872: public void testReturnTypeToSameReturnTypeMethod() {
1873: Method_info oldMethod = getOldPublishedJar().getClassfile(
1874: "ModifiedPackage.ModifiedClass").getMethod(
1875: "returnTypeToSameReturnTypeMethod()");
1876: Method_info newMethod = getNewPublishedJar().getClassfile(
1877: "ModifiedPackage.ModifiedClass").getMethod(
1878: "returnTypeToSameReturnTypeMethod()");
1879:
1880: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1881:
1882: assertEquals("package", 0, mockStrategy
1883: .getPackageDifferentCount());
1884: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1885: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1886: assertEquals("constant", 0, mockStrategy
1887: .getConstantValueDifferentCount());
1888: assertEquals("method", 0, mockStrategy
1889: .getMethodDifferentCount());
1890: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1891: }
1892:
1893: public void testReturnTypeToDifferentReturnTypeMethod() {
1894: Method_info oldMethod = getOldPublishedJar().getClassfile(
1895: "ModifiedPackage.ModifiedClass").getMethod(
1896: "returnTypeToDifferentReturnTypeMethod()");
1897: Method_info newMethod = getNewPublishedJar().getClassfile(
1898: "ModifiedPackage.ModifiedClass").getMethod(
1899: "returnTypeToDifferentReturnTypeMethod()");
1900:
1901: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1902:
1903: assertEquals("package", 0, mockStrategy
1904: .getPackageDifferentCount());
1905: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1906: assertEquals("field", 0, mockStrategy.getFieldDifferentCount());
1907: assertEquals("constant", 0, mockStrategy
1908: .getConstantValueDifferentCount());
1909: assertEquals("method", 0, mockStrategy
1910: .getMethodDifferentCount());
1911: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1912: }
1913:
1914: public void testThrowsToSameThrowsMethod() {
1915: Method_info oldMethod = getOldPublishedJar().getClassfile(
1916: "ModifiedPackage.ModifiedClass").getMethod(
1917: "throwsToSameThrowsMethod()");
1918: Method_info newMethod = getNewPublishedJar().getClassfile(
1919: "ModifiedPackage.ModifiedClass").getMethod(
1920: "throwsToSameThrowsMethod()");
1921:
1922: assertFalse(strategy.isMethodDifferent(oldMethod, newMethod));
1923:
1924: assertEquals("package", 0, mockStrategy
1925: .getPackageDifferentCount());
1926: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1927: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1928: assertEquals("constant", 0, mockStrategy
1929: .getConstantValueDifferentCount());
1930: assertEquals("method", 0, mockStrategy
1931: .getMethodDifferentCount());
1932: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1933: }
1934:
1935: public void testThrowsToDifferentThrowsMethod() {
1936: Method_info oldMethod = getOldPublishedJar().getClassfile(
1937: "ModifiedPackage.ModifiedClass").getMethod(
1938: "throwsToDifferentThrowsMethod()");
1939: Method_info newMethod = getNewPublishedJar().getClassfile(
1940: "ModifiedPackage.ModifiedClass").getMethod(
1941: "throwsToDifferentThrowsMethod()");
1942:
1943: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1944:
1945: assertEquals("package", 0, mockStrategy
1946: .getPackageDifferentCount());
1947: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1948: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1949: assertEquals("constant", 0, mockStrategy
1950: .getConstantValueDifferentCount());
1951: assertEquals("method", 0, mockStrategy
1952: .getMethodDifferentCount());
1953: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1954: }
1955:
1956: public void testCompatibleClassWithIncompatibleMethod() {
1957: Classfile oldClass = getOldPublishedJar().getClassfile(
1958: "ModifiedPackage.CompatibleClass");
1959: Classfile newClass = getNewPublishedJar().getClassfile(
1960: "ModifiedPackage.CompatibleClass");
1961:
1962: Method_info oldMethod = oldClass
1963: .getMethod("incompatibleMethod()");
1964: Method_info newMethod = newClass
1965: .getMethod("incompatibleMethod()");
1966:
1967: assertTrue(strategy.isMethodDifferent(oldMethod, newMethod));
1968: assertTrue(strategy.isClassDifferent(oldClass, newClass));
1969:
1970: assertEquals("package", 0, mockStrategy
1971: .getPackageDifferentCount());
1972: assertEquals("class", 0, mockStrategy.getClassDifferentCount());
1973: assertEquals("field", 0, mockStrategy.getMethodDifferentCount());
1974: assertEquals("constant", 0, mockStrategy
1975: .getConstantValueDifferentCount());
1976: assertEquals("method", 0, mockStrategy
1977: .getMethodDifferentCount());
1978: assertEquals("code", 0, mockStrategy.getCodeDifferentCount());
1979: }
1980: }
|