private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xmethod.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xmethod); } FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor(); Collection<BugInstance> warnings = warningsByMethod.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor()); }
public static boolean likelyTestCase(XMethod m) { if (m.getAnnotation(JUNIT4TEST) != null) { return true; } ClassDescriptor c = m.getClassDescriptor(); if (m.getName().startsWith("test") || m.getName().startsWith("assert")) { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); try { if (subtypes2.isSubtype(c, JUNIT3TESTCASE)) { return true; } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } } return false; }
isExhaustive1 = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null; if (isExhaustive1) { } else { isExclusive1 = xmethod.getAnnotation(EXCLUSIVE_ANNOTATION) != null;
@Override public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException { XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor); // Is this class an obligation type? Obligation thisClassObligation = database.getFactory().getObligationByType(xclass.getClassDescriptor()); // Scan methods for uses of obligation-related annotations for (XMethod xmethod : xclass.getXMethods()) { // Is this method marked with @CreatesObligation? if (thisClassObligation != null) { if (xmethod.getAnnotation(createsObligation) != null) { database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation)); } // Is this method marked with @DischargesObligation? if (xmethod.getAnnotation(dischargesObligation) != null) { database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.DEL, ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation)); } } addObligations(xmethod); } }
AnnotationValue av = xMethod.getAnnotation(junitTestAnnotation); if (av != null) { Object value = av.getValue("expected");
@Override public void visit(Code code) { if(!testingEnabled){ return; } if (getMethod().isStatic() || getMethod().isPrivate()) { return; } XMethod overrides = Lookup.findSuperImplementorAsXMethod(getThisClass(), getMethodName(), getMethodSig(), bugReporter); if (overrides == null) { return; } AnnotationValue annotation = overrides.getAnnotation(mustOverrideAnnotation); if (annotation == null) { return; } sawCallToSuper = false; super.visit(code); if (!sawCallToSuper) { bugReporter.reportBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this).addString( "Method must invoke override method in superclass")); } }
private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) { AnnotationValue expect = xmethod.getAnnotation(annotation); if (expect == null) { return; } if (DEBUG) { System.out.println("*** Found " + annotation + " annotation on " + xmethod); } FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor(); Collection<BugInstance> warnings = warningsByMethod.get(descriptor); check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor()); }
public static boolean likelyTestCase(XMethod m) { if (m.getAnnotation(JUNIT4TEST) != null) { return true; } ClassDescriptor c = m.getClassDescriptor(); if (m.getName().startsWith("test") || m.getName().startsWith("assert")) { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); try { if (subtypes2.isSubtype(c, JUNIT3TESTCASE)) { return true; } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } } return false; }
isExhaustive1 = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null; if (isExhaustive1) { } else { isExclusive1 = xmethod.getAnnotation(EXCLUSIVE_ANNOTATION) != null;
@Override public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException { XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor); // Is this class an obligation type? Obligation thisClassObligation = database.getFactory().getObligationByType(xclass.getClassDescriptor()); // Scan methods for uses of obligation-related annotations for (XMethod xmethod : xclass.getXMethods()) { // Is this method marked with @CreatesObligation? if (thisClassObligation != null) { if (xmethod.getAnnotation(createsObligation) != null) { database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation)); } // Is this method marked with @DischargesObligation? if (xmethod.getAnnotation(dischargesObligation) != null) { database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.DEL, ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation)); } } addObligations(xmethod); } }
AnnotationValue av = xMethod.getAnnotation(junitTestAnnotation); if (av != null) { Object value = av.getValue("expected");
@Override public void visit(Code code) { if(!testingEnabled){ return; } if (getMethod().isStatic() || getMethod().isPrivate()) { return; } XMethod overrides = Lookup.findSuperImplementorAsXMethod(getThisClass(), getMethodName(), getMethodSig(), bugReporter); if (overrides == null) { return; } AnnotationValue annotation = overrides.getAnnotation(mustOverrideAnnotation); if (annotation == null) { return; } sawCallToSuper = false; super.visit(code); if (!sawCallToSuper) { bugReporter.reportBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this).addString( "Method must invoke override method in superclass")); } }