private void resetClockToStartOfTest(final ClockMock clock) { clock.resetDeltaFromReality(); // Date at which all tests start-- we create the date object here after the system properties which set the JVM in UTC have been set. final DateTime testStartDate = new DateTime(2012, 5, 7, 0, 3, 42, 0); clock.setDeltaFromReality(testStartDate.getMillis() - clock.getUTCNow().getMillis()); }
@BeforeSuite(alwaysRun = true) public void globalBeforeSuite() { if (Boolean.valueOf(System.getProperty("killbill.test.redis", "false"))) { redisServer = new RedisServer(56379); redisServer.start(); redissonClient = new RedissonCacheClientProvider("redis://127.0.0.1:56379", 1).get(); theRealClock = new DistributedClockMock(); ((DistributedClockMock) theRealClock).setRedissonClient(redissonClient); extraPropertiesForTestSuite = ImmutableMap.<String, String>of("org.killbill.cache.config.redis", "true", "org.killbill.cache.config.redis.url", "redis://127.0.0.1:56379"); } else { theRealClock.resetDeltaFromReality(); extraPropertiesForTestSuite = ImmutableMap.<String, String>of(); } // The clock needs to be setup early in @BeforeSuite, as it is needed when starting the server, but see below clock = theRealClock; }
@POST @Path("/clock") @Produces(APPLICATION_JSON) @ApiOperation(value = "Set the current time", response = ClockResource.class) @ApiResponses(value = {/* @ApiResponse(code = 200, message = "Successful"), */ @ApiResponse(code = 400, message = "Invalid time or timezone supplied")}) public Response setTestClockTime(@QueryParam(QUERY_REQUESTED_DT) final String requestedClockDate, @QueryParam("timeZone") final String timeZoneStr, @QueryParam("timeoutSec") @DefaultValue("5") final Long timeoutSec, @javax.ws.rs.core.Context final HttpServletRequest request) { final ClockMock testClock = getClockMock(); if (requestedClockDate == null) { testClock.resetDeltaFromReality(); } else { final DateTime newTime = DATE_TIME_FORMATTER.parseDateTime(requestedClockDate).toDateTime(DateTimeZone.UTC); testClock.setTime(newTime); } waitForNotificationToComplete(request, timeoutSec); return getCurrentTime(timeZoneStr); }
private void resetClockToStartOfTest(final ClockMock clock) { clock.resetDeltaFromReality(); // Date at which all tests start-- we create the date object here after the system properties which set the JVM in UTC have been set. final DateTime testStartDate = new DateTime(2012, 5, 7, 0, 3, 42, 0); clock.setDeltaFromReality(testStartDate.getMillis() - clock.getUTCNow().getMillis()); }
@BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); dateHelper = new EntitlementDateHelper(); clock.resetDeltaFromReality(); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { embeddedDB.cleanupAllTables(); clock.resetDeltaFromReality(); metricRegistry.removeMatching(MetricFilter.ALL); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); log.debug("beforeMethod callcontext classLoader = " + (Thread.currentThread().getContextClassLoader() != null ? Thread.currentThread().getContextClassLoader().toString() : "null")); //Thread.currentThread().setContextClassLoader(null); log.debug("RESET TEST FRAMEWORK"); controllerDispatcher.clearAll(); overdueConfigCache.loadDefaultOverdueConfig((OverdueConfig) null); clock.resetDeltaFromReality(); busHandler.reset(); // Start services lifecycle.fireStartupSequencePriorEventRegistration(); registerHandlers(); lifecycle.fireStartupSequencePostEventRegistration(); paymentPlugin.clear(); }
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); controllerDispatcher.clearAll(); bus.start(); restartInvoiceService(invoiceService); clock.resetDeltaFromReality(); }
@BeforeSuite(alwaysRun = true) public void globalBeforeSuite() { if (Boolean.valueOf(System.getProperty("killbill.test.redis", "false"))) { redisServer = new RedisServer(56379); redisServer.start(); redissonClient = new RedissonCacheClientProvider("redis://127.0.0.1:56379", 1).get(); theRealClock = new DistributedClockMock(); ((DistributedClockMock) theRealClock).setRedissonClient(redissonClient); extraPropertiesForTestSuite = ImmutableMap.<String, String>of("org.killbill.cache.config.redis", "true", "org.killbill.cache.config.redis.url", "redis://127.0.0.1:56379"); } else { theRealClock.resetDeltaFromReality(); extraPropertiesForTestSuite = ImmutableMap.<String, String>of(); } // The clock needs to be setup early in @BeforeSuite, as it is needed when starting the server, but see below clock = theRealClock; }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } log.debug("RESET TEST FRAMEWORK"); cleanupAllTables(); clock.resetDeltaFromReality(); busHandler.reset(); lifecycle.fireStartupSequencePriorEventRegistration(); busService.getBus().register(busHandler); externalBus.register(new FakeKPMPlugin()); lifecycle.fireStartupSequencePostEventRegistration(); }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } super.beforeMethod(); stateMachineConfigCache.clearPaymentStateMachineConfig(PLUGIN_NAME, internalCallContext); stateMachineConfigCache.loadDefaultPaymentStateMachineConfig(PaymentModule.DEFAULT_STATE_MACHINE_PAYMENT_XML); paymentExecutors.initialize(); eventBus.start(); Profiling.resetPerThreadProfilingData(); clock.resetDeltaFromReality(); janitor.initialize(); janitor.start(); }
@Override @BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { if (hasFailed()) { return; } /* We copy the initialization instead of invoking the super method so we can add the registration of the publicBus event; TODO modify sequence to allow optional registration of publicListener */ cleanupAllTables(); log.debug("RESET TEST FRAMEWORK"); controllerDispatcher.clearAll(); overdueConfigCache.loadDefaultOverdueConfig((OverdueConfig) null); clock.resetDeltaFromReality(); busHandler.reset(); // Start services publicListener = new PublicListener(); lifecycle.fireStartupSequencePriorEventRegistration(); busService.getBus().register(busHandler); externalBus.register(publicListener); lifecycle.fireStartupSequencePostEventRegistration(); paymentPlugin.clear(); this.externalBusCount = new AtomicInteger(0); }