Font size
WorksheetsCore Spring Test 7
Total questions: 50
Worksheet time: 2hrs 39mins
endpoint.shutdown.enable=true
management.endpoint.shutdown.enabled=true
management.endpoint.enabled.shutdown=true
endpoint.shutdown.disabled=false
True
False
@SpringBootApplication
@ContextConfiguration
@EnableAutoConfiguration
@ComponentScan
It can be used on classes annotated with @Controller.
@RequestMapping will only map to GET requests unless explicitly specified different.
It have attribute "method" which can be used to customize requests methods that this method will map to.
We can specify the request parameters for the method using the attribute "requestParams".
It contains @ExtendWith(SpringExtension.class)
It contains @RunWith(SpringRunner.class)
It enables Spring Boot specific features on top of Spring Test
It's used on test methods
Serializable
Read commited
Read uncommited
Repeatable Reads
@WebMvcTest
@TestConfiguration
@JsonTest
@DataJpaTest
Query
Prepared statement
Transaction
Callback
Spring will use a class named SimpleJpaRepository by default to create beans for every Spring data repository.
If not specified @EnableJpaRepositories will scan the package of the configuration class and any of its subpackages.
To enable the usage of Spring data repositories the usse @EnableJpaRepositories on top of your configuration class is required.
The class used for beans creation of Spring data repositories can be specified using repositoryBaseClass attribute of @EnableJpaRepositories.
home
country
city
steet
HTTP
SMTP
FTP
JMX
This method will return Map with key-value pairs for the row updated.
This method returns void
This method will update the first_name column of user with id=1 to John
This method will return the id of the updated row
"execution (protected void com.whizlabs.spring.questions.aop.SomeClass.*)"
"within (com..* throws Exception")
"args(String)"
"execution (void com..SomeClass.get*())"
@Configuration(enableAspectJAutoProxy=true)
@AspectJConfiguration
@EnableAspectJAutoProxy
@Aspect
Spring Boot loads schema.sql for DDL and data.sql for DML from the classpath
Spring Boot will start the application even if the loaded scripts fail
Spring Boot will automatically initialize embedded and standalone databases
Spring Boot will load the schema-${platform}.sql and data-${platform}.sql files (if present), where platform is the value of spring.datasource.platform
@PreAuthorize
@PreFilter
@RolesAllowed
@PostAuthorize
GET
PATCH
PUT
DELETE
getCities
getCities2
getCities3
All of the above
@RequestMapping("/person") public String getPersonWithId1(@PathVariable("id") Long personId){ .... }
@RequestMapping("/person") public String getPersonWithId2(@PathVariable Long personId){ .... }
@RequestMapping("/person") public String getPersonWithId3(@RequestParam Long personId){ .... }
@RequestMapping("/person") public String getPersonWithId4(@RequestParam("id") Long personId){ .... }
Use the registerShutdownHook method on the application context to register a shutdown hook.
Use destroy() method declared in the class AbstractApplicationContext.
Use the close() method declared in the interface AbstractApplicationContext.
All of the above
Classes annotated with @Configuration can be final
Methods annotated with @Bean can't be final
Methods annotated with @Bean can be static
Methods annotated with @Bean can be private
Spring Security can be configured via web.xml or via Java Configuration.
The @EnableSpringSecurity annotation should be used on a @Configuration class to enable Spring Security
@Secured annotation can be used on class level
Spring Security is implemented only on web level
Request
Response
WebSocket
Factory
@ConditionalOnClass
@ConditionalOnBean
@ConditionalOnMissingClass
@ConditionalOnMissingBean
True
False
PUT
GET
PATCH
DELETE
DataSource is an interace from the Spring framework
DataSource represents any data source for SQL database
The DataSource interface is implemented by a driver vendor
All of the above.
TransactionManager
TransactionInterceptor
TransactionTemplate
PlatformTransactionManager
@Value("#{systemProperties['someProperty']}")
@Value("$(systemProperties['someProperty'])")
@Value("${someProperty}")
@Value("#(someProperty)")
The @Autowired annotation will not work in Spring application with XML configuration.
The @Autowired annotation can be used to inject a String value.
For the @Autowired annotation to work a component scanning must be enabled.
@Autowired has an attributed "required" and by default its value is false.
DataSource is always auto-configured in Spring Boot
For DataSource to be autoconfigured and a bean to be created successfully, database connector must included as a dependency
For DataSource to be autoconfigured and a bean to be created successfully, spring-boot-starter-data-jdbc must included as a dependency
To auto configure DataSource it must be listed in the spring.factories file of your project
Read commited
Repateable Reads
Serializable
Read uncommited
@Before
@BeforeEach
@BeforeAll
@BeforeClass
True
False
Around advice(@Around)
After throwing advice(@AfterThrowing)
After returning advice(@AfterReturning)
After (finally) advice(@After)
SecurityContextHolder
SecurityContext
Authentication
ProviderManager
Change the annotation from @Bean to @Bean("playerBeanId")
Change the annotation from @Bean to @Bean(name="playerBeanId")
Add @Qualifier("playerBeanId") on top of playerBean method
Change the annotation from @Bean to @Bean(id="playerBeanId")
True
False
@Component("specialPlayer")
@Qualifier("specialPlayer")
@Component(id="specialPlayer")
@Bean(name="specialPlayer")
@PropertySource({"classpath:/myFile.properties","classpath:/myFile2.properties"})
@PropertySource("classpath:/myFile.properties,classpath:/myFile2.properties")
@PropertySources({ @PropertySource("classpath:/myFile.properties"), @PropertySource("classpath:/myFile2.properties") })
@PropertySources( @PropertySource("classpath:/myFile.properties"), @PropertySource("classpath:/myFile2.properties") )
True
False
"execution (void com..* throws java.io.IOException)"
"args(..)"
"execution (public !int com.whizlabs.spring.questions.aop.SomeClass.*)"
"within(com..*)"
loggers endpoint is exposed by default via both JMX and HTTP
loggers endpoint can be used to list all the loggers in the application
via HTTP an individual logger can be viewed using /actuator/loggers?name=<logger_name>
loggers endpoint can be used to change the logging level of a certain logger.
@SpringBootTest
@Mock
@InjectMocks
@MockBean
findFirst5ById
getFirstFiveById
showFirst5ById
readTop5ById
True
False
Both fat jar and original jar are executable
original jar contains compiled code for an application and also all the dependencies
To create fat-jar the spring-boot-maven-plugin dependency must be set
fat jar contains compiled code for an application without the dependencies
Method annotated with it can handle a POST request in certain cases.
We can replace it using @RequestMapping(method = RequestMethod.GET).
It's a specialization of @RequestMapping.
All of the above.
spring-boot-devtools
spring-boot-actuator
spring-boot-starter-web
spring-boot-starter-security
Spring Boot increases productivity.
Spring Boot increases boilerplate configuration.
Spring Boot simplifies deployment.
Spring Boot doesnt allow creating executable jars.
