ApplicationContextResolverImpl implements ApplicationContextResolver, InitializingBean,
                   DisposableBean { protected String getBeanFileName(BatchJobData jobRecord) { Assert.notNull(jobRecord); StringBuilder str = new StringBuilder(); String jobAppCd = jobRecord.getJobAppCd() == null ? "" : jobRecord.getJobAppCd(); if (classpath == null || classpath.length() == 0) { str.append(jobAppCd).append(PROPERTY_BEAN_FILENAME_SUFFIX); return str.toString(); } str.append(classpath); if (!classpath.contains(REPLACE_STRING_PREFIX)) { return str.append(jobAppCd).append(PROPERTY_BEAN_FILENAME_SUFFIX) .toString(); } String pathSource = str.toString(); pathSource = pathSource.replaceAll(REPLACE_STRING_JOB_APP_CD_UPPER, REPLACE_STRING_JOB_APP_CD_UPPER_REPLACE); pathSource = pathSource.replaceAll(REPLACE_STRING_JOB_APP_CD_LOWER, REPLACE_STRING_JOB_APP_CD_LOWER_REPLACE); StandardEvaluationContext eval = new StandardEvaluationContext( jobRecord); Expression exp; try { exp = parser.parseExpression(pathSource, parserContext); str = new StringBuilder(String.class.cast(exp.getValue(eval))); } catch (ParseException e) { throw new IllegalArgumentException( LOGGER.getLogMessage(LogId.EAL025058, "beanDefinition.business.classpath"), e); } return str.append(jobAppCd).append(PROPERTY_BEAN_FILENAME_SUFFIX) .toString(); }  @Override ApplicationContext resolveApplicationContext(); @Override ApplicationContext resolveApplicationContext(
            BatchJobData batchJobData); @Override void closeApplicationContext(ApplicationContext applicationContext); @Override void afterPropertiesSet(); void setCommonContextClassPath(String[] commonContextClassPath); @Override void destroy();  }
@Test public void testGetBeanFileName01() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("jobAppCd"); }}; target.classpath = null; assertEquals("jobAppCd.xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName02() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("jobAppCd"); }}; target.classpath = ""; assertEquals("jobAppCd.xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName03() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd(null); }}; target.classpath = ""; assertEquals(".xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName04() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("jobAppCd"); }}; target.classpath = "classpath/"; assertEquals("classpath/jobAppCd.xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName05() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("B0000001"); }}; target.classpath = "classpath/${jobAppCd}/"; assertEquals("classpath/B0000001/B0000001.xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName06() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("B0000001"); }}; target.classpath = "classpath/${noDefProperty}/"; try { target.getBeanFileName(batchJobData); fail(); } catch (SpelEvaluationException e) { assertTrue(e.getMessage().contains( "EL1008E: Property or field 'noDefProperty' cannot be found on object of type 'jp.terasoluna.fw.batch.executor.ApplicationContextResolverImplTest")); } }
@Test public void testGetBeanFileName07() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("B0000001"); }}; target.classpath = "classpath/${jobAppCd/"; try { target.getBeanFileName(batchJobData); fail(); } catch (IllegalArgumentException e) { assertEquals( "[EAL025058] Invalid format in batch.properties. key:beanDefinition.business.classpath", e.getMessage()); } }
@Test public void testGetBeanFileName08() throws Exception { target.classpath = "classpath/"; try { target.getBeanFileName(null); fail(); } catch (IllegalArgumentException e) { assertEquals( "[Assertion failed] - this argument is required; it must not be null", e.getMessage()); } }
@Test public void testGetBeanFileName09() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("to_upper"); }}; target.classpath = "classpath/${jobAppCdUpper}/"; assertEquals("classpath/TO_UPPER/to_upper.xml", target.getBeanFileName(batchJobData)); }
@Test public void testGetBeanFileName10() throws Exception { BatchJobData batchJobData = new BatchJobData() {{ setJobAppCd("TO_LOWER"); }}; target.classpath = "classpath/${jobAppCdLower}/"; assertEquals("classpath/to_lower/TO_LOWER.xml", target.getBeanFileName(batchJobData)); }