From e0b85586e2fa6fa0d8295d240480d2b6558deab4 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 14 May 2017 19:23:11 +0300 Subject: [PATCH] cleanup work and test naming --- .../org/baeldung/bean/injection/Helm.java | 2 +- .../org/baeldung/customscope/TenantBean.java | 8 +++--- .../customscope/TenantBeansConfig.java | 2 +- .../org/baeldung/customscope/TenantScope.java | 4 +-- .../jasperreports/SimpleReportExporter.java | 26 +++++++------------ .../jasperreports/SimpleReportFiller.java | 6 ++--- .../config/JasperRerportsSimpleConfig.java | 5 +--- .../org/baeldung/shell/simple/SimpleCLI.java | 25 +++++------------- .../shell/simple/SimpleURLConverter.java | 5 ++-- .../org/baeldung/springretry/AppConfig.java | 6 ++--- .../org/baeldung/springretry/MyService.java | 2 +- .../ThreadPoolTaskSchedulerExamples.java | 23 ++++++++-------- ...jectionWithJavaConfigIntegrationTest.java} | 6 ++--- ...njectionWithXMLConfigIntegrationTest.java} | 5 ++-- ...jectionWithJavaConfigIntegrationTest.java} | 5 ++-- ...njectionWithXMLConfigIntegrationTest.java} | 5 ++-- .../baeldung/customscope/TenantScopeTest.java | 26 +++++++++---------- .../ehcache/SquareCalculatorTest.java | 9 +++---- ...hreadPoolTaskSchedulerIntegrationTest.java | 2 +- 19 files changed, 69 insertions(+), 103 deletions(-) rename spring-all/src/test/java/org/baeldung/bean/injection/{ConstructorBasedBeanInjectionWithJavaConfigTest.java => ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java} (80%) rename spring-all/src/test/java/org/baeldung/bean/injection/{ConstructorBasedBeanInjectionWithXMLConfigTest.java => ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java} (87%) rename spring-all/src/test/java/org/baeldung/bean/injection/{SetterBasedBeanInjectionWithJavaConfigTest.java => SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java} (80%) rename spring-all/src/test/java/org/baeldung/bean/injection/{SetterBasedBeanInjectionWithXMLConfigTest.java => SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java} (79%) diff --git a/spring-all/src/main/java/org/baeldung/bean/injection/Helm.java b/spring-all/src/main/java/org/baeldung/bean/injection/Helm.java index 6d6ea85482..86f71ce795 100644 --- a/spring-all/src/main/java/org/baeldung/bean/injection/Helm.java +++ b/spring-all/src/main/java/org/baeldung/bean/injection/Helm.java @@ -1,7 +1,7 @@ package org.baeldung.bean.injection; public class Helm { - + private String brandOfHelm = "HelmBrand"; public String getBrandOfHelm() { diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantBean.java b/spring-all/src/main/java/org/baeldung/customscope/TenantBean.java index 2d3049ebb9..874fcda9f2 100644 --- a/spring-all/src/main/java/org/baeldung/customscope/TenantBean.java +++ b/spring-all/src/main/java/org/baeldung/customscope/TenantBean.java @@ -1,16 +1,14 @@ package org.baeldung.customscope; public class TenantBean { - + private final String name; - + public TenantBean(String name) { this.name = name; } 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())); } } diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java b/spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java index 0e21ad9344..be3ac001fb 100644 --- a/spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java +++ b/spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java @@ -12,7 +12,7 @@ public class TenantBeansConfig { public TenantBean foo() { return new TenantBean("foo"); } - + @Scope(scopeName = "tenant") @Bean public TenantBean bar() { diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantScope.java b/spring-all/src/main/java/org/baeldung/customscope/TenantScope.java index 062d7ee890..144d092be6 100644 --- a/spring-all/src/main/java/org/baeldung/customscope/TenantScope.java +++ b/spring-all/src/main/java/org/baeldung/customscope/TenantScope.java @@ -8,13 +8,13 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.config.Scope; public class TenantScope implements Scope { - + private Map scopedObjects = Collections.synchronizedMap(new HashMap()); private Map destructionCallbacks = Collections.synchronizedMap(new HashMap()); @Override public Object get(String name, ObjectFactory objectFactory) { - if(!scopedObjects.containsKey(name)) { + if (!scopedObjects.containsKey(name)) { scopedObjects.put(name, objectFactory.getObject()); } return scopedObjects.get(name); diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java b/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java index 1252dcda4d..103bb37eb4 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java +++ b/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java @@ -19,13 +19,13 @@ import org.springframework.stereotype.Component; @Component public class SimpleReportExporter { - + private JasperPrint jasperPrint; public SimpleReportExporter() { } - - public SimpleReportExporter (JasperPrint jasperPrint){ + + public SimpleReportExporter(JasperPrint jasperPrint) { this.jasperPrint = jasperPrint; } @@ -36,9 +36,7 @@ public class SimpleReportExporter { public void setJasperPrint(JasperPrint jasperPrint) { this.jasperPrint = jasperPrint; } - - - + public void exportToPdf(String fileName, String author) { // print report to file @@ -61,27 +59,25 @@ 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); } } - public void exportToXlsx(String fileName,String sheetName) { + public void exportToXlsx(String fileName, String sheetName) { JRXlsxExporter exporter = new JRXlsxExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fileName)); SimpleXlsxReportConfiguration reportConfig = new SimpleXlsxReportConfiguration(); - reportConfig.setSheetNames(new String[]{sheetName}); + reportConfig.setSheetNames(new String[] { sheetName }); exporter.setConfiguration(reportConfig); 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); } } } diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java b/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java index ae675dd280..08891d940a 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java +++ b/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java @@ -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); } } diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java b/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java index 90fc96cdbb..5cc2d894c9 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java +++ b/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java @@ -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 diff --git a/spring-all/src/main/java/org/baeldung/shell/simple/SimpleCLI.java b/spring-all/src/main/java/org/baeldung/shell/simple/SimpleCLI.java index 0bbc62cf2c..f73d9bda00 100644 --- a/spring-all/src/main/java/org/baeldung/shell/simple/SimpleCLI.java +++ b/spring-all/src/main/java/org/baeldung/shell/simple/SimpleCLI.java @@ -33,36 +33,25 @@ 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); } catch (FileNotFoundException ex) { - //Ignore + // Ignore } return "Done."; } private boolean adminEnableExecuted = false; - @CliAvailabilityIndicator(value = {"web-save"}) + @CliAvailabilityIndicator(value = { "web-save" }) public boolean isAdminEnabled() { return adminEnableExecuted; } @@ -72,7 +61,7 @@ public class SimpleCLI implements CommandMarker { adminEnableExecuted = true; return "Admin commands enabled."; } - + @CliCommand(value = "admin-disable") public String adminDisable() { adminEnableExecuted = false; diff --git a/spring-all/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java b/spring-all/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java index 66bab5c488..4824cfbf05 100644 --- a/spring-all/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java +++ b/spring-all/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java @@ -16,14 +16,13 @@ public class SimpleURLConverter implements Converter { try { return new URL(value); } catch (MalformedURLException ex) { - //Ignore + // Ignore } return null; } @Override - public boolean getAllPossibleValues(List completions, Class requiredType, - String existingData, String optionContext, MethodTarget target) { + public boolean getAllPossibleValues(List completions, Class requiredType, String existingData, String optionContext, MethodTarget target) { return false; } diff --git a/spring-all/src/main/java/org/baeldung/springretry/AppConfig.java b/spring-all/src/main/java/org/baeldung/springretry/AppConfig.java index 63bb2a53f1..d9b081578c 100644 --- a/spring-all/src/main/java/org/baeldung/springretry/AppConfig.java +++ b/spring-all/src/main/java/org/baeldung/springretry/AppConfig.java @@ -11,9 +11,9 @@ import org.springframework.retry.support.RetryTemplate; @Configuration @ComponentScan(basePackages = "org.baeldung.springretry") @EnableRetry -//Uncomment this two lines if we need XML configuration -//@EnableAspectJAutoProxy -//@ImportResource("classpath:/retryadvice.xml") +// Uncomment this two lines if we need XML configuration +// @EnableAspectJAutoProxy +// @ImportResource("classpath:/retryadvice.xml") public class AppConfig { @Bean diff --git a/spring-all/src/main/java/org/baeldung/springretry/MyService.java b/spring-all/src/main/java/org/baeldung/springretry/MyService.java index 2b8cc16eb3..6306ff3c26 100644 --- a/spring-all/src/main/java/org/baeldung/springretry/MyService.java +++ b/spring-all/src/main/java/org/baeldung/springretry/MyService.java @@ -7,7 +7,7 @@ import org.springframework.retry.annotation.Recover; import org.springframework.retry.annotation.Retryable; public interface MyService { - + @Retryable void retryService(); diff --git a/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java index 7505b85516..5d72ed148a 100644 --- a/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java +++ b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java @@ -14,34 +14,35 @@ import org.springframework.stereotype.Component; public class ThreadPoolTaskSchedulerExamples { @Autowired private ThreadPoolTaskScheduler taskScheduler; - + @Autowired private CronTrigger cronTrigger; - + @Autowired private PeriodicTrigger periodicTrigger; - + @PostConstruct - public void scheduleRunnableWithCronTrigger(){ + public void scheduleRunnableWithCronTrigger() { taskScheduler.schedule(new RunnableTask("Current Date"), new Date()); taskScheduler.scheduleWithFixedDelay(new RunnableTask("Fixed 1 second Delay"), 1000); - taskScheduler.scheduleWithFixedDelay(new RunnableTask("Current Date Fixed 1 second Delay"),new Date() , 1000); - taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"),new Date(), 2000); + taskScheduler.scheduleWithFixedDelay(new RunnableTask("Current Date Fixed 1 second Delay"), new Date(), 1000); + taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), new Date(), 2000); taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), 2000); taskScheduler.schedule(new RunnableTask("Cron Trigger"), cronTrigger); taskScheduler.schedule(new RunnableTask("Periodic Trigger"), periodicTrigger); } - - class RunnableTask implements Runnable{ + + class RunnableTask implements Runnable { private String message; - - public RunnableTask(String message){ + + public RunnableTask(String message) { this.message = message; } + @Override public void run() { - System.out.println("Runnable Task with "+message+" on thread "+Thread.currentThread().getName()); + System.out.println("Runnable Task with " + message + " on thread " + Thread.currentThread().getName()); } } } \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigTest.java b/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 80% rename from spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigTest.java rename to spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java index 68f8fc13d9..447a09d69e 100644 --- a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java @@ -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()); } } diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigTest.java b/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 87% rename from spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigTest.java rename to spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java index e69de124b2..9f6011d851 100644 --- a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java @@ -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()); } } diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigTest.java b/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 80% rename from spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigTest.java rename to spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java index 8705995acd..1c15775093 100644 --- a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java @@ -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()); } } diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigTest.java b/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 79% rename from spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigTest.java rename to spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java index 1958761d78..bc17a08383 100644 --- a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java @@ -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()); } } diff --git a/spring-all/src/test/java/org/baeldung/customscope/TenantScopeTest.java b/spring-all/src/test/java/org/baeldung/customscope/TenantScopeTest.java index 641e57bffd..f6cce4d9f2 100644 --- a/spring-all/src/test/java/org/baeldung/customscope/TenantScopeTest.java +++ b/spring-all/src/test/java/org/baeldung/customscope/TenantScopeTest.java @@ -16,17 +16,17 @@ public class TenantScopeTest { @Test public final void whenRegisterScopeAndBeans_thenContextContainsFooAndBar() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - try{ + try { ctx.register(TenantScopeConfig.class); ctx.register(TenantBeansConfig.class); ctx.refresh(); - + TenantBean foo = (TenantBean) ctx.getBean("foo", TenantBean.class); foo.sayHello(); TenantBean bar = (TenantBean) ctx.getBean("bar", TenantBean.class); bar.sayHello(); Map foos = ctx.getBeansOfType(TenantBean.class); - + assertThat(foo, not(equalTo(bar))); assertThat(foos.size(), equalTo(2)); assertTrue(foos.containsValue(foo)); @@ -34,40 +34,38 @@ public class TenantScopeTest { BeanDefinition fooDefinition = ctx.getBeanDefinition("foo"); BeanDefinition barDefinition = ctx.getBeanDefinition("bar"); - + assertThat(fooDefinition.getScope(), equalTo("tenant")); assertThat(barDefinition.getScope(), equalTo("tenant")); - } - finally { + } finally { ctx.close(); } } - + @Test public final void whenComponentScan_thenContextContainsFooAndBar() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - try{ + try { ctx.scan("org.baeldung.customscope"); ctx.refresh(); - + TenantBean foo = (TenantBean) ctx.getBean("foo", TenantBean.class); foo.sayHello(); TenantBean bar = (TenantBean) ctx.getBean("bar", TenantBean.class); bar.sayHello(); Map foos = ctx.getBeansOfType(TenantBean.class); - + assertThat(foo, not(equalTo(bar))); assertThat(foos.size(), equalTo(2)); assertTrue(foos.containsValue(foo)); assertTrue(foos.containsValue(bar)); - + BeanDefinition fooDefinition = ctx.getBeanDefinition("foo"); BeanDefinition barDefinition = ctx.getBeanDefinition("bar"); - + assertThat(fooDefinition.getScope(), equalTo("tenant")); assertThat(barDefinition.getScope(), equalTo("tenant")); - } - finally { + } finally { ctx.close(); } } diff --git a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java b/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java index ab7aebf7a1..5f79bdbbb8 100644 --- a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java +++ b/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java @@ -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"); } } } diff --git a/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerIntegrationTest.java b/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerIntegrationTest.java index d95857d384..94c58cb17e 100644 --- a/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ThreadPoolTaskSchedulerConfig.class }, loader = AnnotationConfigContextLoader.class) public class ThreadPoolTaskSchedulerIntegrationTest { - + @Test public void testThreadPoolTaskSchedulerAnnotation() throws InterruptedException { Thread.sleep(2550);