Example usage for java.lang UnsupportedClassVersionError UnsupportedClassVersionError

List of usage examples for java.lang UnsupportedClassVersionError UnsupportedClassVersionError

Introduction

In this page you can find the example usage for java.lang UnsupportedClassVersionError UnsupportedClassVersionError.

Prototype

public UnsupportedClassVersionError() 

Source Link

Document

Constructs a UnsupportedClassVersionError with no detail message.

Usage

From source file:org.sonar.core.plugins.PluginClassloadersTest.java

@Test
public void detect_plugins_compiled_for_bad_java_version() throws Exception {
    thrown.expect(SonarException.class);
    thrown.expectMessage("The plugin checkstyle is not supported with Java 1.");

    ClassWorld world = mock(ClassWorld.class);
    when(world.newRealm(anyString(), any(ClassLoader.class))).thenThrow(new UnsupportedClassVersionError());

    classloaders = new PluginClassloaders(getClass().getClassLoader(), world);

    DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null).setKey("checkstyle")
            .setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
            .addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));

    classloaders.init(Arrays.<PluginMetadata>asList(checkstyle));
}