Created
April 24, 2013 13:52
-
-
Save ittaiz/5452280 to your computer and use it in GitHub Desktop.
A test which checks which jar files some spring classes arrive from on runtime.
This was needed since "mvn dependency:tree" showed incorrect results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wixpress.springVersionBug; | |
import org.junit.*; | |
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory; | |
import org.springframework.core.GenericTypeResolver; | |
import java.security.CodeSource; | |
import static org.hamcrest.Matchers.endsWith; | |
/** | |
* @author ittaiz | |
* @since 3/24/13 | |
*/ | |
public class SpringVersionTest { | |
@Test | |
public void verifySpringBeans311InClasspath(){ | |
verifyCorrectSpringVersionInClasspathFor(AbstractAutowireCapableBeanFactory.class,"spring-beans-3.1.1.RELEASE.jar"); | |
} | |
@Test | |
public void verifySpringCore311InClasspath(){ | |
verifyCorrectSpringVersionInClasspathFor(GenericTypeResolver.class,"spring-core-3.1.1.RELEASE.jar"); | |
} | |
public void verifyCorrectSpringVersionInClasspathFor(Class springClass,String expectedJarFileName){ | |
CodeSource springClassCodeSource = springClass.getProtectionDomain().getCodeSource(); | |
Assert.assertNotNull("expecting "+expectedJarFileName+" to be loaded by non-system class loader",springClassCodeSource); | |
Assert.assertThat(springClassCodeSource.getLocation().toString(),endsWith(expectedJarFileName)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment