Skip to content

Commit

Permalink
adds more coverage (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
codyfrehr committed Mar 2, 2024
1 parent 3f496ba commit b0d2eb3
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ If you are using our Spring Boot starter, then use the following properties to c

[source,yaml,indent=0]
----
io.xpdf.api.pdftext:
io.xpdf.api.pdf-text:
executable-path: "~/libs/pdftotext"
timeout-seconds: 60
----
Expand Down
10 changes: 5 additions & 5 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
- test all code examples from readme and javadocs to ensure they are working!
- figure out how to get github pipeline to run 32-bit architecture (might need to use docker containers...)
- set codecov failure threshold. any other configs to be aware of?
- set up github issue management and security management
- explore and update other general settings for the repo
- figure out process to deploy to maven central repo
- take into consideration repos which provide download statistics: https://blog.sonatype.com/2010/12/now-available-central-download-statistics-for-oss-projects/
- guide: https://maven.apache.org/repository/guide-central-repository-upload.html
Expand All @@ -17,6 +12,11 @@
- add dependabot to repo for automatic security updates? not sure how i feel about auto updates...
at very least, make sure notifications set up for failing pipeline security tests.
and make sure repo security well configured, and snyk configured as well as possible (login to snyk website for additional configs)
- set up github issue management and security management
- explore and update other general settings for the repo
- figure out how to get github pipeline to run 32-bit architecture (might need to use docker containers...)
- set codecov failure threshold. any other configs to be aware of?
- setup slack or discord group for questions and add badge to readme
- fix broken github links on resume and website
- reorganize SCRIBBLES into official supporting documents
- write CONTRIBUTING (is this standard name for developer instructions to contribute? DEVELOPERS seems like a better name for file maybe?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @since 1.0.0
*/
public class XpdfException extends Exception {
public abstract class XpdfException extends Exception {

public XpdfException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Common - The components shared between Xpdf APIs.
* Copyright © 2024 xpdf.io (info@xpdf.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.xpdf.api.common.exception

import io.kotest.matchers.shouldBe
import io.mockk.mockk
import org.junit.jupiter.api.Test

class XpdfProcessingExceptionTest {

@Test
fun `should initialize`() {
// given
val cause = mockk<Exception>()
val exception = XpdfProcessingException(cause)

// when then
exception.cause shouldBe cause
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Common - The components shared between Xpdf APIs.
* Copyright © 2024 xpdf.io (info@xpdf.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.xpdf.api.common.exception

import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test

class XpdfRuntimeExceptionTest {

@Test
fun `should initialize`() {
// given
val exception = XpdfRuntimeException("some message")

// when then
exception.message shouldBe "some message"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Common - The components shared between Xpdf APIs.
* Copyright © 2024 xpdf.io (info@xpdf.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.xpdf.api.common.exception

import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test

class XpdfTimeoutExceptionTest {

@Test
fun `should initialize`() {
// given
val exception = XpdfTimeoutException("some message")

// when then
exception.message shouldBe "some message"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Common - The components shared between Xpdf APIs.
* Copyright © 2024 xpdf.io (info@xpdf.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.xpdf.api.common.exception

import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test

class XpdfValidationExceptionTest {

@Test
fun `should initialize`() {
// given
val exception = XpdfValidationException("some message")

// when then
exception.message shouldBe "some message"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @since 1.0.0
*/
@Data
@ConfigurationProperties(prefix = "io.xpdf.api.pdftext")
@ConfigurationProperties(prefix = "io.xpdf.api.pdf-text")
public class PdfTextToolProperties {

private Path executablePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"properties": [
{
"name": "io.xpdf.api.pdftext.executable-path"
"name": "io.xpdf.api.pdf-text.executable-path"
},
{
"name": "io.xpdf.api.pdftext.timeout-seconds"
"name": "io.xpdf.api.pdf-text.timeout-seconds"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class PdfTextToolAutoConfigurationTest {
}

TestPropertyValues.of(
"io.xpdf.api.pdftext.executable-path=${executableFile.canonicalPath}",
"io.xpdf.api.pdftext.timeout-seconds=99"
"io.xpdf.api.pdf-text.executable-path=${executableFile.canonicalPath}",
"io.xpdf.api.pdf-text.timeout-seconds=99"
).applyTo(context)

context.register(PdfTextToolAutoConfiguration::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* PdfText API - An API for accessing a native pdftotext library.
* Copyright © 2024 xpdf.io (info@xpdf.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.xpdf.api.pdftext

import io.kotest.matchers.shouldBe
import io.xpdf.api.pdftext.options.PdfTextEncoding
import io.xpdf.api.pdftext.options.PdfTextEndOfLine
import io.xpdf.api.pdftext.options.PdfTextFormat
import org.junit.jupiter.api.Test

class PdfTextOptionsTest {

@Test
fun `should convert to string`() {
// given
val options = PdfTextOptions.builder()
.pageStart(1)
.pageStop(5)
.format(PdfTextFormat.LAYOUT)
.encoding(PdfTextEncoding.UTF_8)
.endOfLine(PdfTextEndOfLine.UNIX)
.pageBreakExcluded(true)
.ownerPassword("ownerPassword")
.userPassword("userPassword")
.build()

// when then
options.toString() shouldBe "PdfTextOptions(pageStart=1, pageStop=5, format=LAYOUT, encoding=UTF_8, endOfLine=UNIX, pageBreakExcluded=true, ownerPassword=ownerPassword, userPassword=userPassword, nativeOptions=null)"
}

}

0 comments on commit b0d2eb3

Please sign in to comment.