18 februarie 2020

O colecție de întrebări pentru interviuri, ediția București 2020

Java SE
- polimorfism, mostenire
- modificatori de acces în JSE, diferența între protected și default
- cum functioneaza variabilele statice
- despre tipurile de excepții: checked și unchecked
- de ce se folosește finally
- try with resources
- cum se creează un obiect immutable
- diferența intre int si Integer
- despre stringuri, mutabile sau imutabile?
- concatenarea de stringuri din java, de ce e costisitor?
- StringBuilder vs StringBuffer
- care sunt tipurile de colecții: liste, seturi, map etc
- diferența List, Map și Set
- set ordonat--- TreeSet? cum se ordonează?
- diferența între Comparable si Comparator
- parsare XML cu java - cum?

- Struts, Servlet
- filtre din Servlet
- interceptor din Struts2
- JSP e thread safe?
- cum functionau aplicațiile Swing pe mai multe thread-uri - cum stia primul thread ca s-a terminat al doilea?
- JDBC, Hibernate
- de ce să folosesți JDBC comparativ cu un ORM?
- tipuri de statements in JDBC
- cum te protejezi de JDBC injection
- la ce se foloseste Maven, tipuri de scope-uri si la ce sunt folosite

Javascript, HTML
- HTML tags, caracteristici html5
- diferența GET/POST
- cum te protejezi de sniffing pe rețea
- obiecte in javascript, se poate folosi let in Javascript?
- multithreading in Javascript? Dar in html? web workers?
- Ajax - cum funcționeaza
- tipuri de atribute ale unui cookie
- tipuri de atacuri în oasp - top 10 vulnerabilities

Baze de date
- ce este un index într-o BD, ce este un trigger
- SQL: diferenta între delete și truncate (truncate nu activează trigger)
- tipuri de join, diferența între left și right join

Altele
- exemple de ședințe Agile
- design patterns exemple
- singleton si multithreading, cum se poate face thread safe
- REST api (x2)
- Linux exemple de comenzi, comanda pt schimbarea parolei, logare ca admin
- un excel care comunică lent cu o BD, cum se poate depana, primii pași?

28 noiembrie 2019

QF teste: exemple de procedura



import java.nio.file.Path

import java.util.concurrent.TimeUnit
import java.util.regex.Pattern

def referenceFile = rc.lookup("referenceFile")
def actualFile = rc.lookup("generatedFile")

def reference = new File(referenceFile).text
def actual = new File(actualFile).text

def isADELrapFormat = reference.contains("<ADELrap")

if(isADELrapFormat) {
    reference = fixFieldsToBeIgnoredInComparison(reference)
    actual = fixFieldsToBeIgnoredInComparison(actual)
}

rc.setLocal("areIdentical", rc.checkEqual(reference, actual, "Mesaj", level:2, report:true, nowrap:false))

private static String fixFieldsToBeIgnoredInComparison(final String xml) {
    final Pattern last_modified_time = Pattern.compile("<LAST_MODIFIED_TIME>.*</LAST_MODIFIED_TIME>");
    return last_modified_time.matcher(xml).replaceFirst("<LAST_MODIFIED_TIME>XXXX</LAST_MODIFIED_TIME>")
}

27 noiembrie 2019

QF teste


Basic setup

Get the ApplicationsSetup_branch.qft (the list of test suites) from STI.
Open it with QF, modify its variable definitions:
  • mainAppRootDir should point to the distribution which will be tested (which has the folders: bin, license, matlab, etc)
  • setup_version should be R9999.9999
  • create two local folders and make testDataFolder and TestResultsFolder point to them
Make sure "Name override mode" is set to "Override everything": go to Edit -> Options, check in Record -> Components and Replay -> Recognition.


Start the application

The application is run from QF itself: go to the left panel -> Procedures -> Dependency: Dependency -> Setup: Start SUT and hit the play button


Create a test

An easy way to record a run is to create a new sequence. If you go to the left panel -> Extras you will see a list of sequences and play one of them to see what it is doing.


Basic steps to create a new sequence
  1. Hit the record button
  2. Do something in your application
  3. Hit the square button to stop recording
  4. When you play the recording, a normal exit disables the Play button and nothing happens, whereas for test failure you will see an error window.

Tips

Depending on the tool you are testing, it is nice to start by deleting the current project and make a new one. Before you stop recording, it is nice to bring the screen to the same place you started from (without deleting the current project though).

Copy your input files into testDataFolder.
When you load your input files, make sure you start from a common parent of testDataFolder and testResultsFolder and then navigate to the file you need. This will make it clear for the QF tool on how to get there.

If you have to export files, export them to your testResultsFolder and navigate to it like described at (2).
Once you first exported a file, rename it using the keyword "reference" to save it as a reference.
To compare the reference file with the newly generated file, use the method shellutils.compareFiles:
  • right click on the sequence -> insert node -> procedure nodes -> procedure call
  • procedure name is "shellutils.compareFiles", variable return type is "areIdentical"
  • you need to fill out 2 variable definitions, one for referenceFile and the other for generatedFile (enter your paths)
  • you need to move the procedure call inside the body of the sequence, as its last step
  • the body of the compareFiles is located in Procedures -> Package: shellutils -> Procedure: compareFiles
  • you can use a different procedure call or make your own, if the above doesn't fit you.
Your sequence doesn't have to cover the whole flow. You can stop the sequence at any time and with the next sequence resume from where you left off.

Steps inside a sequence (such as mouse events, inputs, etc) can be moved freely to another sequence in case the use case is split. Also, if QF doesn't capture certain components, feel free to stop the sequence before QF will throw the error, and start a new sequence after you have manually fixed it or just waited for it to disappear.

26 septembrie 2019

Notite MVN, Git, etc

Maven
> mvn clean install -rf :parent -DskipTests


Git MERGE
> git status
> git checkout <branch-de-unde-aduci-date>
> git pull
> git checkout <task care face merge>
> git merge <branch-de-unde-aduci-date>
> git status

Daca sunt conflicte: GO & solve conflicts in IDE
> git commit
(:wq in Vim to save commit default message)
> IDE: add & commit as normal
> git push

Commit de pe branch-ul meu pe unul gresit:
> git commit --amend
(edit file with correct branch code)
> git push

Sterge toate modificarile necomise inca:
> git add .
> git stash
> git stash drop

Arata codul ultimului commit (nu neaparat pushed):
> git log --format="%H" -n 1

Pe un branch nou aplica un commit:
> git cherry-pick <commit-id>
> git push


GIT Bash: find text in all files:
> grep -rnw '/path/to/somewhere/' -e 'pattern'


IDE Hotswap agent
-XXaltjvm=dcevm -javaagent:C:\Program Files\Java\hotswap-agent.jar YourApp

Run in debug mode, check hotswap are init in the logs
Reload:
1) Run -> Reload changed classes
2) Build -> Recompile...
3) App: refresh step


Altele
If pinging PC does not work:
> ipconfig /flushdns
(cached IP has changed)

21 mai 2019

Uncle Bob about Factory design pattern


Clean Code: un tutorial destul de distractiv, dar scump, despre programarea eficienta in Java si bunele practici