From 620e6de1e6054559998605626314ab20b5f090f7 Mon Sep 17 00:00:00 2001
From: guoxiaoqi <guoxiaoqi2@huawei.com>
Date: Thu, 13 May 2021 17:26:55 +0800
Subject: [PATCH] Patch out dependency on JMockit

Signed-off-by: guoxiaoqi <guoxiaoqi2@huawei.com>
---
 .../jersey/ext/cdi1x/internal/CdiUtilTest.java     | 45 ------------
 .../internal/scanning/PackageNamesScannerTest.java | 80 ----------------------
 2 files changed, 125 deletions(-)

diff --git a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java
index 0cdafe1..bcc2a66 100644
--- a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java
+++ b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java
@@ -28,11 +28,6 @@ import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
-import mockit.Verifications;
-
 /**
  * Unit tests for {@link org.glassfish.jersey.ext.cdi1x.internal.CdiUtil}.
  *
@@ -48,34 +43,6 @@ public class CdiUtilTest {
         }
     }
 
-    @Test
-    public void getBeanManagerCustom(@Mocked final TestBeanManagerProvider custom,
-                                     @Mocked final DefaultBeanManagerProvider fallback) throws Exception {
-        CdiUtil.getBeanManager();
-
-        new Verifications() {{
-            custom.getBeanManager(); times = 1;
-            fallback.getBeanManager(); times = 0;
-        }};
-    }
-
-    @Test
-    public void getDefaultBeanManagerDefault(@Mocked final DefaultBeanManagerProvider fallback) throws Exception {
-        new MockUp<CdiUtil>() {
-            @Mock
-            @SuppressWarnings("UnusedDeclaration")
-            <T> T lookupService(final Class<T> clazz) {
-                return null;
-            }
-        };
-
-        CdiUtil.getBeanManager();
-
-        new Verifications() {{
-            fallback.getBeanManager(); times = 1;
-        }};
-    }
-
     @Priority(500)
     public static class MyServiceOne implements MyService {
     }
@@ -115,16 +82,4 @@ public class CdiUtilTest {
         assertThat(CdiUtil.createHk2InjectionManagerStore(), instanceOf(TestInjectionManagerStore.class));
     }
 
-    @Test
-    public void createHk2LocatorManagerDefault() throws Exception {
-        new MockUp<CdiUtil>() {
-            @Mock
-            @SuppressWarnings("UnusedDeclaration")
-            <T> T lookupService(final Class<T> clazz) {
-                return null;
-            }
-        };
-
-        assertThat(CdiUtil.createHk2InjectionManagerStore(), instanceOf(SingleInjectionManagerStore.class));
-    }
 }
diff --git a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java
index f8f5668..abc8c49 100644
--- a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java
+++ b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java
@@ -16,10 +16,6 @@
 
 package org.glassfish.jersey.tests.jmockit.server.internal.scanning;
 
-import mockit.Expectations;
-import mockit.Injectable;
-import mockit.Tested;
-import mockit.Verifications;
 import org.glassfish.jersey.server.internal.scanning.PackageNamesScanner;
 import org.glassfish.jersey.server.internal.scanning.ResourceFinderException;
 import org.junit.Before;
@@ -94,82 +90,6 @@ public class PackageNamesScannerTest {
         new PackageNamesScanner(createTestClassLoader("bad", createTestURLStreamHandler("bad"), jaxRsApiPath), packages, false);
     }
 
-
-    @Tested
-    PackageNamesScanner scanner1 = new PackageNamesScanner(new String[]{"javax.ws.rs"}, false);
-    @Tested
-    PackageNamesScanner scanner2 = new PackageNamesScanner(new String[]{"javax.ws.rs.core"}, false);
-    @Tested
-    PackageNamesScanner scanner3 = new PackageNamesScanner(new String[]{"javax.ws.rs.client"}, false);
-
-    /**
-     * Reproducer for OWLS-19790: When scanner is reset the underlying JAR input streams should be closed.
-     */
-    @Test
-    public void testInputStreamClosedAfterReset() throws Exception {
-        JarInputStream stream = new JarInputStream(
-                new ByteArrayInputStream("test".getBytes(), 0, 4));
-
-        new Expectations(InputStream.class){};
-
-        scanner1.reset();
-
-        scanner2.reset();
-        scanner2.reset();
-
-        scanner3.reset();
-
-        new Verifications() {{
-            stream.close();
-            times = 4;
-        }};
-    }
-
-    /**
-     * Reproducer for OWLS-19790: When scanner is closed the underlying JAR input streams should be closed as well.
-     */
-    @Test
-    public void testInputStreamClosedAfterClose()  throws Exception {
-
-        JarInputStream stream = new JarInputStream(
-                new ByteArrayInputStream("test".getBytes(), 0, 4));
-
-        new Expectations(JarInputStream.class){};
-
-        scanner1.close();
-
-        scanner2.close();
-        scanner2.close();
-
-        scanner3.close();
-
-        new Verifications() {{
-            stream.close();
-            times = 3;
-        }};
-    }
-
-    /**
-     * Reproducer for OWLS-19790: When we iterate through the all entries provided by a scanner JAR input stream should be closed.
-     */
-    @Tested
-    PackageNamesScanner scanner = new PackageNamesScanner(new String[]{"javax.ws.rs"}, false);
-    @Test
-    public void testInputStreamClosedAfterIteration(@Injectable("false") boolean recursive) throws Exception {
-        JarInputStream stream = new JarInputStream(
-                new ByteArrayInputStream("test".getBytes(), 0, 4));
-
-        new Expectations(JarInputStream.class) {{
-            stream.getNextJarEntry();
-            result = null;
-            stream.close();
-        }};
-
-        while (scanner.hasNext()) {
-            scanner.next();
-        }
-    }
-
     private ClassLoader createTestClassLoader(final String scheme,
                                               final URLStreamHandler urlStreamHandler,
                                               final String resourceFilePath) {
-- 
1.8.3.1

