[spring-extensions] branch master updated: IDP-997 Align test environment with how files are really loaded

Rod Widdowson rdw at steadingsoftware.com
Thu Jun 16 08:53:46 EDT 2016


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=ba07bab5fcc5bbb566646b8bfa6131e795d9e09b

The following commit(s) were added to refs/heads/master by this push:
       new  ba07bab   IDP-997 Align test environment with how files are really loaded
ba07bab is described below

commit ba07bab5fcc5bbb566646b8bfa6131e795d9e09b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 16 13:49:52 2016 +0100

    IDP-997 Align test environment with how files are really loaded
    
    https://issues.shibboleth.net/jira/browse/IDP-997
    
    use the SchemaAware Bean definition reader.
    
    Also add eclipse's auto-added checkstyle changes.
---
 .../ext/spring/resource/HTTPResourceTest.java      | 25 +++++++++++-----------
 .../ext/spring/resource/SVNResourceTest.java       | 14 ++++++------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/test/java/net/shibboleth/ext/spring/resource/HTTPResourceTest.java b/src/test/java/net/shibboleth/ext/spring/resource/HTTPResourceTest.java
index 7932c57..72bd648 100644
--- a/src/test/java/net/shibboleth/ext/spring/resource/HTTPResourceTest.java
+++ b/src/test/java/net/shibboleth/ext/spring/resource/HTTPResourceTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Collection;
 
+import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
 import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
 import net.shibboleth.utilities.java.support.httpclient.InMemoryCachingHttpClientBuilder;
 
@@ -55,8 +56,8 @@ public class HTTPResourceTest {
     }
 
     @Test public void existsTest() throws IOException {
-        HTTPResource existsResource = new HTTPResource(client, existsURL);
-        HTTPResource notExistsResource = new HTTPResource(client, nonExistsURL);
+        final HTTPResource existsResource = new HTTPResource(client, existsURL);
+        final HTTPResource notExistsResource = new HTTPResource(client, nonExistsURL);
 
         Assert.assertTrue(existsResource.exists());
         Assert.assertFalse(notExistsResource.exists());
@@ -86,7 +87,7 @@ public class HTTPResourceTest {
 
     @Test public void testCachedNoCache() throws IOException, InterruptedException {
 
-        TestHTTPResource what = new TestHTTPResource(client, existsURL);
+        final TestHTTPResource what = new TestHTTPResource(client, existsURL);
         Assert.assertTrue(what.exists());
         Assert.assertNull(what.getLasteCacheResponseStatus());
         Assert.assertTrue(ResourceTestHelper.compare(what, new ClassPathResource("data/document.xml")));
@@ -97,7 +98,7 @@ public class HTTPResourceTest {
 
         final InMemoryCachingHttpClientBuilder builder = new InMemoryCachingHttpClientBuilder();
         builder.setMaxCacheEntries(3);
-        TestHTTPResource what = new TestHTTPResource(builder.buildClient(), existsURL);
+        final TestHTTPResource what = new TestHTTPResource(builder.buildClient(), existsURL);
         Assert.assertTrue(what.exists());
         Assert.assertNotNull(what.getLasteCacheResponseStatus());
         Assert.assertTrue(ResourceTestHelper.compare(what, new ClassPathResource("data/document.xml")));
@@ -105,13 +106,13 @@ public class HTTPResourceTest {
         Assert.assertEquals(what.getLasteCacheResponseStatus(), CacheResponseStatus.CACHE_HIT);
     }
 
-    private GenericApplicationContext getContext(String fileName, File theDir) {
+    private GenericApplicationContext getContext(final String fileName, final File theDir) {
         final GenericApplicationContext parentContext = new GenericApplicationContext();
         parentContext.refresh(); // THIS IS REQUIRED
         parentContext.getBeanFactory().registerSingleton("theDir", theDir);
 
         final GenericApplicationContext context = new GenericApplicationContext(parentContext);
-        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(context);
+        final XmlBeanDefinitionReader beanDefinitionReader = new SchemaTypeAwareXMLBeanDefinitionReader(context);
 
         beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
         beanDefinitionReader.loadBeanDefinitions(fileName);
@@ -124,7 +125,7 @@ public class HTTPResourceTest {
         final GenericApplicationContext context = getContext("classpath:data/MemBackedHTTPBean.xml", null);
         try {
 
-            Collection<TestHTTPResource> beans = context.getBeansOfType(TestHTTPResource.class).values();
+            final Collection<TestHTTPResource> beans = context.getBeansOfType(TestHTTPResource.class).values();
             Assert.assertEquals(beans.size(), 1);
 
             final TestHTTPResource what = beans.iterator().next();
@@ -140,8 +141,8 @@ public class HTTPResourceTest {
         }
     }
 
-    private void emptyDir(File dir) {
-        for (File f : dir.listFiles()) {
+    private void emptyDir(final File dir) {
+        for (final File f : dir.listFiles()) {
             if (f.isDirectory()) {
                 emptyDir(f);
             }
@@ -157,7 +158,7 @@ public class HTTPResourceTest {
         try {
             theDir = p.toFile();
             context = getContext("classpath:data/MemBackedHTTPBean.xml", null);
-            Collection<TestHTTPResource> beans = context.getBeansOfType(TestHTTPResource.class).values();
+            final Collection<TestHTTPResource> beans = context.getBeansOfType(TestHTTPResource.class).values();
             Assert.assertEquals(beans.size(), 1);
 
             final TestHTTPResource what = beans.iterator().next();
@@ -187,11 +188,11 @@ public class HTTPResourceTest {
                 count++;
                 try {
                     notExistsResource.getInputStream();
-                } catch (IOException e) {
+                } catch (final IOException e) {
                     // expected because resource does not exist
                 }
             }
-        } catch (IOException e) {
+        } catch (final IOException e) {
             Assert.fail("Bad URL", e);
         }
     }
diff --git a/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java b/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java
index 1ff85db..958b6c6 100644
--- a/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java
+++ b/src/test/java/net/shibboleth/ext/spring/resource/SVNResourceTest.java
@@ -24,6 +24,8 @@ import java.nio.file.Path;
 import java.text.ParseException;
 import java.util.Collection;
 
+import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
+
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -77,12 +79,12 @@ public class SVNResourceTest {
     }
 
     @BeforeMethod public void makeDir() throws IOException {
-        Path p = Files.createTempDirectory("SVNResourceTest");
+        final Path p = Files.createTempDirectory("SVNResourceTest");
         theDir = p.toFile();
     }
 
-    private void emptyDir(File dir) {
-        for (File f : dir.listFiles()) {
+    private void emptyDir(final File dir) {
+        for (final File f : dir.listFiles()) {
             if (f.isDirectory()) {
                 emptyDir(f);
             }
@@ -122,7 +124,7 @@ public class SVNResourceTest {
         Assert.assertTrue(resource.exists());
 
         // CHANGE IF WE CHECKIN A NEW FILE
-        long delta =
+        final long delta =
                 resource.lastModified() - new DateTime(2013, 12, 31, 16, 59, 06, 500, DateTimeZone.UTC).getMillis();
         Assert.assertTrue(delta < 501 && delta > -501);
 
@@ -130,13 +132,13 @@ public class SVNResourceTest {
 
     }
 
-    private GenericApplicationContext getContext(String fileName) {
+    private GenericApplicationContext getContext(final String fileName) {
         final GenericApplicationContext parentContext = new GenericApplicationContext();
         parentContext.refresh(); // THIS IS REQUIRED
         parentContext.getBeanFactory().registerSingleton("theDir", theDir);
 
         final GenericApplicationContext context = new GenericApplicationContext(parentContext);
-        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(context);
+        final XmlBeanDefinitionReader beanDefinitionReader = new SchemaTypeAwareXMLBeanDefinitionReader(context);
 
         beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
         beanDefinitionReader.loadBeanDefinitions(fileName);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list