-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from caffinc/development
Splitting jaggr into main and util projects
- Loading branch information
Showing
31 changed files
with
265 additions
and
49 deletions.
There are no files selected for viewing
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,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>jaggr-parent</artifactId> | ||
<groupId>com.caffinc</groupId> | ||
<version>0.2.2</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>jaggr-utils</artifactId> | ||
<name>jaggr Utils</name> | ||
<description>Utilities for jaggr</description> | ||
<url>https://github.com/caffinc/jaggr</url> | ||
|
||
<developers> | ||
<developer> | ||
<name>Caffinc</name> | ||
<email>admin@caffinc.com</email> | ||
<organization>Caffinc</organization> | ||
<organizationUrl>http://www.caffinc.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>http://www.opensource.org/licenses/mit-license.php</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<url>https://github.com/caffinc/jaggr</url> | ||
</scm> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>${gson-version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
2 changes: 1 addition & 1 deletion
2
...finc/jaggr/core/utils/JsonFileReader.java → ...m/caffinc/jaggr/utils/JsonFileReader.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,4 +1,4 @@ | ||
package com.caffinc.jaggr.core.utils; | ||
package com.caffinc.jaggr.utils; | ||
|
||
import com.google.gson.Gson; | ||
|
||
|
76 changes: 76 additions & 0 deletions
76
jaggr/jaggr-utils/src/test/java/com/caffinc/jaggr/utils/JsonFileReaderTest.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,76 @@ | ||
package com.caffinc.jaggr.utils; | ||
|
||
import com.google.gson.Gson; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.FileWriter; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.*; | ||
|
||
/** | ||
* Tests the JsonFileReader utility | ||
* | ||
* @author Sriram | ||
* @since 11/27/2016 | ||
*/ | ||
public class JsonFileReaderTest { | ||
private static final String TEMP_DIR = System.getProperty("java.io.tmpdir"); | ||
private static final Random RANDOM = new Random(); | ||
private static final Gson GSON = new Gson(); | ||
|
||
@Test | ||
public void testGetFileLines() throws Exception { | ||
Path tempFilePath = Paths.get(TEMP_DIR, "jsontest" + RANDOM.nextInt() + ".json"); | ||
try { | ||
List<String> lines; | ||
try (BufferedWriter br = new BufferedWriter(new FileWriter(tempFilePath.toFile())) | ||
) { | ||
for (int i = 0; i < 10; i++) | ||
br.write(i + "\n"); | ||
} | ||
lines = JsonFileReader.getFileLines(tempFilePath.toString()); | ||
for (int i = 0; i < 10; i++) { | ||
Assert.assertEquals("Value should match value written to file", String.valueOf(i), lines.get(i)); | ||
} | ||
} finally { | ||
Files.delete(tempFilePath); | ||
} | ||
} | ||
|
||
@Test | ||
public void testReadJsonFromFile() throws Exception { | ||
Path tempFilePath = Paths.get(TEMP_DIR, "jsontest" + RANDOM.nextInt() + ".json"); | ||
try { | ||
List<Map<String, Object>> expectedData = new ArrayList<>(); | ||
try (BufferedWriter br = new BufferedWriter(new FileWriter(tempFilePath.toFile())) | ||
) { | ||
for (int i = 0; i < 10; i++) { | ||
Map<String, Object> json = new HashMap<>(); | ||
json.put("_id", (double) i); | ||
json.put("val", RANDOM.nextDouble()); | ||
expectedData.add(json); | ||
br.write(GSON.toJson(json) + "\n"); | ||
} | ||
} | ||
List<Map<String, Object>> jsonLines = JsonFileReader.readJsonFromFile(tempFilePath.toString()); | ||
for (int i = 0; i < 10; i++) { | ||
Assert.assertEquals("Value should match value written to file", expectedData.get(i), jsonLines.get(i)); | ||
} | ||
} finally { | ||
Files.delete(tempFilePath); | ||
} | ||
} | ||
|
||
@Test | ||
public void testReadJsonFromResource() throws Exception { | ||
List<Map<String, Object>> result = JsonFileReader.readJsonFromResource("raw.json"); | ||
Assert.assertEquals("There must be ten lines in the file", 10, result.size()); | ||
for (Map<String, Object> obj : result) { | ||
Assert.assertEquals("There must be 9 elements in the object", 9, obj.size()); | ||
} | ||
} | ||
} |
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,10 @@ | ||
{"index":1,"index_start_at":56,"integer":25,"float":14.0942,"name":"Mitchell","surname":"Archer","fullname":"Dennis Sherrill","email":"rita@bowman.lc","bool":false} | ||
{"index":2,"index_start_at":57,"integer":33,"float":13.9546,"name":"Miriam","surname":"Stanton","fullname":"Meredith Watson","email":"lisa@livingston.es","bool":false} | ||
{"index":3,"index_start_at":58,"integer":27,"float":18.8563,"name":"Leo","surname":"Robinson","fullname":"Brent Albright","email":"richard@richardson.do","bool":false} | ||
{"index":4,"index_start_at":59,"integer":14,"float":14.914,"name":"Dianne","surname":"Middleton","fullname":"Alex Gay","email":"melinda@glover.az","bool":false} | ||
{"index":5,"index_start_at":60,"integer":36,"float":13.7685,"name":"Dan","surname":"Kirk","fullname":"Anna Bradley","email":"alice@christensen.cr","bool":true} | ||
{"index":6,"index_start_at":61,"integer":8,"float":18.4737,"name":"Natalie","surname":"Lassiter","fullname":"Karl Cassidy","email":"jonathan@gray.vu","bool":true} | ||
{"index":7,"index_start_at":62,"integer":24,"float":15.9886,"name":"Eileen","surname":"Bunn","fullname":"Shannon Hendrix","email":"luis@king.cx","bool":true} | ||
{"index":8,"index_start_at":63,"integer":15,"float":14.8193,"name":"Clifford","surname":"Schwartz","fullname":"Sara Gilbert","email":"judith@hunt.et","bool":false} | ||
{"index":9,"index_start_at":64,"integer":33,"float":14.2817,"name":"Florence","surname":"Washington","fullname":"Thomas Casey","email":"vivian@caldwell.hn","bool":false} | ||
{"index":10,"index_start_at":65,"integer":10,"float":17.4529,"name":"Ellen","surname":"Haynes","fullname":"Lee Denton","email":"scott@wrenn.uy","bool":true} |
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,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>jaggr-parent</artifactId> | ||
<groupId>com.caffinc</groupId> | ||
<version>0.2.2</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>jaggr</artifactId> | ||
<name>jaggr</name> | ||
<description>Simple JSON Aggregator for Java</description> | ||
<url>https://github.com/caffinc/jaggr</url> | ||
|
||
<developers> | ||
<developer> | ||
<name>Caffinc</name> | ||
<email>admin@caffinc.com</email> | ||
<organization>Caffinc</organization> | ||
<organizationUrl>http://www.caffinc.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>http://www.opensource.org/licenses/mit-license.php</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<url>https://github.com/caffinc/jaggr</url> | ||
</scm> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>jaggr-utils</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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