poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1891289 - in /poi/trunk: poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
Date Mon, 05 Jul 2021 21:36:08 GMT
Author: kiwiwings
Date: Mon Jul  5 21:36:07 2021
New Revision: 1891289

URL: http://svn.apache.org/viewvc?rev=1891289&view=rev
Log:
deactivate TestSignatureInfo on Jdk 1.8.0 PatchLevel 292

Added:
    poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java   (with props)
Modified:
    poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java

Modified: poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java?rev=1891289&r1=1891288&r2=1891289&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
(original)
+++ poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
Mon Jul  5 21:36:07 2021
@@ -102,6 +102,7 @@ import org.apache.poi.poifs.crypt.dsig.s
 import org.apache.poi.poifs.crypt.dsig.services.TimeStampServiceValidator;
 import org.apache.poi.poifs.storage.RawDataUtil;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.util.ConditionalExecution.DisabledOnJreEx;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.TempFile;
@@ -444,6 +445,7 @@ class TestSignatureInfo {
     }
 
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void testSignSpreadsheetWithSignatureInfo() throws Exception {
         initKeyPair();
         String testFile = "hello-world-unsigned.xlsx";
@@ -467,6 +469,7 @@ class TestSignatureInfo {
     }
 
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void testSignEnvelopingDocument() throws Exception {
         String testFile = "hello-world-unsigned.xlsx";
         File sigCopy = testdata.getFile(testFile);
@@ -716,6 +719,7 @@ class TestSignatureInfo {
     }
 
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void testNonSha1() throws Exception {
         String testFile = "hello-world-unsigned.xlsx";
         initKeyPair();
@@ -745,6 +749,7 @@ class TestSignatureInfo {
 
     // Test signing of external references / hyperlinks
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void bug65214() throws Exception {
         initKeyPair();
 
@@ -783,6 +788,7 @@ class TestSignatureInfo {
     }
 
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void bug58630() throws Exception {
         // test deletion of sheet 0 and signing
         File tpl = copy(testdata.getFile("bug58630.xlsx"));
@@ -915,6 +921,7 @@ class TestSignatureInfo {
     }
 
     @Test
+    @DisabledOnJreEx("1.8.0_292")
     void testSignatureImage() throws Exception {
         initKeyPair();
 

Added: poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java?rev=1891289&view=auto
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java (added)
+++ poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java Mon Jul  5 21:36:07
2021
@@ -0,0 +1,89 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+/* ====================================================================
+   This product contains an ASLv2 licensed version of the OOXML signer
+   package from the eID Applet project
+   http://code.google.com/p/eid-applet/source/browse/trunk/README.txt
+   Copyright (C) 2008-2014 FedICT.
+   ================================================================= */
+package org.apache.poi.util;
+
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
+import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.regex.Pattern;
+
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.platform.commons.util.Preconditions;
+
+/**
+ * Collection of Junit annotations to control the executions of tests
+ */
+public class ConditionalExecution {
+    @Target({ ElementType.TYPE, ElementType.METHOD })
+    @Retention(RetentionPolicy.RUNTIME)
+    @Documented
+    @ExtendWith(DisabledOnJreExCondition.class)
+    public @interface DisabledOnJreEx {
+
+        /**
+         * Version-Strings as Regex
+         */
+        String[] value();
+
+        /**
+         * Reason to provide if the test of container ends up being disabled.
+         */
+        String disabledReason() default "";
+
+    }
+
+    public static class DisabledOnJreExCondition implements ExecutionCondition {
+
+        DisabledOnJreExCondition() {
+        }
+
+        @Override
+        public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context)
{
+            String version = Runtime.class.getPackage().getImplementationVersion();
+            return findAnnotation(context.getElement(), DisabledOnJreEx.class).filter(annotation
-> !isEnabled(annotation))
+                .map(annotation -> disabled("PatchLevel skipped", "JRE version " + version
+ " skipped"))
+                .orElseGet(() -> enabled("PatchLevel not matched"));
+        }
+
+
+        boolean isEnabled(DisabledOnJreEx annotation) {
+            String[] versions = annotation.value();
+            Preconditions.condition(versions.length > 0, "You must declare at least one
JRE version in @DisabledOnJreEx");
+            String version = Runtime.class.getPackage().getImplementationVersion();
+            return Arrays.stream(versions).noneMatch(p -> Pattern.matches(p, version));
+        }
+
+    }
+
+}

Propchange: poi/trunk/poi/src/test/java/org/apache/poi/util/ConditionalExecution.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message