Wednesday 6 March 2019

create eclipse template

1) JUNIT Templates

a) Junit before method
${:import (org.junit.Before)}
  
@Before
public void setUp() {
    ${cursor}
}
b) Junit after method
${:import (org.junit.After)}
  
@After
public void tearDown() {
    ${cursor}
}
c) Junit before class
${:import (org.junit.BeforeClass)}
  
@BeforeClass
public static void oneTimeSetUp() {
    // one-time initialization code
    ${cursor}
}
d) Junit after class
${:import (org.junit.AfterClass)}
  
@AfterClass
public static void oneTimeTearDown() {
    // one-time cleanup code
    ${cursor}
}


2) Logging Templates

The templates below are useful for creating a logger and logging messages. I use SLF4J, but they could easily be tweaked to use any other logging framework.
a) Create a new Logger
${:import(org.slf4j.Logger,
          org.slf4j.LoggerFactory)}
private static final Logger LOGGER = LoggerFactory.getLogger(${enclosing_type}.class);
b) Check Debug scope before putting debug log
if(LOGGER.isDebugEnabled())
     LOGGER.debug(${word_selection}${});
${cursor}
c) Log info level statement
LOGGER.info(${word_selection}${});
${cursor}
d) Log the error
LOGGER.error(${word_selection}${}, ${exception_variable_name});
e) Log error and throw exception

LOGGER.error(${word_selection}${}, ${exception_variable_name});
throw ${exception_variable_name};
${cursor}

40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot

  40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot 1. What is Tight Coupling? When a class (ClassA) is depen...