use of org.apache.sling.scripting.api.resource.ScriptingResourceResolverProvider in project sling by apache.
the class SightlyJavaCompilerServiceTest method testObsoleteMemoryCachedUseObject.
@Test
public void testObsoleteMemoryCachedUseObject() throws Exception {
String pojoPath = "/apps/myproject/testcomponents/a/Pojo.java";
String className = "apps.myproject.testcomponents.a.Pojo";
scriptingResourceResolverProvider = Mockito.mock(ScriptingResourceResolverProvider.class);
ResourceResolver resolver = Mockito.mock(ResourceResolver.class);
when(scriptingResourceResolverProvider.getRequestScopedResourceResolver()).thenReturn(resolver);
Resource pojoResource = Mockito.mock(Resource.class);
when(pojoResource.getPath()).thenReturn(pojoPath);
when(resourceBackedPojoChangeMonitor.getLastModifiedDateForJavaUseObject(pojoPath)).thenReturn(2l);
when(pojoResource.adaptTo(InputStream.class)).thenReturn(IOUtils.toInputStream("DUMMY", "UTF-8"));
when(resolver.getResource(pojoPath)).thenReturn(pojoResource);
when(classLoaderWriter.getLastModified("/apps/myproject/testcomponents/a/Pojo.class")).thenReturn(1l);
getInstancePojoTest(className);
/*
* assuming the compiled class has a last modified date greater than the source, then the compiler should not recompile the Use
* object
*/
verify(compiler).compileSource(any(SourceIdentifier.class), anyString());
}
use of org.apache.sling.scripting.api.resource.ScriptingResourceResolverProvider in project sling by apache.
the class SightlyJavaCompilerServiceTest method testObsoleteDiskCachedUseObject.
@Test
public void testObsoleteDiskCachedUseObject() throws Exception {
String pojoPath = "/apps/myproject/testcomponents/a/Pojo.java";
String className = "apps.myproject.testcomponents.a.Pojo";
scriptingResourceResolverProvider = Mockito.mock(ScriptingResourceResolverProvider.class);
ResourceResolver resolver = Mockito.mock(ResourceResolver.class);
when(scriptingResourceResolverProvider.getRequestScopedResourceResolver()).thenReturn(resolver);
Resource pojoResource = Mockito.mock(Resource.class);
when(pojoResource.getPath()).thenReturn(pojoPath);
ResourceMetadata mockMetadata = Mockito.mock(ResourceMetadata.class);
when(mockMetadata.getModificationTime()).thenReturn(2l);
when(pojoResource.getResourceMetadata()).thenReturn(mockMetadata);
when(pojoResource.adaptTo(InputStream.class)).thenReturn(IOUtils.toInputStream("DUMMY", "UTF-8"));
when(resolver.getResource(pojoPath)).thenReturn(pojoResource);
when(classLoaderWriter.getLastModified("/apps/myproject/testcomponents/a/Pojo.class")).thenReturn(1l);
getInstancePojoTest(className);
/*
* assuming the compiled class has a last modified date greater than the source, then the compiler should not recompile the Use
* object
*/
verify(compiler).compileSource(any(SourceIdentifier.class), anyString());
}
use of org.apache.sling.scripting.api.resource.ScriptingResourceResolverProvider in project sling by apache.
the class SightlyJavaCompilerServiceTest method testMemoryCachedUseObject.
@Test
public void testMemoryCachedUseObject() throws Exception {
String pojoPath = "/apps/myproject/testcomponents/a/Pojo.java";
String className = "apps.myproject.testcomponents.a.Pojo";
scriptingResourceResolverProvider = Mockito.mock(ScriptingResourceResolverProvider.class);
ResourceResolver resolver = Mockito.mock(ResourceResolver.class);
when(scriptingResourceResolverProvider.getRequestScopedResourceResolver()).thenReturn(resolver);
Resource pojoResource = Mockito.mock(Resource.class);
when(pojoResource.getPath()).thenReturn(pojoPath);
when(resourceBackedPojoChangeMonitor.getLastModifiedDateForJavaUseObject(pojoPath)).thenReturn(1l);
when(pojoResource.adaptTo(InputStream.class)).thenReturn(IOUtils.toInputStream("DUMMY", "UTF-8"));
when(resolver.getResource(pojoPath)).thenReturn(pojoResource);
when(classLoaderWriter.getLastModified("/apps/myproject/testcomponents/a/Pojo.class")).thenReturn(2l);
getInstancePojoTest(className);
/*
* assuming the compiled class has a last modified date greater than the source, then the compiler should not recompile the Use
* object
*/
verify(compiler, never()).compileSource(any(SourceIdentifier.class), anyString());
}
use of org.apache.sling.scripting.api.resource.ScriptingResourceResolverProvider in project sling by apache.
the class SightlyJavaCompilerServiceTest method testDiskCachedUseObject.
@Test
public void testDiskCachedUseObject() throws Exception {
String pojoPath = "/apps/myproject/testcomponents/a/Pojo.java";
String className = "apps.myproject.testcomponents.a.Pojo";
scriptingResourceResolverProvider = Mockito.mock(ScriptingResourceResolverProvider.class);
ResourceResolver resolver = Mockito.mock(ResourceResolver.class);
when(scriptingResourceResolverProvider.getRequestScopedResourceResolver()).thenReturn(resolver);
Resource pojoResource = Mockito.mock(Resource.class);
when(pojoResource.getPath()).thenReturn(pojoPath);
ResourceMetadata mockMetadata = Mockito.mock(ResourceMetadata.class);
when(mockMetadata.getModificationTime()).thenReturn(1l);
when(pojoResource.getResourceMetadata()).thenReturn(mockMetadata);
when(pojoResource.adaptTo(InputStream.class)).thenReturn(IOUtils.toInputStream("DUMMY", "UTF-8"));
when(resolver.getResource(pojoPath)).thenReturn(pojoResource);
when(classLoaderWriter.getLastModified("/apps/myproject/testcomponents/a/Pojo.class")).thenReturn(2l);
getInstancePojoTest(className);
/*
* assuming the compiled class has a last modified date greater than the source, then the compiler should not recompile the Use
* object
*/
verify(compiler, never()).compileSource(any(SourceIdentifier.class), anyString());
}
Aggregations