cleanup work and test naming
This commit is contained in:
parent
2b374fa8ae
commit
e0b85586e2
|
@ -9,8 +9,6 @@ public class TenantBean {
|
|||
}
|
||||
|
||||
public void sayHello() {
|
||||
System.out.println(String.format("Hello from %s of type %s",
|
||||
this.name,
|
||||
this.getClass().getName()));
|
||||
System.out.println(String.format("Hello from %s of type %s", this.name, this.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@ public class SimpleReportExporter {
|
|||
this.jasperPrint = jasperPrint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void exportToPdf(String fileName, String author) {
|
||||
|
||||
// print report to file
|
||||
|
@ -61,8 +59,7 @@ public class SimpleReportExporter {
|
|||
try {
|
||||
exporter.exportReport();
|
||||
} catch (JRException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +77,7 @@ public class SimpleReportExporter {
|
|||
try {
|
||||
exporter.exportReport();
|
||||
} catch (JRException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +90,7 @@ public class SimpleReportExporter {
|
|||
try {
|
||||
exporter.exportReport();
|
||||
} catch (JRException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,8 +103,7 @@ public class SimpleReportExporter {
|
|||
try {
|
||||
exporter.exportReport();
|
||||
} catch (JRException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ public class SimpleReportFiller {
|
|||
jasperReport = JasperCompileManager.compileReport(reportStream);
|
||||
JRSaver.saveObject(jasperReport, reportFileName.replace(".jrxml", ".jasper"));
|
||||
} catch (JRException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,8 +53,7 @@ public class SimpleReportFiller {
|
|||
try {
|
||||
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource.getConnection());
|
||||
} catch (JRException | SQLException ex) {
|
||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
||||
.log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,7 @@ public class JasperRerportsSimpleConfig {
|
|||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.HSQL)
|
||||
.addScript("classpath:employee-schema.sql")
|
||||
.build();
|
||||
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).addScript("classpath:employee-schema.sql").build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -33,24 +33,13 @@ public class SimpleCLI implements CommandMarker {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@CliCommand(
|
||||
value = {"web-get", "wg"},
|
||||
help = "Displays the contents of a URL."
|
||||
)
|
||||
public String webGet(
|
||||
@CliOption(
|
||||
key = {"", "url"},
|
||||
help = "URL whose contents will be displayed."
|
||||
) URL url) {
|
||||
@CliCommand(value = { "web-get", "wg" }, help = "Displays the contents of a URL.")
|
||||
public String webGet(@CliOption(key = { "", "url" }, help = "URL whose contents will be displayed.") URL url) {
|
||||
return getContentsOfUrlAsString(url);
|
||||
}
|
||||
|
||||
@CliCommand(
|
||||
value = {"web-save", "ws"},
|
||||
help = "Saves the contents of a URL.")
|
||||
public String webSave(
|
||||
@CliOption(key = {"", "url"}, help = "URL whose contents will be saved.") URL url,
|
||||
@CliOption(key = {"out", "file"}, mandatory = true, help = "The name of the file.") String file) {
|
||||
@CliCommand(value = { "web-save", "ws" }, help = "Saves the contents of a URL.")
|
||||
public String webSave(@CliOption(key = { "", "url" }, help = "URL whose contents will be saved.") URL url, @CliOption(key = { "out", "file" }, mandatory = true, help = "The name of the file.") String file) {
|
||||
String contents = getContentsOfUrlAsString(url);
|
||||
try (PrintWriter out = new PrintWriter(file)) {
|
||||
out.write(contents);
|
||||
|
|
|
@ -22,8 +22,7 @@ public class SimpleURLConverter implements Converter<URL> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllPossibleValues(List<Completion> completions, Class<?> requiredType,
|
||||
String existingData, String optionContext, MethodTarget target) {
|
||||
public boolean getAllPossibleValues(List<Completion> completions, Class<?> requiredType, String existingData, String optionContext, MethodTarget target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public class ThreadPoolTaskSchedulerExamples {
|
|||
public RunnableTask(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Runnable Task with " + message + " on thread " + Thread.currentThread().getName());
|
||||
|
|
|
@ -5,19 +5,17 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
public class ConstructorBasedBeanInjectionWithJavaConfigTest {
|
||||
public class ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest {
|
||||
private static final String HELM_NAME = "HelmBrand";
|
||||
|
||||
@Test
|
||||
public void givenJavaConfigFile_whenUsingConstructorBasedBeanInjection_thenCorrectHelmName() {
|
||||
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConstructorBasedShipConfig.class);
|
||||
ctx.refresh();
|
||||
|
||||
Ship ship = ctx.getBean(Ship.class);
|
||||
|
||||
Assert.assertEquals(HELM_NAME, ship.getHelm()
|
||||
.getBrandOfHelm());
|
||||
Assert.assertEquals(HELM_NAME, ship.getHelm().getBrandOfHelm());
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class ConstructorBasedBeanInjectionWithXMLConfigTest {
|
||||
public class ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest {
|
||||
|
||||
private static final String HELM_NAME = "HelmBrand";
|
||||
|
||||
|
@ -14,7 +14,6 @@ public class ConstructorBasedBeanInjectionWithXMLConfigTest {
|
|||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-constructor.xml");
|
||||
|
||||
final Ship shipConstructorBean = (Ship) applicationContext.getBean("ship");
|
||||
Assert.assertEquals(HELM_NAME, shipConstructorBean.getHelm()
|
||||
.getBrandOfHelm());
|
||||
Assert.assertEquals(HELM_NAME, shipConstructorBean.getHelm().getBrandOfHelm());
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
public class SetterBasedBeanInjectionWithJavaConfigTest {
|
||||
public class SetterBasedBeanInjectionWithJavaConfigIntegrationTest {
|
||||
|
||||
private static final String HELM_NAME = "HelmBrand";
|
||||
|
||||
|
@ -18,7 +18,6 @@ public class SetterBasedBeanInjectionWithJavaConfigTest {
|
|||
|
||||
Ship ship = ctx.getBean(Ship.class);
|
||||
|
||||
Assert.assertEquals(HELM_NAME, ship.getHelm()
|
||||
.getBrandOfHelm());
|
||||
Assert.assertEquals(HELM_NAME, ship.getHelm().getBrandOfHelm());
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class SetterBasedBeanInjectionWithXMLConfigTest {
|
||||
public class SetterBasedBeanInjectionWithXMLConfigIntegrationTest {
|
||||
|
||||
private static final String HELM_NAME = "HelmBrand";
|
||||
|
||||
|
@ -14,7 +14,6 @@ public class SetterBasedBeanInjectionWithXMLConfigTest {
|
|||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-setter.xml");
|
||||
|
||||
final Ship shipSetterBean = (Ship) applicationContext.getBean("ship");
|
||||
Assert.assertEquals(HELM_NAME, shipSetterBean.getHelm()
|
||||
.getBrandOfHelm());
|
||||
Assert.assertEquals(HELM_NAME, shipSetterBean.getHelm().getBrandOfHelm());
|
||||
}
|
||||
}
|
|
@ -37,8 +37,7 @@ public class TenantScopeTest {
|
|||
|
||||
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
||||
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +65,7 @@ public class TenantScopeTest {
|
|||
|
||||
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
||||
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ public class SquareCalculatorTest {
|
|||
public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() {
|
||||
for (int i = 10; i < 15; i++) {
|
||||
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||
System.out.println("Square value of " + i + " is: "
|
||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,14 +29,12 @@ public class SquareCalculatorTest {
|
|||
public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() {
|
||||
for (int i = 10; i < 15; i++) {
|
||||
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||
System.out.println("Square value of " + i + " is: "
|
||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
}
|
||||
|
||||
for (int i = 10; i < 15; i++) {
|
||||
assertTrue(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||
System.out.println("Square value of " + i + " is: "
|
||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue