Skip to content

Feature/#12 stabilization of login modifier#28

Merged
malaskowski merged 5 commits intomasterfrom
feature/#12-stabilization-of-login-modifier
Nov 10, 2016
Merged

Feature/#12 stabilization of login modifier#28
malaskowski merged 5 commits intomasterfrom
feature/#12-stabilization-of-login-modifier

Conversation

@tomaszhulakcogni
Copy link
Copy Markdown
Contributor

No description provided.


import java.util.Map;

public class LoginModifierConfig {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have this class package-scoped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

form.login(config.getLogin(), config.getPassword());
}

private void sleep() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename this method to sth like:

  • waitForAuthentication
  • delayBeforeLoginCheck
  • ??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to delayBeforeLoginCheckOrReattempt. Long, but descriptive - this timeout is used in two contexts.

this.loginTokenKey = getParameter(params, LOGIN_TOKEN_KEY_PARAM, DEFAULT_LOGIN_TOKEN);
this.forceLogin = BooleanUtils.toBoolean(params.get(FORCE_LOGIN));
int loginTimeout = NumberUtils.toInt(getParameter(params, LOGIN_CHECK_TIMEOUT_PARAM, DEFAULT_CHECK_TIMEOUT_PARAM));
this.loginCheckTimeout = Math.min(10000, loginTimeout);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename this attribute to sth like:

  • this.waitForAuthentication = loginCheckDelay
  • this.delayBeforeLoginCheck = delay
  • ??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to delayBeforeLoginCheckOrReattempt. Long, but descriptive - this timeout is used in two contexts.

Thread.sleep(config.getLoginCheckTimeout());
} catch (InterruptedException e) {
LOGGER.error("Interruption", e);
Thread.currentThread().interrupt();
Copy link
Copy Markdown
Contributor

@wiiitek wiiitek Nov 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This line looks suspicious.
I went through one article about the topic:
http://www.javaspecialists.eu/archive/Issue056.html
and it looks like it makes sense for interrupting newly created threads.
Here however we are in some thread that is performing screen collection.
I woud rather throw some runtime exception here:
new RuntimeException("this thread should NOT be interrupted here")..
See also https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()

Could we consult someone on this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is so little damage here when sleep is interrupted, we can go with this approach. It looks that SleepModifier handles interruption in similar way - it may be area to improve at least logging there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left as it is.

private LoginModifierConfig config;

LoginModifier(WebCommunicationWrapper webCommunicationWrapper, ValidationResultBuilder validationResultBuilder) {
this.webCommunicationWrapper = webCommunicationWrapper;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also have this.webDriver in line 49 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<profiles>
<profile>
<!-- Assembly test suites from 'partials' catolog into one main-test.xml -->
<!-- Assembly test suites from 'partials' catalog into one main-test.xml -->
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid changes with only white-space characters modification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's a typo fix: catolog -> catalog

}

private void sleep() {
if (config.getLoginCheckTimeout() > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use sleep in two places. Its action depends on LoginCheckTimeout value. Should sleep method be used both before each re-attempt of login and during login method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm going to describe it in the documentation.

Thread.sleep(config.getLoginCheckTimeout());
} catch (InterruptedException e) {
LOGGER.error("Interruption", e);
Thread.currentThread().interrupt();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is so little damage here when sleep is interrupted, we can go with this approach. It looks that SleepModifier handles interruption in similar way - it may be area to improve at least logging there.

@malaskowski
Copy link
Copy Markdown
Contributor

malaskowski commented Nov 4, 2016

Please update Login Modifier Documentation in this pull request.

@malaskowski malaskowski merged commit 62e1620 into master Nov 10, 2016
@malaskowski malaskowski deleted the feature/#12-stabilization-of-login-modifier branch November 10, 2016 12:55
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

Successfully merging this pull request may close these issues.

4 participants