-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #6 Signed-off-by: Tony Deng <[email protected]>
- Loading branch information
Showing
4 changed files
with
97 additions
and
58 deletions.
There are no files selected for viewing
18 changes: 10 additions & 8 deletions
18
src/main/java/com/github/tonydeng/fmj/handler/DefaultCallbackHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
package com.github.tonydeng.fmj.handler; | ||
|
||
import com.github.tonydeng.fmj.runner.BaseCommandOption; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import com.google.common.collect.Lists; | ||
import lombok.Cleanup; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by tonydeng on 15/4/20. | ||
*/ | ||
@Slf4j | ||
public class DefaultCallbackHandler implements ProcessCallbackHandler { | ||
private static final Logger log = LoggerFactory.getLogger(DefaultCallbackHandler.class); | ||
|
||
|
||
@Override | ||
public String handler(InputStream inputStream) throws IOException { | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, BaseCommandOption.UTF8)); | ||
StringBuffer sb = new StringBuffer(); | ||
@Cleanup BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, BaseCommandOption.UTF8)); | ||
List<String> buffer = Lists.newArrayList(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
sb.append(line).append("\n"); | ||
buffer.add(line); | ||
} | ||
return sb.toString(); | ||
return String.join("\n", buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/java/com/github/tonydeng/fmj/utils/EncriptUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.tonydeng.fmj.utils; | ||
|
||
import com.github.tonydeng.fmj.BaseTest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Tony Deng | ||
* @version V1.0 | ||
* @date 2019-09-10 00:28 | ||
**/ | ||
@Slf4j | ||
public class EncriptUtilsTest extends BaseTest { | ||
|
||
private static final String INPUT = "12345"; | ||
|
||
@Test | ||
public void testMd5() { | ||
Assert.assertEquals("827CCB0EEA8A706C4C34A16891F84E7B",EncriptUtils.md5(INPUT)); | ||
} | ||
} |