Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoRenewingTokenProviderTest Test() method fails #3

Open
rcollette opened this issue Aug 12, 2018 · 0 comments
Open

AutoRenewingTokenProviderTest Test() method fails #3

rcollette opened this issue Aug 12, 2018 · 0 comments

Comments

@rcollette
Copy link

I get an error running mvm install locally during tests, with no code modification having been done. I believe the issue is that ScheduledExecutorService is not mocked. Clock based services (or the Clock they depend upon) should be mocked due to variances in clock speeds on different machines. Using sleep is inaccurate.

		if (this.isActive())
			throw new IllegalStateException("Already started");

		// fetching from a remote service will inevitably pose some delay so we
		// defensively choose to count the fetch time from the very start.
		T newToken = this.getTokenService().fetch();
		if (newToken == null)
			throw new IllegalStateException("The token fetched from this TokenService is null");
		TemporalAccessToken<T> accessToken = new TemporalAccessToken<>(newToken, Instant.now(), this.tokenExpireInTemporalUnit());
		this.fireTokenUpdate(accessToken, null);

		this.tokenRenewTask = new TokenRenewTask(this, accessToken);
		long delayMillis = this.estimatedRepetitionsDelay().toMillis();

Error is

Running net.oauth2.client.AutoRenewingTokenProviderTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Tests run: 16, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.782 sec <<< FAILURE! - in net.oauth2.client.AutoRenewingTokenProviderTest
test(net.oauth2.client.AutoRenewingTokenProviderTest)  Time elapsed: 0.085 sec  <<< FAILURE!
org.mockito.exceptions.verification.TooManyActualInvocations: 
tokenChangeObserver.tokenChanged(
    <Capturing argument>,
    <Capturing argument>
);
Wanted 3 times:
-> at net.oauth2.client.AutoRenewingTokenProviderTest.test(AutoRenewingTokenProviderTest.java:377)
But was 4 times. Undesired invocation:
-> at net.oauth2.client.AutoRenewingTokenProvider.lambda$fireTokenUpdate$0(AutoRenewingTokenProvider.java:175)

        at net.oauth2.client.AutoRenewingTokenProviderTest.test(AutoRenewingTokenProviderTest.java:377)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant