org.springframework.core.SpringVersion Java Examples

The following examples show how to use org.springframework.core.SpringVersion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimeEnvironmentInfo.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
private RuntimeEnvironmentInfo(Class spiClass, String implementationName, String implementationVersion,
                               String platformType, String platformApiVersion, String platformClientVersion,
                               String platformHostVersion, Map<String, String> platformSpecificInfo) {
	Assert.notNull(spiClass, "spiClass is required");
	Assert.notNull(implementationName, "implementationName is required");
	Assert.notNull(implementationVersion, "implementationVersion is required");
	Assert.notNull(platformType, "platformType is required");
	Assert.notNull(platformApiVersion, "platformApiVersion is required");
	Assert.notNull(platformClientVersion, "platformClientVersion is required");
	Assert.notNull(platformHostVersion, "platformHostVersion is required");
	this.spiVersion = RuntimeVersionUtils.getVersion(spiClass);
	this.implementationName = implementationName;
	this.implementationVersion = implementationVersion;
	this.platformType = platformType;
	this.platformApiVersion = platformApiVersion;
	this.platformClientVersion = platformClientVersion;
	this.platformHostVersion = platformHostVersion;
	this.javaVersion = System.getProperty("java.version");
	this.springVersion = SpringVersion.getVersion();
	this.springBootVersion = RuntimeVersionUtils.getSpringBootVersion();
	this.platformSpecificInfo.putAll(platformSpecificInfo);
}
 
Example #2
Source File: RuntimeEnvironmentInfoBuilderTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreatingRuntimeEnvironmentInfo() {
	RuntimeEnvironmentInfo rei = new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName("TestDeployer")
			.implementationVersion("1.0.0")
			.platformClientVersion("1.2.0")
			.platformHostVersion("1.1.0")
			.platformType("Test")
			.platformApiVersion("1")
			.addPlatformSpecificInfo("foo", "bar")
			.build();
	assertThat(rei.getSpiVersion(), is(RuntimeVersionUtils.getVersion(AppDeployer.class)));
	assertThat(rei.getImplementationName(), is("TestDeployer"));
	assertThat(rei.getImplementationVersion(), is("1.0.0"));
	assertThat(rei.getPlatformType(), is("Test"));
	assertThat(rei.getPlatformApiVersion(), is("1"));
	assertThat(rei.getPlatformClientVersion(), is("1.2.0"));
	assertThat(rei.getPlatformHostVersion(), is("1.1.0"));
	assertThat(rei.getJavaVersion(), is(System.getProperty("java.version")));
	assertThat(rei.getSpringVersion(), is(SpringVersion.getVersion()));
	assertThat(rei.getSpringBootVersion(), is(RuntimeVersionUtils.getSpringBootVersion()));
	assertThat(rei.getPlatformSpecificInfo().get("foo"), is("bar"));
}
 
Example #3
Source File: EnhancerProxyCreater.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
private String tryObjenesisProxyCreation(ClassPool cp) {
        if (cp.find("org.springframework.objenesis.SpringObjenesis") == null) {
            return "";
        }

        // do not know why 4.2.6 AND 4.3.0 does not work, probably cglib version and cache problem
        if (SpringVersion.getVersion().startsWith("4.2.6") ||
                SpringVersion.getVersion().startsWith("4.3.0")) {
            return "";
        }

        return
                "org.springframework.objenesis.SpringObjenesis objenesis = new org.springframework.objenesis.SpringObjenesis();" +
                    "if (objenesis.isWorthTrying()) {" +
//                      "try {" +
                            "Class proxyClass = e.createClass();" +
                            "Object proxyInstance = objenesis.newInstance(proxyClass, false);" +
                            "((org.springframework.cglib.proxy.Factory) proxyInstance).setCallbacks(new org.springframework.cglib.proxy.Callback[] {handler});" +
                            "return proxyInstance;" +
//                      "}" +
//                      "catch (Throwable ex) {}" +
                    "}";
    }
 
Example #4
Source File: ServerlessServletEmbeddedServerFactoryTest.java    From aws-serverless-java-container with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void before() {
    // We skip the tests if we are running against Spring 5.2.x - SpringBoot 1.5 is deprecated and no longer
    // breaking changes in the latest Spring releases have not been supported in it.
    // TODO: Update the check to verify any Spring version above 5.2
    assumeFalse(Objects.requireNonNull(SpringVersion.getVersion()).startsWith("5.2"));
}
 
Example #5
Source File: SpringBootSecurityTest.java    From aws-serverless-java-container with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void before() {
    // We skip the tests if we are running against Spring 5.2.x - SpringBoot 1.5 is deprecated and no longer
    // breaking changes in the latest Spring releases have not been supported in it.
    // TODO: Update the check to verify any Spring version above 5.2
    assumeFalse(Objects.requireNonNull(SpringVersion.getVersion()).startsWith("5.2"));
}
 
Example #6
Source File: SpringBootAppTest.java    From aws-serverless-java-container with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void before() {
    // We skip the tests if we are running against Spring 5.2.x - SpringBoot 1.5 is deprecated and no longer
    // breaking changes in the latest Spring releases have not been supported in it.
    // TODO: Update the check to verify any Spring version above 5.2
    assumeFalse(Objects.requireNonNull(SpringVersion.getVersion()).startsWith("5.2"));
}
 
Example #7
Source File: SpringMvcTest.java    From bugsnag-java with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void springVersionSetCorrectly() {
    callRuntimeExceptionEndpoint();

    Report report = verifyAndGetReport(delivery);

    // Check that the Spring version is set as expected
    Map<String, Object> deviceMetadata = report.getDevice();
    Map<String, Object> runtimeVersions =
            (Map<String, Object>) deviceMetadata.get("runtimeVersions");
    assertEquals(SpringVersion.getVersion(), runtimeVersions.get("springFramework"));
    assertEquals(SpringBootVersion.getVersion(), runtimeVersions.get("springBoot"));
}
 
Example #8
Source File: DefaultObjectDirectoryMapper.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
private static ConverterManager createDefaultConverterManager() {
    String springVersion = SpringVersion.getVersion();
    if(springVersion == null) {
        LOG.debug("Could not determine the Spring Version. Guessing > Spring 3.0. If this does not work, please ensure to explicitly set converterManager");
        return new ConversionServiceConverterManager();
    } else if(springVersion.compareTo("3.0") > 0) {
        return new ConversionServiceConverterManager();
    } else {
        return new ConverterManagerImpl();
    }
}
 
Example #9
Source File: DefaultObjectDirectoryMapperTest.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@Test
public void springVersionIsNull() {
    spy(SpringVersion.class);
    when(SpringVersion.getVersion()).thenReturn(null);

    DefaultObjectDirectoryMapper mapper = new DefaultObjectDirectoryMapper();

    // LDAP-300
    assertThat(Whitebox.getInternalState(mapper,"converterManager")).isNotNull();
}
 
Example #10
Source File: InternalBar.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	System.err.println(SpringVersion.getVersion());
}
 
Example #11
Source File: BugsnagSpringConfiguration.java    From bugsnag-java with MIT License 4 votes vote down vote up
private void addSpringRuntimeVersion(Map<String, Object> device) {
    Diagnostics.addDeviceRuntimeVersion(device, "springFramework", SpringVersion.getVersion());
}
 
Example #12
Source File: VersionObtainer.java    From tutorials with MIT License 4 votes vote down vote up
public String getSpringVersion() {
    return SpringVersion.getVersion();
}