static void setCached(VerifyContext context, ExcelSheetRuleExtensionRepository repository) { Reference<ExcelSheetRuleExtensionRepository> ref; if (repository.getClass().getClassLoader() == ClassLoader.getSystemClassLoader()) { ref = new SoftReference<>(repository); } else { ref = new WeakReference<>(repository); } CACHE.put(context.getTestContext().getClassLoader(), ref); }
private ValuePredicate<Calendar> createNowPredicate(VerifyContext context) { assert context != null; Calendar begin = toDatetime(context.getTestStarted()); Calendar end = toDatetime(context.getTestFinished()); end.add(Calendar.SECOND, 1); end.add(Calendar.MILLISECOND, -1); return Predicates.period(begin, end); }
/** * Set current time as when test was finished. */ public void testFinished() { setTestFinished(new Date()); }
throw new IllegalArgumentException("target must not be null"); //$NON-NLS-1$ VerifyContext verifyContext = new VerifyContext(context); verifyContext.testFinished();
/** * Verifies jobflow output. * @param description the exporter description * @param verifier the verifier * @return verify differences * @throws IOException if failed to verify the output */ public List<Difference> verify(ExporterDescription description, VerifierFactory verifier) throws IOException { TestModerator moderator = new TestModerator(getTestTools(), this); return moderator.inspect( description.getModelType(), description, new VerifyContext(this), verifier); }
Messages.getString("FlowPartTester.infoExecute"), //$NON-NLS-1$ flowDescription.getClass().getName())); VerifyContext verifyContext = new VerifyContext(driverContext); executor.runJobflow(jobflow); verifyContext.testFinished();
startDate = new Date(); VerifyContext verifyContext = new VerifyContext(driverContext, startDate); executor.runJobflow(mirror); verifyContext.testFinished();
private static ExcelSheetRuleExtensionRepository newInstance(VerifyContext context) { ClassLoader classLoader = context.getTestContext().getClassLoader(); List<ExcelSheetRuleExtension> extensions = new ArrayList<>(); for (ExcelSheetRuleExtension extension : ServiceLoader.load(ExcelSheetRuleExtension.class, classLoader)) { extensions.add(extension); } return new ExcelSheetRuleExtensionRepository(extensions); }
private ValuePredicate<Calendar> createTodayPredicate(VerifyContext context) { assert context != null; Calendar begin = toDate(context.getTestStarted()); Calendar end = toDate(context.getTestFinished()); end.add(Calendar.DATE, 1); end.add(Calendar.MILLISECOND, -1); return Predicates.period(begin, end); }
Messages.getString("JobFlowTester.infoExecute"), //$NON-NLS-1$ jobflowClass.getName())); VerifyContext verifyContext = new VerifyContext(driverContext); executor.runJobflow(jobflow); verifyContext.testFinished();
/** * Returns a {@link ExcelSheetRuleExtensionRepository} for the target context. * @param context the target context * @return a repository object * @throws IllegalArgumentException if some parameters were {@code null} */ public static ExcelSheetRuleExtensionRepository get(VerifyContext context) { if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } Reference<ExcelSheetRuleExtensionRepository> ref = CACHE.get(context.getTestContext().getClassLoader()); ExcelSheetRuleExtensionRepository cached = ref == null ? null : ref.get(); if (cached != null) { return cached; } ExcelSheetRuleExtensionRepository created = newInstance(context); setCached(context, created); return created; }
@Override public <T> Verifier createVerifier( DataModelDefinition<T> definition, VerifyContext context) throws IOException { DataModelSource expected = expectedFactory.createSource(definition, context.getTestContext()); VerifyRule verifyRule = ruleFactory.createRule(definition, context); boolean succeed = false; try { Verifier verifier = new VerifyRuleVerifier(expected, verifyRule); succeed = true; return verifier; } finally { if (succeed == false) { expected.close(); } } } @Override