[Minor] Code cleanup

This commit is contained in:
Robert von Burg 2016-02-10 20:28:11 +01:00
parent 3336cfda1b
commit c947260853
13 changed files with 79 additions and 86 deletions

View File

@ -39,6 +39,7 @@ public enum ConnectionMode {
* or do any other kind of work * or do any other kind of work
*/ */
OFF { OFF {
@Override
public boolean isSimulation() { public boolean isSimulation() {
return false; return false;
} }
@ -50,6 +51,7 @@ public enum ConnectionMode {
* re-established should an {@link IOException} occur * re-established should an {@link IOException} occur
*/ */
ON { ON {
@Override
public boolean isSimulation() { public boolean isSimulation() {
return false; return false;
} }
@ -60,6 +62,7 @@ public enum ConnectionMode {
* {@link CommunicationConnection} accepts messages, but silently swallows them, instead of processing them * {@link CommunicationConnection} accepts messages, but silently swallows them, instead of processing them
*/ */
SIMULATION { SIMULATION {
@Override
public boolean isSimulation() { public boolean isSimulation() {
return true; return true;
} }

View File

@ -77,7 +77,7 @@ public class SimpleMessageArchive implements IoMessageArchive {
@Override @Override
public synchronized List<IoMessage> getBy(String connectionId) { public synchronized List<IoMessage> getBy(String connectionId) {
List<IoMessage> all = new ArrayList<IoMessage>(); List<IoMessage> all = new ArrayList<>();
for (IoMessage msg : this.messageArchive) { for (IoMessage msg : this.messageArchive) {
if (msg.getConnectionId().equals(connectionId)) if (msg.getConnectionId().equals(connectionId))
all.add(msg); all.add(msg);
@ -87,7 +87,7 @@ public class SimpleMessageArchive implements IoMessageArchive {
@Override @Override
public synchronized List<IoMessage> getBy(String connectionId, CommandKey key) { public synchronized List<IoMessage> getBy(String connectionId, CommandKey key) {
List<IoMessage> all = new ArrayList<IoMessage>(); List<IoMessage> all = new ArrayList<>();
for (IoMessage msg : this.messageArchive) { for (IoMessage msg : this.messageArchive) {
if (msg.getConnectionId().equals(connectionId) && msg.getKey().equals(key)) if (msg.getConnectionId().equals(connectionId) && msg.getKey().equals(key))
all.add(msg); all.add(msg);

View File

@ -162,9 +162,10 @@ public class DbSchemaVersionCheck {
Version currentVersion = null; Version currentVersion = null;
try (PreparedStatement st = con.prepareStatement(sql)) { try (PreparedStatement st = con.prepareStatement(sql)) {
st.setString(1, app); st.setString(1, app);
ResultSet rs = st.executeQuery(); try (ResultSet rs = st.executeQuery()) {
if (rs.next()) if (rs.next())
currentVersion = Version.valueOf(rs.getString(2)); currentVersion = Version.valueOf(rs.getString(2));
}
} }
return currentVersion; return currentVersion;

View File

@ -125,14 +125,10 @@ public class Version implements Comparable<Version> {
* If the numerical components are negative or the qualifier string is invalid. * If the numerical components are negative or the qualifier string is invalid.
*/ */
public Version(final int major, final int minor, final int micro, String qualifier, boolean osgiStyle) { public Version(final int major, final int minor, final int micro, String qualifier, boolean osgiStyle) {
if (qualifier == null) {
qualifier = "";
}
this.major = major; this.major = major;
this.minor = minor; this.minor = minor;
this.micro = micro; this.micro = micro;
this.qualifier = qualifier; this.qualifier = qualifier == null ? "" : qualifier;
this.versionString = null; this.versionString = null;
validate(); validate();
} }
@ -155,8 +151,8 @@ public class Version implements Comparable<Version> {
String qual = StringHelper.EMPTY; String qual = StringHelper.EMPTY;
try { try {
StringTokenizer st = new StringTokenizer(version, SEPARATOR + MAVEN_QUALIFIER_SEPARATOR StringTokenizer st = new StringTokenizer(version,
+ OSGI_QUALIFIER_SEPARATOR, true); SEPARATOR + MAVEN_QUALIFIER_SEPARATOR + OSGI_QUALIFIER_SEPARATOR, true);
maj = Integer.parseInt(st.nextToken()); maj = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens()) { // minor if (st.hasMoreTokens()) { // minor
@ -248,16 +244,14 @@ public class Version implements Comparable<Version> {
* If {@code version} is improperly formatted. * If {@code version} is improperly formatted.
*/ */
public static Version valueOf(String version) { public static Version valueOf(String version) {
if (version == null) { if (version == null)
return emptyVersion; return emptyVersion;
}
version = version.trim(); String trimmedVersion = version.trim();
if (version.length() == 0) { if (trimmedVersion.length() == 0)
return emptyVersion; return emptyVersion;
}
return new Version(version); return new Version(trimmedVersion);
} }
/** /**
@ -478,12 +472,11 @@ public class Version implements Comparable<Version> {
private String createQualifier(boolean withOsgiStyle) { private String createQualifier(boolean withOsgiStyle) {
if (this.qualifier.equals(MAVEN_SNAPSHOT_QUALIFIER) || this.qualifier.equals(OSGI_SNAPSHOT_QUALIFIER)) { if (this.qualifier.equals(MAVEN_SNAPSHOT_QUALIFIER) || this.qualifier.equals(OSGI_SNAPSHOT_QUALIFIER)) {
if (withOsgiStyle) { if (withOsgiStyle)
return OSGI_SNAPSHOT_QUALIFIER; return OSGI_SNAPSHOT_QUALIFIER;
} else { return MAVEN_SNAPSHOT_QUALIFIER;
return MAVEN_SNAPSHOT_QUALIFIER;
}
} }
return this.qualifier; return this.qualifier;
} }

View File

@ -89,7 +89,7 @@ public class Paging<T> {
*/ */
public static <T> Paging<T> asPage(List<T> list, int pageSize, int page) { public static <T> Paging<T> asPage(List<T> list, int pageSize, int page) {
Paging<T> paging = new Paging<T>(pageSize, page); Paging<T> paging = new Paging<>(pageSize, page);
paging.nrOfElements = list.size(); paging.nrOfElements = list.size();
if (paging.pageSize <= 0 || paging.pageToReturn <= 0) { if (paging.pageSize <= 0 || paging.pageToReturn <= 0) {

View File

@ -54,10 +54,8 @@ public class ExceptionHelper {
* @return * @return
*/ */
public static String getExceptionMessageWithCauses(Throwable t) { public static String getExceptionMessageWithCauses(Throwable t) {
if (t.getCause() == null)
if (t.getCause() == null) {
return getExceptionMessage(t); return getExceptionMessage(t);
}
String root = getExceptionMessageWithCauses(t.getCause()); String root = getExceptionMessageWithCauses(t.getCause());
return getExceptionMessage(t) + "\n" + root; return getExceptionMessage(t) + "\n" + root;
@ -87,10 +85,8 @@ public class ExceptionHelper {
* @return a string representation of the given {@link Throwable}'s messages including causes * @return a string representation of the given {@link Throwable}'s messages including causes
*/ */
public static String formatExceptionMessage(Throwable t) { public static String formatExceptionMessage(Throwable t) {
if (t.getCause() == null)
if (t.getCause() == null) {
return getExceptionMessage(t); return getExceptionMessage(t);
}
String root = formatExceptionMessage(t.getCause()); String root = formatExceptionMessage(t.getCause());
return getExceptionMessage(t) + "\ncause:\n" + root; return getExceptionMessage(t) + "\ncause:\n" + root;
@ -99,12 +95,13 @@ public class ExceptionHelper {
/** /**
* Returns the root cause for the given {@link Throwable} * Returns the root cause for the given {@link Throwable}
* *
* @param t * @param throwable
* the {@link Throwable} for which to get the root cause * the {@link Throwable} for which to get the root cause
* *
* @return the root cause of the given {@link Throwable} * @return the root cause of the given {@link Throwable}
*/ */
public static Throwable getRootCause(Throwable t) { public static Throwable getRootCause(Throwable throwable) {
Throwable t = throwable;
while (t.getCause() != null) { while (t.getCause() != null) {
t = t.getCause(); t = t.getCause();
} }

View File

@ -378,7 +378,7 @@ public class FileHelper {
File file = files.get(i); File file = files.get(i);
// get list of parents for this file // get list of parents for this file
List<File> parents = new ArrayList<File>(); List<File> parents = new ArrayList<>();
File parent = file.getParentFile(); File parent = file.getParentFile();
while (parent != null) { while (parent != null) {
parents.add(parent); parents.add(parent);
@ -389,7 +389,7 @@ public class FileHelper {
// and now the same for the next file // and now the same for the next file
File fileNext = files.get(i + 1); File fileNext = files.get(i + 1);
List<File> parentsNext = new ArrayList<File>(); List<File> parentsNext = new ArrayList<>();
File parentNext = fileNext.getParentFile(); File parentNext = fileNext.getParentFile();
while (parentNext != null) { while (parentNext != null) {
parentsNext.add(parentNext); parentsNext.add(parentNext);

View File

@ -54,9 +54,13 @@ public class ISO8601Duration implements DurationFormat {
* @author gattom * @author gattom
*/ */
public enum TimeDuration { public enum TimeDuration {
SECOND(1000, 'S'), MINUTE(60 * SECOND.duration(), 'M'), HOUR(60 * MINUTE.duration(), 'H'), DAY(24 * HOUR SECOND(1000, 'S'),
.duration(), 'D'), WEEK(7 * DAY.duration(), 'W'), MONTH(30 * DAY.duration(), 'M'), YEAR(12 * MONTH MINUTE(60 * SECOND.duration(), 'M'),
.duration(), 'Y'); HOUR(60 * MINUTE.duration(), 'H'),
DAY(24 * HOUR.duration(), 'D'),
WEEK(7 * DAY.duration(), 'W'),
MONTH(30 * DAY.duration(), 'M'),
YEAR(12 * MONTH.duration(), 'Y');
final long millis; final long millis;
final char isoChar; final char isoChar;
@ -74,17 +78,15 @@ public class ISO8601Duration implements DurationFormat {
char duration = isostring.charAt(unitIndex); char duration = isostring.charAt(unitIndex);
switch (duration) { switch (duration) {
case 'S': case 'S':
if (isostring.substring(0, unitIndex).contains("T")) { if (isostring.substring(0, unitIndex).contains("T"))
return SECOND; return SECOND;
} else throw new NumberFormatException(
throw new NumberFormatException(duration duration + " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1S)");
+ " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1S)");
case 'H': case 'H':
if (isostring.substring(0, unitIndex).contains("T")) { if (isostring.substring(0, unitIndex).contains("T"))
return HOUR; return HOUR;
} else throw new NumberFormatException(
throw new NumberFormatException(duration duration + " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1H)");
+ " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1H)");
case 'D': case 'D':
return DAY; return DAY;
case 'W': case 'W':
@ -92,11 +94,9 @@ public class ISO8601Duration implements DurationFormat {
case 'Y': case 'Y':
return YEAR; return YEAR;
case 'M': case 'M':
if (isostring.substring(0, unitIndex).contains("T")) { if (isostring.substring(0, unitIndex).contains("T"))
return MINUTE; return MINUTE;
} else { return MONTH;
return MONTH;
}
default: default:
throw new NumberFormatException(duration + " is not a valid unit of time in ISO8601"); throw new NumberFormatException(duration + " is not a valid unit of time in ISO8601");
} }

View File

@ -73,17 +73,15 @@ public class ISO8601Worktime implements WorktimeFormat {
char duration = isostring.charAt(unitIndex); char duration = isostring.charAt(unitIndex);
switch (duration) { switch (duration) {
case 'S': case 'S':
if (isostring.substring(0, unitIndex).contains("T")) { if (isostring.substring(0, unitIndex).contains("T"))
return SECOND; return SECOND;
} else throw new NumberFormatException(
throw new NumberFormatException(duration duration + " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1S)");
+ " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1S)");
case 'H': case 'H':
if (isostring.substring(0, unitIndex).contains("T")) { if (isostring.substring(0, unitIndex).contains("T"))
return HOUR; return HOUR;
} else throw new NumberFormatException(
throw new NumberFormatException(duration duration + " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1H)");
+ " is not a valid unit of time in ISO8601 without a preceeding T (e.g.: PT1H)");
case 'M': case 'M':
return MINUTE; return MINUTE;
default: default:
@ -143,11 +141,9 @@ public class ISO8601Worktime implements WorktimeFormat {
} while (newposition < s.length()); } while (newposition < s.length());
return newResult; return newResult;
} else {
throw new NumberFormatException(s + " cannot be parsed to ISO 8601 Duration");
} }
throw new NumberFormatException(s + " cannot be parsed to ISO 8601 Duration");
} }
/** /**

View File

@ -88,8 +88,8 @@ public class ObjectFilter {
* Default constructor initializing the filter * Default constructor initializing the filter
*/ */
public ObjectFilter() { public ObjectFilter() {
this.cache = new HashMap<Object, ObjectCache>(); this.cache = new HashMap<>();
this.keySet = new HashSet<String>(); this.keySet = new HashSet<>();
} }
/** /**
@ -439,7 +439,7 @@ public class ObjectFilter {
* @return The list of all objects registered under the given key and that need to be added. * @return The list of all objects registered under the given key and that need to be added.
*/ */
public List<Object> getAdded(String key) { public List<Object> getAdded(String key) {
List<Object> addedObjects = new LinkedList<Object>(); List<Object> addedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
@ -460,7 +460,7 @@ public class ObjectFilter {
* @return The list of all objects registered under the given key and that need to be added. * @return The list of all objects registered under the given key and that need to be added.
*/ */
public <V extends Object> List<V> getAdded(Class<V> clazz, String key) { public <V extends Object> List<V> getAdded(Class<V> clazz, String key) {
List<V> addedObjects = new LinkedList<V>(); List<V> addedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
@ -483,7 +483,7 @@ public class ObjectFilter {
* @return The list of all objects registered under the given key and that need to be updated. * @return The list of all objects registered under the given key and that need to be updated.
*/ */
public List<Object> getUpdated(String key) { public List<Object> getUpdated(String key) {
List<Object> updatedObjects = new LinkedList<Object>(); List<Object> updatedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
@ -504,7 +504,7 @@ public class ObjectFilter {
* @return The list of all objects registered under the given key and that need to be updated. * @return The list of all objects registered under the given key and that need to be updated.
*/ */
public <V extends Object> List<V> getUpdated(Class<V> clazz, String key) { public <V extends Object> List<V> getUpdated(Class<V> clazz, String key) {
List<V> updatedObjects = new LinkedList<V>(); List<V> updatedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
@ -527,7 +527,7 @@ public class ObjectFilter {
* @return The list of object registered under the given key that have, as a final action, removal. * @return The list of object registered under the given key that have, as a final action, removal.
*/ */
public List<Object> getRemoved(String key) { public List<Object> getRemoved(String key) {
List<Object> removedObjects = new LinkedList<Object>(); List<Object> removedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
@ -548,7 +548,7 @@ public class ObjectFilter {
* @return The list of object registered under the given key that have, as a final action, removal. * @return The list of object registered under the given key that have, as a final action, removal.
*/ */
public <V extends Object> List<V> getRemoved(Class<V> clazz, String key) { public <V extends Object> List<V> getRemoved(Class<V> clazz, String key) {
List<V> removedObjects = new LinkedList<V>(); List<V> removedObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) { if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
@ -573,7 +573,7 @@ public class ObjectFilter {
* @return The list of object registered under the given key that have, as a final action, removal. * @return The list of object registered under the given key that have, as a final action, removal.
*/ */
public <V extends Object> List<V> getAll(Class<V> clazz, String key) { public <V extends Object> List<V> getAll(Class<V> clazz, String key) {
List<V> objects = new LinkedList<V>(); List<V> objects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getKey().equals(key)) { if (objectCache.getKey().equals(key)) {
@ -596,7 +596,7 @@ public class ObjectFilter {
* @return The list of all objects that of the given class * @return The list of all objects that of the given class
*/ */
public <V extends Object> List<V> getAll(Class<V> clazz) { public <V extends Object> List<V> getAll(Class<V> clazz) {
List<V> objects = new LinkedList<V>(); List<V> objects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getObject().getClass() == clazz) { if (objectCache.getObject().getClass() == clazz) {
@ -618,7 +618,7 @@ public class ObjectFilter {
* @return The list of objects matching the given key. * @return The list of objects matching the given key.
*/ */
public List<Object> getAll(String key) { public List<Object> getAll(String key) {
List<Object> allObjects = new LinkedList<Object>(); List<Object> allObjects = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getKey().equals(key)) { if (objectCache.getKey().equals(key)) {
@ -638,7 +638,7 @@ public class ObjectFilter {
* @return The list of objects matching the given key. * @return The list of objects matching the given key.
*/ */
public List<ObjectCache> getCache(String key) { public List<ObjectCache> getCache(String key) {
List<ObjectCache> allCache = new LinkedList<ObjectCache>(); List<ObjectCache> allCache = new LinkedList<>();
Collection<ObjectCache> allObjs = this.cache.values(); Collection<ObjectCache> allObjs = this.cache.values();
for (ObjectCache objectCache : allObjs) { for (ObjectCache objectCache : allObjs) {
if (objectCache.getKey().equals(key)) { if (objectCache.getKey().equals(key)) {

View File

@ -33,7 +33,7 @@ public class DefaultedHashMapTest {
@Before @Before
public void setUp() { public void setUp() {
this.map = new DefaultedHashMap<String, String>("foobar"); this.map = new DefaultedHashMap<>("foobar");
this.map.put("foo", "foofoo"); this.map.put("foo", "foofoo");
} }

View File

@ -37,26 +37,27 @@ public class AesCryptoHelperTest {
// encrypt data // encrypt data
ByteArrayOutputStream encryptedOut = new ByteArrayOutputStream(); ByteArrayOutputStream encryptedOut = new ByteArrayOutputStream();
OutputStream outputStream = AesCryptoHelper.wrapEncrypt(password, salt, encryptedOut); try (OutputStream outputStream = AesCryptoHelper.wrapEncrypt(password, salt, encryptedOut)) {
outputStream.write(clearTextBytes); outputStream.write(clearTextBytes);
outputStream.flush(); outputStream.flush();
outputStream.close(); }
// decrypt data // decrypt data
byte[] encryptedBytes = encryptedOut.toByteArray(); byte[] encryptedBytes = encryptedOut.toByteArray();
ByteArrayInputStream encryptedIn = new ByteArrayInputStream(encryptedBytes); ByteArrayInputStream encryptedIn = new ByteArrayInputStream(encryptedBytes);
InputStream inputStream = AesCryptoHelper.wrapDecrypt(password, salt, encryptedIn); try (InputStream inputStream = AesCryptoHelper.wrapDecrypt(password, salt, encryptedIn)) {
ByteArrayOutputStream decryptedOut = new ByteArrayOutputStream(); ByteArrayOutputStream decryptedOut = new ByteArrayOutputStream();
byte[] readBuffer = new byte[64]; byte[] readBuffer = new byte[64];
int read = 0; int read = 0;
while ((read = inputStream.read(readBuffer)) != -1) { while ((read = inputStream.read(readBuffer)) != -1) {
decryptedOut.write(readBuffer, 0, read); decryptedOut.write(readBuffer, 0, read);
}
byte[] decryptedBytes = decryptedOut.toByteArray();
assertArrayEquals(clearTextBytes, decryptedBytes);
} }
byte[] decryptedBytes = decryptedOut.toByteArray();
assertArrayEquals(clearTextBytes, decryptedBytes);
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (ExceptionHelper.getRootCause(e).getMessage().equals("Illegal key size or default parameters")) if (ExceptionHelper.getRootCause(e).getMessage().equals("Illegal key size or default parameters"))
logger.warn("YOU ARE MISSING THE UNLIMITED JCE POLICIES and can not do AES encryption!"); logger.warn("YOU ARE MISSING THE UNLIMITED JCE POLICIES and can not do AES encryption!");
@ -75,6 +76,7 @@ public class AesCryptoHelperTest {
byte[] decryptedBytes = AesCryptoHelper.decrypt(password, salt, encryptedBytes); byte[] decryptedBytes = AesCryptoHelper.decrypt(password, salt, encryptedBytes);
assertArrayEquals(clearTextBytes, decryptedBytes); assertArrayEquals(clearTextBytes, decryptedBytes);
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (ExceptionHelper.getRootCause(e).getMessage().equals("Illegal key size or default parameters")) if (ExceptionHelper.getRootCause(e).getMessage().equals("Illegal key size or default parameters"))
logger.warn("YOU ARE MISSING THE UNLIMITED JCE POLICIES and can not do AES encryption!"); logger.warn("YOU ARE MISSING THE UNLIMITED JCE POLICIES and can not do AES encryption!");
@ -141,6 +143,7 @@ public class AesCryptoHelperTest {
String inputSha256 = StringHelper.getHexString(FileHelper.hashFileSha256(new File(clearTextFileS))); String inputSha256 = StringHelper.getHexString(FileHelper.hashFileSha256(new File(clearTextFileS)));
String doutputSha256 = StringHelper.getHexString(FileHelper.hashFileSha256(new File(decryptedFileS))); String doutputSha256 = StringHelper.getHexString(FileHelper.hashFileSha256(new File(decryptedFileS)));
assertEquals(inputSha256, doutputSha256); assertEquals(inputSha256, doutputSha256);
} catch (RuntimeException e) { } catch (RuntimeException e) {

View File

@ -39,7 +39,7 @@ public class GenerateReverseBaseEncodingAlphabets {
public static String generateReverseAlphabet(String name, byte[] alphabet) { public static String generateReverseAlphabet(String name, byte[] alphabet) {
Map<Byte, Byte> valueToIndex = new HashMap<Byte, Byte>(); Map<Byte, Byte> valueToIndex = new HashMap<>();
for (byte i = 0; i < alphabet.length; i++) { for (byte i = 0; i < alphabet.length; i++) {
Byte value = Byte.valueOf(i); Byte value = Byte.valueOf(i);
Byte key = Byte.valueOf(alphabet[value]); Byte key = Byte.valueOf(alphabet[value]);