myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: MYFACES-4225 tests
Date Tue, 06 Oct 2020 12:05:24 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 316a812  MYFACES-4225 tests
316a812 is described below

commit 316a8126c8f792a77ec5ad01829042ef170a4ecf
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Oct 6 14:05:12 2020 +0200

    MYFACES-4225 tests
---
 .../application/ResourceHandlerImplTest.java       | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
index 7452e1b..92e712b 100644
--- a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
+++ b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
@@ -35,6 +35,7 @@ import org.apache.myfaces.resource.ResourceHandlerSupport;
 import org.apache.myfaces.resource.ResourceLoader;
 import org.apache.myfaces.resource.ResourceMeta;
 import org.apache.myfaces.resource.ResourceMetaImpl;
+import org.junit.Ignore;
 import org.mockito.Mockito;
 
 /**
@@ -258,6 +259,63 @@ public class ResourceHandlerImplTest extends AbstractJsfTestCase
                 Mockito.eq("test.png"), Mockito.eq("test"), Mockito.eq("test"), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
         Mockito.verify(loader, Mockito.times(1)).createResourceMeta(
                 Mockito.any(), Mockito.eq("test"), Mockito.any(), Mockito.eq("test.png"),
Mockito.any());
+    }
+    
+    @Test
+    public void testDisabledCache()
+    {
+        ResourceLoader loader = Mockito.spy(new ClassLoaderResourceLoader(null));
+        Mockito.when(loader.resourceExists(Mockito.any())).thenReturn(true);
+
+        ResourceHandlerCache cache = Mockito.spy(new ResourceHandlerCache());   
+        Mockito.when(cache.isResourceHandlerCacheEnabled()).thenReturn(false);
+        
+        ResourceHandlerSupport support = Mockito.spy(new DefaultResourceHandlerSupport());
+        Mockito.when(support.getResourceLoaders()).thenReturn(new ResourceLoader[] { loader
});
+        
+        resourceHandler = Mockito.spy(resourceHandler);
+        Mockito.when(resourceHandler.getResourceHandlerCache()).thenReturn(cache);
+        Mockito.when(resourceHandler.getResourceHandlerSupport()).thenReturn(support);
+        
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
+
+        Mockito.verify(cache, Mockito.times(4)).getResource(
+                Mockito.eq("test.png"), Mockito.eq("test"), Mockito.eq("test"), Mockito.any());
+        Mockito.verify(cache, Mockito.times(4)).putResource(
+                Mockito.eq("test.png"), Mockito.eq("test"), Mockito.eq("test"), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
+        Mockito.verify(loader, Mockito.times(4)).createResourceMeta(
+                Mockito.any(), Mockito.eq("test"), Mockito.any(), Mockito.eq("test.png"),
Mockito.any());
+    }
+    
+    @Ignore
+    @Test
+    public void testNegativeCache()
+    {
+        ResourceLoader loader = Mockito.spy(new ClassLoaderResourceLoader(null));
+        Mockito.when(loader.resourceExists(Mockito.any())).thenReturn(false);
+
+        ResourceHandlerCache cache = Mockito.spy(new ResourceHandlerCache());   
+        
+        ResourceHandlerSupport support = Mockito.spy(new DefaultResourceHandlerSupport());
+        Mockito.when(support.getResourceLoaders()).thenReturn(new ResourceLoader[] { loader
});
+        
+        resourceHandler = Mockito.spy(resourceHandler);
+        Mockito.when(resourceHandler.getResourceHandlerCache()).thenReturn(cache);
+        Mockito.when(resourceHandler.getResourceHandlerSupport()).thenReturn(support);
+        
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
+        resourceHandler.createResource("test.png", "test", "test");
 
+        Mockito.verify(cache, Mockito.times(4)).getResource(
+                Mockito.eq("test.png"), Mockito.eq("test"), Mockito.eq("test"), Mockito.any());
+        Mockito.verify(cache, Mockito.times(1)).putResource(
+                Mockito.eq("test.png"), Mockito.eq("test"), Mockito.eq("test"), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
+        Mockito.verify(loader, Mockito.times(1)).createResourceMeta(
+                Mockito.any(), Mockito.eq("test"), Mockito.any(), Mockito.eq("test.png"),
Mockito.any());
     }
 }


Mime
View raw message