-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas
authored and
Andreas
committed
Sep 21, 2023
1 parent
602ed37
commit 1b4215e
Showing
4 changed files
with
163 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/test/java"/> | ||
<classpathentry kind="src" path="src/test/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="build/classes"/> | ||
</classpath> |
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project default="build_jar" name="Create all Jars for Project VcfReader"> | ||
<property name="version" value="23.0.1" /> | ||
|
||
<property name="projectsPath" value="${user.home}/git" /> | ||
<echo message="projectsPath: ${projectsPath}" /> | ||
|
||
<property name="buildPath" value="build" /> | ||
<echo message="buildPath: ${buildPath}" /> | ||
|
||
<target name="build_jar" depends="cleanup_before, create_jar, cleanup_after" /> | ||
|
||
<target name="cleanup_before"> | ||
<delete dir="${buildPath}/bin" /> | ||
<mkdir dir="${buildPath}/bin" /> | ||
</target> | ||
|
||
<target name="create_jar"> | ||
<javac debug="true" nowarn="true" deprecation="false" destdir="${buildPath}/bin" fork="yes" source="1.8" target="1.8" srcdir="src/main/java" includeantruntime="false" encoding="UTF-8" /> | ||
|
||
<jar destfile="${buildPath}/vcf-${version}.jar"> | ||
<manifest> | ||
<attribute name="Version" value="${version}" /> | ||
</manifest> | ||
|
||
<fileset dir="${buildPath}/bin" /> | ||
|
||
<fileset dir="" includes="LICENSE.txt"/> | ||
</jar> | ||
|
||
<jar destfile="${buildPath}/vcf-${version}_sources.jar"> | ||
<manifest> | ||
<attribute name="Version" value="${version}" /> | ||
</manifest> | ||
|
||
<fileset dir="src/main/java" includes="**/*.java"/> | ||
|
||
<fileset dir="" includes="LICENSE.txt"/> | ||
</jar> | ||
</target> | ||
|
||
<target name="cleanup_after"> | ||
<delete dir="${buildPath}/bin" /> | ||
</target> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
src/test/java/de/soderer/utilities/vcf/VcfReaderWriterTest.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,67 @@ | ||
package de.soderer.utilities.vcf; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import de.soderer.utilities.vcf.utilities.BOMInputStream; | ||
|
||
public class VcfReaderWriterTest { | ||
@SuppressWarnings("resource") | ||
@Test | ||
public void test1() throws Exception { | ||
final File testfile = new File(getClass().getClassLoader().getResource("vcf/test.vcf").toURI()); | ||
|
||
File tempFile = File.createTempFile("VcfReaderWriterTest", ".vcf"); | ||
|
||
try { | ||
int cardCount = 0; | ||
try (VcfReader reader = new VcfReader(new FileInputStream(testfile)); | ||
VcfWriter writer = new VcfWriter(new FileOutputStream(tempFile), true)) { | ||
VcfCard nextCard; | ||
while ((nextCard = reader.readNextCard()) != null) { | ||
cardCount++; | ||
String version; | ||
switch (cardCount) { | ||
case 2: | ||
version = "3.0"; | ||
break; | ||
case 3: | ||
version = "4.0"; | ||
break; | ||
default: | ||
version = "2.1"; | ||
} | ||
|
||
writer.writeCard(nextCard, version); | ||
} | ||
} catch (final Exception e) { | ||
e.printStackTrace(); | ||
Assert.fail(e.getMessage()); | ||
} | ||
|
||
try (BufferedReader readerOriginal = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(testfile)).skipBOM(), StandardCharsets.UTF_8)); | ||
BufferedReader readerTest = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(tempFile)).skipBOM(), StandardCharsets.UTF_8))) { | ||
int line = 0; | ||
String nextLineOriginal; | ||
String nextLineTest; | ||
while ((nextLineOriginal = readerOriginal.readLine()) != null) { | ||
nextLineTest = readerTest.readLine(); | ||
line++; | ||
Assert.assertEquals("Unexpected data in line " + line, nextLineOriginal, nextLineTest); | ||
} | ||
} | ||
} finally { | ||
if (tempFile != null && tempFile.exists()) { | ||
tempFile.delete(); | ||
tempFile = null; | ||
} | ||
} | ||
} | ||
} |
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,43 @@ | ||
BEGIN:VCARD | ||
VERSION:2.1 | ||
N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=4D=C3=BC=73=74=65=72=6D=61=6E=6E;=45=72=69=6B=61;;=44=72=2E; | ||
FN:Dr. Erika Mustermann | ||
ORG:Wikimedia | ||
ROLE:Kommunikation | ||
TITLE:Redaktion & Gestaltung | ||
PHOTO;JPEG:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg | ||
TEL;WORK;VOICE:(0221) 9999123 | ||
TEL;HOME;VOICE:(0221) 1234567 | ||
EMAIL;PREF;INTERNET:erika@mustermann.de | ||
ADR;HOME:;;Heidestrasse 17;Koeln;;51147;Deutschland | ||
REV:2014-03-01T22:11:10Z | ||
END:VCARD | ||
BEGIN:VCARD | ||
VERSION:3.0 | ||
N:Mustermann;Erika;;Dr.; | ||
FN:Dr. Erika Mustermann | ||
ORG:Wikimedia | ||
ROLE:Kommunikation | ||
TITLE:Redaktion & Gestaltung | ||
PHOTO;VALUE=URL;TYPE=JPEG:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg | ||
TEL;TYPE=WORK,VOICE:+49 221 9999123 | ||
TEL;TYPE=HOME,VOICE:+49 221 1234567 | ||
EMAIL;TYPE=PREF,INTERNET:erika@mustermann.de | ||
ADR;TYPE=HOME:;;Heidestraße 17;Köln;;51147;Germany | ||
REV:2014-03-01T22:11:10Z | ||
URL:http://de.wikipedia.org/ | ||
END:VCARD | ||
BEGIN:VCARD | ||
VERSION:4.0 | ||
N:Mustermann;Erika;;Dr.; | ||
FN:Dr. Erika Mustermann | ||
ORG:Wikimedia | ||
ROLE:Kommunikation | ||
TITLE:Redaktion & Gestaltung | ||
PHOTO;MEDIATYPE=image/jpeg:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg | ||
TEL;TYPE=work,voice;VALUE=uri:tel:+49-221-9999123 | ||
TEL;TYPE=home,voice;VALUE=uri:tel:+49-221-1234567 | ||
EMAIL:erika@mustermann.de | ||
ADR;TYPE=home;LABEL="Heidestraße 17\n51147 Köln\nDeutschland":;;Heidestraße 17;Köln;;51147;Germany | ||
REV:2014-03-01T22:11:10Z | ||
END:VCARD |