diff --git a/.editorconfig b/.editorconfig
index f82d4e34c..9d9900e7e 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -10,3 +10,12 @@ trim_trailing_whitespace = true
# noinspection EditorConfigKeyCorrectness
continuation_indent_size = 8
+
+[{*.raml,*.yaml,*.yml}]
+indent_size = 2
+
+[{*.markdown,*.md}]
+indent_size = 2
+max_line_length = 120
+tab_width = 2
+ij_continuation_indent_size = 4
diff --git a/NOTICE b/NOTICE
index 95e810cbe..e6ddd9979 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,4 +1,4 @@
-gson-utils
+zip4jvm
Copyright 2021 Oleg Cherednik (oleg.cherednik@gmail.com)
This product includes software developed by
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index 3397c9a49..000000000
--- a/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-architect
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 2e8dc5b79..d5adba4d3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,3 +1,6 @@
+import com.github.jk1.license.filter.LicenseBundleNormalizer
+import com.github.jk1.license.render.InventoryHtmlReportRenderer
+
buildscript {
repositories {
mavenLocal()
@@ -8,8 +11,10 @@ buildscript {
plugins {
id 'jacoco'
id 'java-library'
+ id 'io.freefair.lombok' version '8.4'
+
id 'org.cadixdev.licenser' version '0.6.1'
- id 'io.franzbecker.gradle-lombok' version '5.0.0'
+ id 'com.github.jk1.dependency-license-report' version '2.5'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'signing'
@@ -25,13 +30,21 @@ repositories {
group 'ru.oleg-cherednik.zip4jvm'
version '1.11'
-sourceCompatibility = '1.8'
-targetCompatibility = '1.8'
+sourceCompatibility = JavaVersion.VERSION_1_8
+targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
+ options.compilerArgs += ['-Xlint:unchecked']
}
+configurations {
+ jar.archiveFileName = "${rootProject.name}-${version}.jar"
+}
+
+apply from: "${projectDir}/gradle/checkstyle.gradle"
+apply from: "${projectDir}/gradle/pmd.gradle"
+
dependencies {
annotationProcessor "org.projectlombok:lombok:${property('lombok.version')}"
@@ -64,9 +77,16 @@ jacocoTestReport {
}
}
-check.dependsOn jacocoTestReport
+javadoc {
+ options.addBooleanOption('Xdoclint:-missing', true)
+}
+
+check.finalizedBy(checkLicense)
+check.finalizedBy(generateLicenseReport)
+check.finalizedBy(jacocoTestReport)
test {
+ dependsOn('jar')
useTestNG()
}
@@ -76,6 +96,13 @@ license {
newLine false
}
+licenseReport {
+ configurations = ['compileClasspath', 'runtimeClasspath', 'testCompileClasspath', 'testRuntimeClasspath']
+ renderers = [new InventoryHtmlReportRenderer()]
+ allowedLicensesFile = new File("$projectDir/misc/license/allowed-licenses.json")
+ filters = [new LicenseBundleNormalizer(bundlePath: "$projectDir/misc/license/license-normalizer-bundle.json")]
+}
+
signing {
sign publishing.publications
}
diff --git a/codecov.yml b/codecov.yml
deleted file mode 100644
index 01bf6177a..000000000
--- a/codecov.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-coverage:
- range: 70..90
- round: down
- precision: 2
diff --git a/gradle/checkstyle.gradle b/gradle/checkstyle.gradle
new file mode 100644
index 000000000..6da6732ef
--- /dev/null
+++ b/gradle/checkstyle.gradle
@@ -0,0 +1,21 @@
+apply plugin: 'checkstyle'
+
+checkstyle {
+ toolVersion = '10.10.0'
+ configFile = file("${projectDir}/misc/checkstyle/checkstyle.xml")
+ ignoreFailures = false
+ maxWarnings = 0
+ maxErrors = 0
+}
+
+checkstyleMain {
+ enabled = true
+ source = 'src/main/java'
+ group = 'static analysis'
+}
+
+checkstyleTest {
+ enabled = true
+ source = 'src/test/java'
+ group = 'static analysis'
+}
diff --git a/gradle/pmd.gradle b/gradle/pmd.gradle
new file mode 100644
index 000000000..841d062d1
--- /dev/null
+++ b/gradle/pmd.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'pmd'
+
+pmd {
+ toolVersion = '6.21.0'
+ consoleOutput = false
+ rulesMinimumPriority = 5
+ ignoreFailures = false
+ ruleSets = [
+ "${projectDir}/misc/pmd/bestpractices.xml",
+ "${projectDir}/misc/pmd/codestyle.xml",
+ "${projectDir}/misc/pmd/design.xml",
+ "${projectDir}/misc/pmd/errorprone.xml",
+ "${projectDir}/misc/pmd/multithreading.xml",
+ "${projectDir}/misc/pmd/performance.xml",
+ "${projectDir}/misc/pmd/security.xml"
+ ]
+}
+
+pmdMain {
+ enabled = true
+ source = 'src/main/java'
+ group = 'static analysis'
+}
+
+pmdTest {
+ dependsOn('jar')
+ enabled = true
+ source = 'src/test/java'
+ group = 'static analysis'
+}
diff --git a/java.png b/java.png
deleted file mode 100644
index 1068d5ec8..000000000
Binary files a/java.png and /dev/null differ
diff --git a/lombok.config b/lombok.config
new file mode 100644
index 000000000..890f812f1
--- /dev/null
+++ b/lombok.config
@@ -0,0 +1,10 @@
+# https://projectlombok.org/features/configuration
+
+# configuration file is in the root of the workspace directory only
+config.stopBubbling = true
+# If true, lombok will generate a @java.beans.ConstructorProperties annotation when generating constructors.
+lombok.anyConstructor.addConstructorProperties=true
+# Do not use experimental annotations
+lombok.experimental.flagUsage=ERROR
+# Lombok marks generated code with @lombok.Generated, so JaCoCo can understand it
+lombok.addLombokGeneratedAnnotation = true
diff --git a/misc/checkstyle/checkstyle.xml b/misc/checkstyle/checkstyle.xml
new file mode 100644
index 000000000..81f146bc0
--- /dev/null
+++ b/misc/checkstyle/checkstyle.xml
@@ -0,0 +1,523 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/license/allowed-licenses.json b/misc/license/allowed-licenses.json
new file mode 100644
index 000000000..dd621207a
--- /dev/null
+++ b/misc/license/allowed-licenses.json
@@ -0,0 +1,10 @@
+{
+ "allowedLicenses": [
+ {
+ "moduleLicense": "Apache License, Version 2.0"
+ },
+ {
+ "moduleLicense": "The MIT License"
+ }
+ ]
+}
diff --git a/misc/license/license-normalizer-bundle.json b/misc/license/license-normalizer-bundle.json
new file mode 100644
index 000000000..316fe533d
--- /dev/null
+++ b/misc/license/license-normalizer-bundle.json
@@ -0,0 +1,363 @@
+{
+ "bundles": [
+ {
+ "bundleName": "Apache-1.1",
+ "licenseName": "Apache Software License, Version 1.1",
+ "licenseUrl": "https://www.apache.org/licenses/LICENSE-1.1"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseName": "Apache License, Version 2.0",
+ "licenseUrl": "https://www.apache.org/licenses/LICENSE-2.0"
+ },
+ {
+ "bundleName": "0BSD",
+ "licenseName": "BSD Zero Clause License",
+ "licenseUrl": "https://opensource.org/licenses/0BSD"
+ },
+ {
+ "bundleName": "BSD-2-Clause",
+ "licenseName": "The 2-Clause BSD License",
+ "licenseUrl": "https://opensource.org/licenses/BSD-2-Clause"
+ },
+ {
+ "bundleName": "BSD-3-Clause",
+ "licenseName": "The 3-Clause BSD License",
+ "licenseUrl": "https://opensource.org/licenses/BSD-3-Clause"
+ },
+ {
+ "bundleName": "CC0-1.0",
+ "licenseName": "Creative Commons Legal Code",
+ "licenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/legalcode"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseName": "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0",
+ "licenseUrl": "https://oss.oracle.com/licenses/CDDL"
+ },
+ {
+ "bundleName": "CDDL-1.1",
+ "licenseName": "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1",
+ "licenseUrl": "https://oss.oracle.com/licenses/CDDL-1.1"
+ },
+ {
+ "bundleName": "CPL-1.0",
+ "licenseName": "Common Public License - v 1.0",
+ "licenseUrl": "https://www.eclipse.org/legal/cpl-v10.html"
+ },
+ {
+ "bundleName": "EPL-1.0",
+ "licenseName": "Eclipse Public License - v 1.0",
+ "licenseUrl": "http://www.eclipse.org/legal/epl-v10.html"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseName": "Eclipse Public License - v 2.0",
+ "licenseUrl": "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt"
+ },
+ {
+ "bundleName": "EDL-1.0",
+ "licenseName": "Eclipse Distribution License - v 1.0",
+ "licenseUrl": "https://www.eclipse.org/org/documents/edl-v10.html"
+ },
+ {
+ "bundleName": "GPL-1.0",
+ "licenseName": "GNU GENERAL PUBLIC LICENSE, Version 1",
+ "licenseUrl": "https://www.gnu.org/licenses/gpl-1.0"
+ },
+ {
+ "bundleName": "GPL-2.0-only",
+ "licenseName": "GNU GENERAL PUBLIC LICENSE, Version 2",
+ "licenseUrl": "https://www.gnu.org/licenses/gpl-2.0"
+ },
+ {
+ "bundleName": "GPL-3.0-only",
+ "licenseName": "GNU GENERAL PUBLIC LICENSE, Version 3",
+ "licenseUrl": "https://www.gnu.org/licenses/gpl-3.0"
+ },
+ {
+ "bundleName": "GPL-2.0 WITH Classpath-exception-2.0",
+ "licenseName": "GNU GENERAL PUBLIC LICENSE, Version 2 + Classpath Exception",
+ "licenseUrl": "https://openjdk.java.net/legal/gplv2+ce.html"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseName": "GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1",
+ "licenseUrl": "https://www.gnu.org/licenses/lgpl-2.1"
+ },
+ {
+ "bundleName": "LGPL-3.0-only",
+ "licenseName": "GNU LESSER GENERAL PUBLIC LICENSE, Version 3",
+ "licenseUrl": "https://www.gnu.org/licenses/lgpl-3.0"
+ },
+ {
+ "bundleName": "MIT",
+ "licenseName": "The MIT License",
+ "licenseUrl": "https://opensource.org/licenses/MIT"
+ },
+ {
+ "bundleName": "MPL-1.1",
+ "licenseName": "Mozilla Public License Version 1.1",
+ "licenseUrl": "https://www.mozilla.org/en-US/MPL/1.1"
+ },
+ {
+ "bundleName": "MPL-2.0",
+ "licenseName": "Mozilla Public License, Version 2.0",
+ "licenseUrl": "https://www.mozilla.org/en-US/MPL/2.0"
+ },
+ {
+ "bundleName": "Public-Domain",
+ "licenseName": "PUBLIC DOMAIN",
+ "licenseUrl": ""
+ }
+ ],
+ "transformationRules": [
+ {
+ "bundleName": "0BSD",
+ "licenseNamePattern": "BSD Zero Clause License"
+ },
+ {
+ "bundleName": "0BSD",
+ "licenseNamePattern": "BSD$"
+ },
+ {
+ "bundleName": "0BSD",
+ "licenseNamePattern": "BSD( |-)clause.*"
+ },
+ {
+ "bundleName": "0BSD",
+ "licenseNamePattern": "BSD( |-)license.*"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseNamePattern": ".*The Apache Software License, Version 2\\.0.*"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseNamePattern": ".*?Apache( |-|_)2.*"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseNamePattern": "ASL 2\\.0"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseNamePattern": ".*Apache License,?( Version)? 2.*"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseUrlPattern": ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseUrlPattern": ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html"
+ },
+ {
+ "bundleName": "Apache-2.0",
+ "licenseFileContentPattern": ".*Apache License,?( Version)? 2.*"
+ },
+ {
+ "bundleName": "Apache-1.1",
+ "licenseFileContentPattern": ".*Apache Software License, Version 1\\.1.*"
+ },
+ {
+ "bundleName": "CC0-1.0",
+ "licenseNamePattern": "CC0(( |-)1(\\.0)?)?"
+ },
+ {
+ "bundleName": "CC0-1.0",
+ "licenseUrlPattern": ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseFileContentPattern": ".*CDDL.*1\\.0"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseUrlPattern": ".*CDDL.*.?1\\.0"
+ },
+ {
+ "bundleName": "CDDL-1.1",
+ "licenseUrlPattern": ".*CDDL.*.?1\\.1"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseNamePattern": "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.0"
+ },
+ {
+ "bundleName": "CDDL-1.1",
+ "licenseNamePattern": "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.1"
+ },
+ {
+ "bundleName": "BSD-3-Clause",
+ "licenseNamePattern": ".*BSD( |-)3-clause.*"
+ },
+ {
+ "bundleName": "BSD-3-Clause",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/BSD-3-Clause"
+ },
+ {
+ "bundleName": "BSD-3-Clause",
+ "licenseNamePattern": ".*?(The )New BSD License.*"
+ },
+ {
+ "bundleName": "BSD-3-Clause",
+ "licenseNamePattern": ".*?Modified BSD License.*"
+ },
+ {
+ "bundleName": "BSD-2-Clause",
+ "licenseNamePattern": "BSD( |-)2-clause.*"
+ },
+ {
+ "bundleName": "BSD-2-Clause",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/BSD-2-Clause"
+ },
+ {
+ "bundleName": "BSD-2-Clause",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/bsd-license(\\.php)?"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseNamePattern": "Common Development and Distribution( License)?"
+ },
+ {
+ "bundleName": "CDDL-1.0",
+ "licenseNamePattern": "CDDL 1(\\.0)"
+ },
+ {
+ "bundleName": "CDDL-1.1",
+ "licenseNamePattern": "CDDL 1\\.1"
+ },
+ {
+ "bundleName": "CDDL-1.1",
+ "licenseUrlPattern": ".*(www\\.).opensource\\.org/licenses/CDDL-1\\.0"
+ },
+ {
+ "bundleName": "EPL-1.0",
+ "licenseNamePattern": "Eclipse Publish License.*(v|version)\\.?\\s?1(\\.?0)?"
+ },
+ {
+ "bundleName": "EPL-1.0",
+ "licenseNamePattern": "Eclipse Public License.*(v|version)\\.?\\s?1(\\.?0)?"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseNamePattern": "Eclipse Public License.*(v|version)\\.?\\s?2(\\.?0)?"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseUrlPattern": ".*(www\\.).opensource\\.org/licenses/EPL-2\\.0"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseUrlPattern": ".*http.?://www\\.eclipse\\.org/legal/epl-.?2\\.?0.*"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseUrlPattern": ".*http.?://www\\.eclipse\\.org/org.*/epl-.?2\\.?0.*"
+ },
+ {
+ "bundleName": "EPL-2.0",
+ "licenseUrlPattern": ".*http.?://projects\\.eclipse\\.org/.*/epl-.?2\\.?0.*"
+ },
+ {
+ "bundleName": "EDL-1.0",
+ "licenseNamePattern": "Eclipse Distribution License.*(v|version)\\.?\\s?1(\\.0)?"
+ },
+ {
+ "bundleName": "EDL-1.0",
+ "licenseUrlPattern": ".*http.?://(www\\.)?eclipse\\.org/org.*/edl-.?1\\.?0.*"
+ },
+ {
+ "bundleName": "GPL-2.0-only",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/GPL-2\\.0"
+ },
+ {
+ "bundleName": "GPL-2.0 WITH Classpath-exception-2.0",
+ "licenseNamePattern": "GNU General Public License, version 2.*classpath exception"
+ },
+ {
+ "bundleName": "GPL-2.0 WITH Classpath-exception-2.0",
+ "licenseNamePattern": "GNU General Public License, version 2.*cp?e"
+ },
+ {
+ "bundleName": "GPL-2.0 WITH Classpath-exception-2.0",
+ "licenseNamePattern": "GNU General Public License, version 2.*, with the classpath exception"
+ },
+ {
+ "bundleName": "GPL-2.0 WITH Classpath-exception-2.0",
+ "licenseNamePattern": "GPL2 w/ CPE"
+ },
+ {
+ "bundleName": "GPL-3.0-only",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/GPL-3\\.0"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/LGPL-2\\.1"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseUrlPattern": ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl-2\\.1(\\.(html|txt))?"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseNamePattern": "LGPL 2\\.1"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseNamePattern": "LGPL.*(v|version)\\.?\\s?2\\.1"
+ },
+ {
+ "bundleName": "LGPL-2.1-only",
+ "licenseUrlPattern": ".*(www\\.)?repository.jboss.org/licenses/lgpl-2.1\\.txt"
+ },
+ {
+ "bundleName": "LGPL-3.0-only",
+ "licenseUrlPattern": ".*(www\\.).opensource\\.org/licenses/LGPL-3\\.0"
+ },
+ {
+ "bundleName": "LGPL-3.0-only",
+ "licenseNamePattern": "lgplv?3"
+ },
+ {
+ "bundleName": "LGPL-3.0-only",
+ "licenseUrlPattern": ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl(-3)?(\\.(html|txt))?"
+ },
+ {
+ "bundleName": "MIT",
+ "licenseNamePattern": "(The\\s)?MIT(\\slicen(c|s)e)?(\\s\\(MIT\\))?"
+ },
+ {
+ "bundleName": "MIT",
+ "licenseUrlPattern": ".*(www\\.)?opensource\\.org/licenses/MIT(\\.php)?"
+ },
+ {
+ "bundleName": "MPL-1.1",
+ "licenseNamePattern": "MPL 1\\.1"
+ },
+ {
+ "bundleName": "MPL-2.0",
+ "licenseUrlPattern": ".*(www\\.).opensource\\.org/licenses/MPL-2\\.0"
+ },
+ {
+ "bundleName": "Public-Domain",
+ "licenseNamePattern": "((public)\\s(domain)).*",
+ "transformUrl": false
+ },
+ {
+ "bundleName": "Public-Domain",
+ "licenseFileContentPattern": ".*(Creative)\\s(Commons).*",
+ "transformUrl": false
+ },
+ {
+ "bundleName": "Public-Domain",
+ "licenseFileContentPattern": ".*((Public)\\s(Domain)).*",
+ "transformUrl": false
+ }
+ ]
+}
diff --git a/misc/pmd/bestpractices.xml b/misc/pmd/bestpractices.xml
new file mode 100644
index 000000000..019d445cc
--- /dev/null
+++ b/misc/pmd/bestpractices.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_bestpractices.html
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/pmd/codestyle.xml b/misc/pmd/codestyle.xml
new file mode 100644
index 000000000..3c2b27ea8
--- /dev/null
+++ b/misc/pmd/codestyle.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_codestyle.html
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/pmd/design.xml b/misc/pmd/design.xml
new file mode 100644
index 000000000..0d721d3bd
--- /dev/null
+++ b/misc/pmd/design.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_design.html
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/pmd/errorprone.xml b/misc/pmd/errorprone.xml
new file mode 100644
index 000000000..5e068dd36
--- /dev/null
+++ b/misc/pmd/errorprone.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_errorprone.html
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/pmd/multithreading.xml b/misc/pmd/multithreading.xml
new file mode 100644
index 000000000..a09f8be8d
--- /dev/null
+++ b/misc/pmd/multithreading.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_multithreading.html
+
+
+
+
+
+
+
+
diff --git a/misc/pmd/performance.xml b/misc/pmd/performance.xml
new file mode 100644
index 000000000..fa1c41349
--- /dev/null
+++ b/misc/pmd/performance.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_performance.html
+
+
+
+
+
+
diff --git a/misc/pmd/security.xml b/misc/pmd/security.xml
new file mode 100644
index 000000000..5adf90112
--- /dev/null
+++ b/misc/pmd/security.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ https://docs.pmd-code.org/latest/pmd_rules_java_security.html
+
+
+
+
diff --git a/src/test/java/ru/olegcherednik/zip4jvm/TestData.java b/src/test/java/ru/olegcherednik/zip4jvm/TestData.java
index f8dd55f0b..a35de61f6 100644
--- a/src/test/java/ru/olegcherednik/zip4jvm/TestData.java
+++ b/src/test/java/ru/olegcherednik/zip4jvm/TestData.java
@@ -39,9 +39,9 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TestData {
- public static final Path dirRoot = createTempDirectory("zip4jvm");
-// public static final Path dirRoot = Paths.get("/Users/o.cherednik/Documents/zip4jvm/foo");
-// public static final Path dirRoot = Paths.get("d:/zip4jvm/foo");
+ //public static final Path dirRoot = createTempDirectory("zip4jvm");
+ // public static final Path dirRoot = Paths.get("/Users/o.cherednik/Documents/zip4jvm/foo");
+ public static final Path dirRoot = Paths.get("d:/zip4jvm/foo");
public static final String dirNameSrcData = "data";
@@ -150,60 +150,65 @@ public final class TestData {
public static final Path zipDeflateSolidAes = dirRoot.resolve("deflate/solid/aes/src.zip");
// winrar
- public static final Path winRarStoreSolidZip = Paths.get("src/test/resources/winrar/store_solid_off.zip").toAbsolutePath();
- public static final Path winRarStoreSolidPkwareZip = Paths.get("src/test/resources/winrar/store_solid_pkware.zip").toAbsolutePath();
- public static final Path winRarStoreSolidAesZip = Paths.get("src/test/resources/winrar/store_solid_aes.zip").toAbsolutePath();
- public static final Path winRarDeflateSolidZip = Paths.get("src/test/resources/winrar/deflate_solid_off.zip").toAbsolutePath();
- public static final Path winRarDeflateSolidPkwareZip = Paths.get("src/test/resources/winrar/deflate_solid_pkware.zip").toAbsolutePath();
- public static final Path winRarDeflateSolidAesZip = Paths.get("src/test/resources/winrar/deflate_solid_aes.zip").toAbsolutePath();
+ private static final Path dirWinRar = Paths.get("src/test/resources/winrar").toAbsolutePath();
+ public static final Path winRarStoreSolidZip = dirWinRar.resolve("store_solid_off.zip");
+ public static final Path winRarStoreSolidPkwareZip = dirWinRar.resolve("store_solid_pkware.zip");
+ public static final Path winRarStoreSolidAesZip = dirWinRar.resolve("store_solid_aes.zip");
+ public static final Path winRarDeflateSolidZip = dirWinRar.resolve("deflate_solid_off.zip");
+ public static final Path winRarDeflateSolidPkwareZip = dirWinRar.resolve("deflate_solid_pkware.zip");
+ public static final Path winRarDeflateSolidAesZip = dirWinRar.resolve("deflate_solid_aes.zip");
// 7-Zip
- public static final Path sevenZipStoreSplitZip = Paths.get("src/test/resources/seven-zip/store_split_off/src.zip.001").toAbsolutePath();
- public static final Path sevenZipStoreSolidPkwareZip = Paths.get("src/test/resources/seven-zip/lzma_solid_aes.zip").toAbsolutePath();
- public static final Path sevenZipLzmaSolidZip = Paths.get("src/test/resources/seven-zip/lzma_solid_off.zip").toAbsolutePath();
- public static final Path sevenZipLzmaSolidAesZip = Paths.get("src/test/resources/seven-zip/lzma_solid_aes.zip").toAbsolutePath();
- public static final Path sevenZipZstdSolidZip = Paths.get("src/test/resources/seven-zip/zstd_solid_off.zip").toAbsolutePath();
- public static final Path sevenZipZstdSolidAesZip = Paths.get("src/test/resources/seven-zip/zstd_solid_aes.zip").toAbsolutePath();
+ private static final Path dirSevenZip = Paths.get("src/test/resources/seven-zip").toAbsolutePath();
+ public static final Path sevenZipStoreSplitZip = dirSevenZip.resolve("store_split_off/src.zip.001");
+ public static final Path sevenZipStoreSolidPkwareZip = dirSevenZip.resolve("lzma_solid_aes.zip");
+ public static final Path sevenZipLzmaSolidZip = dirSevenZip.resolve("lzma_solid_off.zip");
+ public static final Path sevenZipLzmaSolidAesZip = dirSevenZip.resolve("lzma_solid_aes.zip");
+ public static final Path sevenZipZstdSolidZip = dirSevenZip.resolve("zstd_solid_off.zip");
+ public static final Path sevenZipZstdSolidAesZip = dirSevenZip.resolve("zstd_solid_aes.zip");
// secure-zip
- public static final Path secureZipStoreSolidAesZip = Paths.get("src/test/resources/secure-zip/store_solid_aes.zip").toAbsolutePath();
- public static final Path secureZipStoreSplitZip = Paths.get("src/test/resources/secure-zip/store_split_off/src.zip").toAbsolutePath();
- public static final Path secureZipLzmaSolidZip = Paths.get("src/test/resources/secure-zip/lzma_solid_off.zip").toAbsolutePath();
- public static final Path secureZipBzip2SolidZip = Paths.get("src/test/resources/secure-zip/bzip2_solid_off.zip").toAbsolutePath();
- public static final Path secureZipBzip2SolidPkwareZip = Paths.get("src/test/resources/secure-zip/bzip2_solid_pkware.zip").toAbsolutePath();
- public static final Path secureZipEnhancedDeflateSolidZip = Paths.get("src/test/resources/secure-zip/ed_solid_off.zip").toAbsolutePath();
+ private static final Path dirSecureZip = Paths.get("src/test/resources/secure-zip").toAbsolutePath();
+ public static final Path secureZipStoreSolidAesZip = dirSecureZip.resolve("store_solid_aes.zip");
+ public static final Path secureZipStoreSplitZip = dirSecureZip.resolve("store_split_off/src.zip");
+ public static final Path secureZipLzmaSolidZip = dirSecureZip.resolve("lzma_solid_off.zip");
+ public static final Path secureZipBzip2SolidZip = dirSecureZip.resolve("bzip2_solid_off.zip");
+ public static final Path secureZipBzip2SolidPkwareZip = dirSecureZip.resolve("bzip2_solid_pkware.zip");
+ public static final Path secureZipEnhancedDeflateSolidZip = dirSecureZip.resolve("ed_solid_off.zip");
// strong
+ private static final Path dirSecureZipStrong = dirSecureZip.resolve("strong");
public static final Path secureZipStoreSolidAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/store_solid_aes256_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("store_solid_aes256_strong.zip");
public static final Path secureZipStoreSolidAes192StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/store_solid_aes192_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("store_solid_aes192_strong.zip");
public static final Path secureZipStoreSolidAes128StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/store_solid_aes128_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("store_solid_aes128_strong.zip");
public static final Path secureZipDeflateSolidAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/deflate_solid_aes256_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("deflate_solid_aes256_strong.zip");
public static final Path secureZipBzip2SolidAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/bzip2_solid_aes256_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("bzip2_solid_aes256_strong.zip");
public static final Path secureZipDeflate64SolidAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/deflate64_solid_aes256_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("deflate64_solid_aes256_strong.zip");
public static final Path secureZipLzmaSolidAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/lzma_solid_aes256_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("lzma_solid_aes256_strong.zip");
public static final Path secureZipBzip2SplitAes256StrongZip =
- Paths.get("src/test/resources/secure-zip/strong/bzip2_split_aes_strong/split_bzip2_aes_strong.zip").toAbsolutePath();
+ dirSecureZipStrong.resolve("bzip2_split_aes_strong/split_bzip2_aes_strong.zip");
// encrypted central directory
+ private static final Path dirSecureZipEcd = dirSecureZipStrong.resolve("ecd");
public static final Path secureZipStoreSolidAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/store_solid_aes256_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("store_solid_aes256_strong_ecd.zip");
public static final Path secureZipDeflateSolidAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/deflate_solid_aes256_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("deflate_solid_aes256_strong_ecd.zip");
public static final Path secureZipDeflate64SolidAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/deflate64_solid_aes256_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("deflate64_solid_aes256_strong_ecd.zip");
public static final Path secureZipBzip2SolidAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/bzip2_solid_aes256_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("bzip2_solid_aes256_strong_ecd.zip");
public static final Path secureZipLzmaSolidAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/lzma_solid_aes256_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("lzma_solid_aes256_strong_ecd.zip");
public static final Path secureZipBzip2SplitAes256StrongEcdZip =
- Paths.get("src/test/resources/secure-zip/strong/ecd/bzip2_split_aes_strong_ecd/split_bzip2_aes_strong_ecd.zip").toAbsolutePath();
+ dirSecureZipEcd.resolve("bzip2_split_aes_strong_ecd/split_bzip2_aes_strong_ecd.zip");
// apk
public static final Path appApk = Paths.get("src/test/resources/apk/app.apk").toAbsolutePath();
@@ -229,7 +234,7 @@ private static String getSymlinkName(String fileName, String prefix) {
private static Path createTempDirectory(String prefix) {
try {
return Files.createTempDirectory(prefix);
- } catch(IOException e) {
+ } catch (IOException e) {
throw new Zip4jvmException(e);
}
}
diff --git a/src/test/java/ru/olegcherednik/zip4jvm/ZipFileTest.java b/src/test/java/ru/olegcherednik/zip4jvm/ZipFileTest.java
index 49dc3350b..76bc2cea4 100644
--- a/src/test/java/ru/olegcherednik/zip4jvm/ZipFileTest.java
+++ b/src/test/java/ru/olegcherednik/zip4jvm/ZipFileTest.java
@@ -75,7 +75,9 @@ public static void removeDir() throws IOException {
}
public void shouldCreateZipFileWhenUseZipFileAndAddFiles() throws IOException {
- ZipEntrySettings entrySettings = ZipEntrySettings.builder().compression(Compression.STORE, CompressionLevel.NORMAL).build();
+ ZipEntrySettings entrySettings = ZipEntrySettings.builder()
+ .compression(Compression.STORE, CompressionLevel.NORMAL)
+ .build();
try (ZipFile.Writer zipFile = ZipIt.zip(file).entrySettings(entrySettings).open()) {
zipFile.add(fileBentley);
@@ -92,7 +94,9 @@ public void shouldCreateZipFileWhenUseZipFileAndAddFiles() throws IOException {
@Test(dependsOnMethods = "shouldCreateZipFileWhenUseZipFileAndAddFiles")
public void shouldAddFilesToExistedZipWhenUseZipFile() throws IOException {
- ZipEntrySettings entrySettings = ZipEntrySettings.builder().compression(Compression.STORE, CompressionLevel.NORMAL).build();
+ ZipEntrySettings entrySettings = ZipEntrySettings.builder()
+ .compression(Compression.STORE, CompressionLevel.NORMAL)
+ .build();
try (ZipFile.Writer zipFile = ZipIt.zip(file).entrySettings(entrySettings).open()) {
zipFile.add(fileDucati);
@@ -113,29 +117,38 @@ public void shouldAddFilesToExistedZipWhenUseZipFile() throws IOException {
}
public void shouldCreateZipFileWithEntryCommentWhenUseZipFile() throws IOException {
- Path file = Zip4jvmSuite.subDirNameAsMethodName(rootDir).resolve("src.zip");
+ Path zip = Zip4jvmSuite.subDirNameAsMethodName(rootDir).resolve("src.zip");
Function entrySettingsProvider = fileName -> {
if ("bentley-continental.jpg".equals(fileName))
- return ZipEntrySettings.builder().compression(Compression.STORE, CompressionLevel.NORMAL).comment("bentley-continental").build();
+ return ZipEntrySettings.builder()
+ .compression(Compression.STORE, CompressionLevel.NORMAL)
+ .comment("bentley-continental").build();
if ("ferrari-458-italia.jpg".equals(fileName))
- return ZipEntrySettings.builder().compression(Compression.DEFLATE, CompressionLevel.NORMAL).comment("ferrari-458-italia").build();
+ return ZipEntrySettings.builder()
+ .compression(Compression.DEFLATE, CompressionLevel.NORMAL)
+ .comment("ferrari-458-italia").build();
if ("wiesmann-gt-mf5.jpg".equals(fileName))
- return ZipEntrySettings.builder().compression(Compression.STORE, CompressionLevel.NORMAL).comment("wiesmann-gt-mf5").build();
+ return ZipEntrySettings.builder()
+ .compression(Compression.STORE, CompressionLevel.NORMAL)
+ .comment("wiesmann-gt-mf5").build();
return ZipEntrySettings.DEFAULT;
};
- try (ZipFile.Writer zipFile = ZipIt.zip(file).entrySettings(entrySettingsProvider).open()) {
+ try (ZipFile.Writer zipFile = ZipIt.zip(zip).entrySettings(entrySettingsProvider).open()) {
zipFile.add(fileBentley);
zipFile.add(fileFerrari);
zipFile.add(fileWiesmann);
}
- assertThatDirectory(file.getParent()).exists().hasOnlyRegularFiles(1);
- assertThatZipFile(file).exists().root().hasOnlyRegularFiles(3);
- assertThatZipFile(file).regularFile("bentley-continental.jpg").exists().hasSize(1_395_362).hasComment("bentley-continental");
- assertThatZipFile(file).regularFile("ferrari-458-italia.jpg").exists().hasSize(320_894).hasComment("ferrari-458-italia");
- assertThatZipFile(file).regularFile("wiesmann-gt-mf5.jpg").exists().hasSize(729_633).hasComment("wiesmann-gt-mf5");
+ assertThatDirectory(zip.getParent()).exists().hasOnlyRegularFiles(1);
+ assertThatZipFile(zip).exists().root().hasOnlyRegularFiles(3);
+ assertThatZipFile(zip).regularFile("bentley-continental.jpg")
+ .exists().hasSize(1_395_362).hasComment("bentley-continental");
+ assertThatZipFile(zip).regularFile("ferrari-458-italia.jpg")
+ .exists().hasSize(320_894).hasComment("ferrari-458-italia");
+ assertThatZipFile(zip).regularFile("wiesmann-gt-mf5.jpg")
+ .exists().hasSize(729_633).hasComment("wiesmann-gt-mf5");
}
// TODO add unzip tests for such ZipFile
@@ -155,20 +168,23 @@ public void shouldCreateZipFileWithEntryDifferentEncryptionAndPasswordWhenUseZip
return ZipEntrySettings.DEFAULT.toBuilder().password(Zip4jvmSuite.password).build();
};
- Path file = Zip4jvmSuite.subDirNameAsMethodName(rootDir).resolve("src.zip");
+ Path zip = Zip4jvmSuite.subDirNameAsMethodName(rootDir).resolve("src.zip");
- try (ZipFile.Writer zipFile = ZipIt.zip(file).entrySettings(entrySettingsProvider).open()) {
+ try (ZipFile.Writer zipFile = ZipIt.zip(zip).entrySettings(entrySettingsProvider).open()) {
zipFile.add(fileBentley);
zipFile.add(fileFerrari);
zipFile.add(fileWiesmann);
}
- assertThatDirectory(file.getParent()).exists().hasOnlyRegularFiles(1);
+ assertThatDirectory(zip.getParent()).exists().hasOnlyRegularFiles(1);
// TODO commented test
-// assertThatZipFile(file).exists().rootEntry().hasSubDirectories(0).hasFiles(3);
-// assertThatZipFile(file).file("bentley-continental.jpg").exists().isImage().hasSize(1_395_362).hasComment("bentley-continental");
-// assertThatZipFile(file).file("ferrari-458-italia.jpg").exists().isImage().hasSize(320_894).hasComment("ferrari-458-italia");
-// assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists().isImage().hasSize(729_633).hasComment("wiesmann-gt-mf5");
+ // assertThatZipFile(file).exists().rootEntry().hasSubDirectories(0).hasFiles(3);
+ // assertThatZipFile(file).file("bentley-continental.jpg").exists()
+ // .isImage().hasSize(1_395_362).hasComment("bentley-continental");
+ // assertThatZipFile(file).file("ferrari-458-italia.jpg").exists()
+ // .isImage().hasSize(320_894).hasComment("ferrari-458-italia");
+ // assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists()
+ // .isImage().hasSize(729_633).hasComment("wiesmann-gt-mf5");
}
public void shouldCreateZipFileWithContentWhenUseZipFile() throws IOException {
@@ -198,11 +214,11 @@ public void shouldCreateZipFileWithContentWhenUseZipFile() throws IOException {
}
// TODO commented test
-// assertThatDirectory(file.getParent()).exists().hasSubDirectories(0).hasFiles(1);
-// assertThatZipFile(file).exists().rootEntry().hasSubDirectories(0).hasFiles(3);
-// assertThatZipFile(file).file("bentley-continental.jpg").exists().isImage().hasSize(1_395_362);
-// assertThatZipFile(file).file("ferrari-458-italia.jpg").exists().isImage().hasSize(320_894);
-// assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists().isImage().hasSize(729_633);
+ // assertThatDirectory(file.getParent()).exists().hasSubDirectories(0).hasFiles(1);
+ // assertThatZipFile(file).exists().rootEntry().hasSubDirectories(0).hasFiles(3);
+ // assertThatZipFile(file).file("bentley-continental.jpg").exists().isImage().hasSize(1_395_362);
+ // assertThatZipFile(file).file("ferrari-458-italia.jpg").exists().isImage().hasSize(320_894);
+ // assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists().isImage().hasSize(729_633);
}
public void shouldCreateZipFileWithEmptyDirectoryWhenAddEmptyDirectory() throws IOException {
@@ -219,8 +235,8 @@ public void shouldCreateZipFileWithEmptyDirectoryWhenAddEmptyDirectory() throws
assertThatDirectory(zip.getParent()).exists().hasOnlyRegularFiles(1);
assertThatZipFile(zip).exists().root().hasEntries(1).hasDirectories(1);
// TODO commented test
-// assertThatZipFile(file).file("bentley-continental.jpg").exists().isImage().hasSize(1_395_362);
-// assertThatZipFile(file).file("ferrari-458-italia.jpg").exists().isImage().hasSize(320_894);
-// assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists().isImage().hasSize(729_633);
+ // assertThatZipFile(file).file("bentley-continental.jpg").exists().isImage().hasSize(1_395_362);
+ // assertThatZipFile(file).file("ferrari-458-italia.jpg").exists().isImage().hasSize(320_894);
+ // assertThatZipFile(file).file("wiesmann-gt-mf5.jpg").exists().isImage().hasSize(729_633);
}
}
diff --git a/src/test/java/ru/olegcherednik/zip4jvm/ZipItTest.java b/src/test/java/ru/olegcherednik/zip4jvm/ZipItTest.java
index 21b555d8f..ef26dfe2e 100644
--- a/src/test/java/ru/olegcherednik/zip4jvm/ZipItTest.java
+++ b/src/test/java/ru/olegcherednik/zip4jvm/ZipItTest.java
@@ -129,13 +129,13 @@ public void shouldAddRegularFilesAndDirectoriesWhenZipExistsDefaultSettings() th
}
public void shouldThrowExceptionWhenAddNullPathAndDefaultSettings() {
- assertThatThrownBy(() -> ZipIt.zip(defSingleZip).add((Path)null)).isExactlyInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> ZipIt.zip(defSingleZip).add((Path) null)).isExactlyInstanceOf(IllegalArgumentException.class);
}
public void shouldThrowExceptionWhenAddNullPathAndCustomSettings() {
ZipEntrySettings entrySettings = ZipEntrySettings.builder().compression(Compression.STORE, CompressionLevel.NORMAL).build();
ZipSettings settings = ZipSettings.builder().entrySettingsProvider(fileName -> entrySettings).build();
- assertThatThrownBy(() -> ZipIt.zip(customSingleZip).settings(settings).add((Path)null)).isExactlyInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> ZipIt.zip(customSingleZip).settings(settings).add((Path) null)).isExactlyInstanceOf(IllegalArgumentException.class);
}
public void shouldCreateZipWhenAddRegularFileAndCustomSettings() throws IOException {
@@ -240,7 +240,7 @@ public void shouldUseDefaultZipEntrySettingsWhenSetNull() throws NoSuchFieldExce
zipIt.entrySettings(entrySettings);
assertThat(getSettings(zipIt).getEntrySettingsProvider().apply("aa")).isSameAs(entrySettings);
- zipIt.entrySettings((ZipEntrySettings)null);
+ zipIt.entrySettings((ZipEntrySettings) null);
assertThat(getSettings(zipIt).getEntrySettingsProvider()).isSameAs(ZipEntrySettings.DEFAULT_PROVIDER);
}
diff --git a/src/test/java/ru/olegcherednik/zip4jvm/utils/ReflectionUtils.java b/src/test/java/ru/olegcherednik/zip4jvm/utils/ReflectionUtils.java
index 67b08b1c5..34dd8947c 100644
--- a/src/test/java/ru/olegcherednik/zip4jvm/utils/ReflectionUtils.java
+++ b/src/test/java/ru/olegcherednik/zip4jvm/utils/ReflectionUtils.java
@@ -25,34 +25,20 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import static org.assertj.core.api.Assertions.assertThat;
-/** Class provides set of methods based on java reflections: invoke constructors, static and not static methods, set or read fields. */
+/**
+ * Class provides set of methods based on java reflections: invoke constructors,
+ * static and not static methods, set or read fields.
+ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReflectionUtils {
public static T getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException {
Field field = getField(obj.getClass(), name);
field.setAccessible(true);
- return (T)field.get(obj);
- }
-
- public static T getStaticFieldValue(Class> cls, String name) throws NoSuchFieldException, IllegalAccessException {
- Field field = getField(cls, name);
- field.setAccessible(true);
- return (T)field.get(cls);
- }
-
- public static T invokeConstructor(Class cls) {
- try {
- Constructor constructor = cls.getDeclaredConstructor();
- constructor.setAccessible(true);
- return constructor.newInstance();
- } catch (Exception ignored) {
- return null;
- }
+ return (T) field.get(obj);
}
public static T invokeConstructor(Class cls, Class>[] types, Object... values) {
@@ -65,7 +51,8 @@ public static T invokeConstructor(Class cls, Class>[] types, Object...
}
}
- public static void setFieldValue(Object obj, String name, Object value) throws NoSuchFieldException, IllegalAccessException {
+ public static void setFieldValue(Object obj, String name, Object value)
+ throws NoSuchFieldException, IllegalAccessException {
Field field = getField(obj.getClass(), name);
boolean accessible = field.isAccessible();
@@ -77,100 +64,38 @@ public static void setFieldValue(Object obj, String name, Object value) throws N
}
}
- public static void setStaticFieldValue(Class> cls, String name, Object value) throws NoSuchFieldException, IllegalAccessException {
- Field field = getField(cls, name);
- boolean accessible = field.isAccessible();
-
- try {
- field.setAccessible(true);
- clearFinalModifier(field);
- setFileValue(field, null, value);
- } finally {
- field.setAccessible(accessible);
- }
- }
-
- private static void clearFinalModifier(Field field) throws NoSuchFieldException, IllegalAccessException {
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- }
-
private static void setFileValue(Field field, Object obj, Object value) throws IllegalAccessException {
if (field.getType() == int.class) {
- field.setInt(obj, (Integer)value);
+ field.setInt(obj, (Integer) value);
} else if (field.getType() == boolean.class) {
- field.setBoolean(obj, (Boolean)value);
+ field.setBoolean(obj, (Boolean) value);
} else if (field.getType() == byte.class) {
- field.setByte(obj, (Byte)value);
+ field.setByte(obj, (Byte) value);
} else if (field.getType() == char.class) {
- field.setChar(obj, (Character)value);
+ field.setChar(obj, (Character) value);
} else if (field.getType() == double.class) {
- field.setDouble(obj, (Double)value);
+ field.setDouble(obj, (Double) value);
} else if (field.getType() == long.class) {
- field.setLong(obj, (Long)value);
+ field.setLong(obj, (Long) value);
} else if (field.getType() == short.class) {
- field.setShort(obj, (Short)value);
+ field.setShort(obj, (Short) value);
} else if (field.getType() == float.class) {
- field.setFloat(obj, (Float)value);
+ field.setFloat(obj, (Float) value);
} else {
field.set(obj, value);
}
}
- public static T invokeStaticMethod(Class> cls, String name) throws Throwable {
- return invokeStaticMethod(cls, name, null);
- }
-
- public static T invokeStaticMethod(Class> cls, String name, Class> type, Object value) throws Throwable {
- return invokeStaticMethod(cls, name, new Class>[] { type }, value);
- }
-
- public static T invokeStaticMethod(Class> cls, String name, Class> type1, Class> type2, Object value1, Object value2) throws Throwable {
- return invokeStaticMethod(cls, name, new Class>[] { type1, type2 }, value1, value2);
- }
-
- public static T invokeStaticMethod(Class> cls, String name, Class> type1, Class> type2, Class> type3,
- Object value1, Object value2, Object value3) throws Throwable {
- return invokeStaticMethod(cls, name, new Class>[] { type1, type2, type3 }, value1, value2, value3);
- }
-
- public static T invokeStaticMethod(Class> cls, String name, Class>[] types, Object... values) throws Throwable {
- try {
- Method method = getMethod(cls, name, types);
- method.setAccessible(true);
- return (T)method.invoke(null, values);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
-
public static T invokeMethod(Object obj, String name) throws Throwable {
assertThat(obj).isNotInstanceOf(Class.class);
return invokeMethod(obj, name, null);
}
- public static T invokeMethod(Object obj, String name, Class> type, Object value) throws Throwable {
- assertThat(obj).isNotInstanceOf(Class.class);
- return invokeMethod(obj, name, new Class>[] { type }, value);
- }
-
- public static T invokeMethod(Object obj, String name, Class> type1, Class> type2, Object value1, Object value2) throws Throwable {
- assertThat(obj).isNotInstanceOf(Class.class);
- return invokeMethod(obj, name, new Class>[] { type1, type2 }, value1, value2);
- }
-
- public static T invokeMethod(Object obj, String name, Class> type1, Class> type2, Class> type3, Object value1, Object value2,
- Object value3) throws Throwable {
- assertThat(obj).isNotInstanceOf(Class.class);
- return invokeMethod(obj, name, new Class>[] { type1, type2, type3 }, value1, value2, value3);
- }
-
public static T invokeMethod(Object obj, String name, Class>[] types, Object... values) throws Throwable {
try {
Method method = getMethod(obj.getClass(), name, types);
method.setAccessible(true);
- return (T)method.invoke(obj, values);
+ return (T) method.invoke(obj, values);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
diff --git a/store/solid/off/src.zip b/store/solid/off/src.zip
new file mode 100644
index 000000000..f04d13578
Binary files /dev/null and b/store/solid/off/src.zip differ
diff --git a/zip.png b/zip.png
deleted file mode 100644
index 154475572..000000000
Binary files a/zip.png and /dev/null differ