RESOLVED: BATCH-1146 Added MD5 hashing to JobParameters in JDBC instance dao
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
||||
@@ -19,6 +25,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
return (JobInstanceDao) applicationContext.getBean("jobInstanceDao");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindJobInstanceByExecution(){
|
||||
|
||||
JobExecutionDao jobExecutionDao = (JobExecutionDao) applicationContext.getBean("jobExecutionDao");
|
||||
@@ -30,4 +37,18 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
JobInstance returnedInstance = dao.getJobInstance(jobExecution);
|
||||
Assert.assertEquals(jobInstance, returnedInstance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHexing() throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = digest.digest("f78spx".getBytes("UTF-8"));
|
||||
StringBuffer output = new StringBuffer();
|
||||
for (byte bite : bytes) {
|
||||
output.append(String.format("%02x", bite));
|
||||
}
|
||||
assertEquals("Wrong hash: "+output,32, output.length());
|
||||
String value = String.format("%032x", new BigInteger(1, bytes));
|
||||
assertEquals("Wrong hash: "+value,32, value.length());
|
||||
assertEquals(value, output.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user