Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-826] Require Java 7 #7

Merged
merged 4 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
<version>32</version>
<version>33</version>
<relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -63,6 +63,7 @@
<properties>
<checkstyle.violation.ignore>RedundantThrows,NewlineAtEndOfFile,ParameterNumber,MethodLength,FileLength,ModifierOrder</checkstyle.violation.ignore>

<javaVersion>7</javaVersion>
<mavenVersion>3.0</mavenVersion>
</properties>

Expand Down Expand Up @@ -144,6 +145,13 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
33 changes: 0 additions & 33 deletions src/test/java/org/apache/maven/shared/utils/OsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.junit.After;
import org.junit.Assert;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Set;

import static org.hamcrest.CoreMatchers.*;
Expand All @@ -40,65 +38,34 @@ public class OsTest
extends Assert
{
private String origOsName;
private String origOsFamily;
private String origOsArch;
private String origOsVersion;


@Before
public void setUp()
throws Exception
{
origOsName = System.getProperty( "os.name" );
origOsArch = System.getProperty( "os.arch" );
origOsVersion = System.getProperty( "os.version" );
origOsFamily = Os.OS_FAMILY;

// and now set some special settings ;)
System.setProperty( "os.name" , "os/2" );
System.setProperty( "os.arch" , "i386" );
System.setProperty( "os.version", "2.1.32" );

// blow away the originally loaded values
setStaticOsField( "OS_NAME", "os/2" );
setStaticOsField( "OS_FAMILY", "os/2" );
setStaticOsField( "OS_ARCH", "i386" );
setStaticOsField( "OS_VERSION", "2.1.32" );
}

@After
public void tearDown()
throws Exception
{
// set the original OS settings again
System.setProperty( "os.name" , origOsName );
System.setProperty( "os.arch" , origOsArch );
System.setProperty( "os.version", origOsVersion );

// restore the originally loaded values
setStaticOsField( "OS_NAME", origOsName );
setStaticOsField( "OS_ARCH", origOsArch );
setStaticOsField( "OS_VERSION", origOsVersion );
setStaticOsField( "OS_FAMILY", origOsFamily );
}

private void setStaticOsField( String variableName, Object value )
throws NoSuchFieldException, IllegalAccessException
{
Field field = Os.class.getField( variableName );

Field modifiersField = Field.class.getDeclaredField( "modifiers" );
modifiersField.setAccessible( true );
modifiersField.setInt( field, field.getModifiers() & ~Modifier.FINAL );

field.setAccessible( true );
field.set( null, value );
}


@Test
public void testConstructor()
throws Exception
{
Os os = new Os();
os.eval();
Expand Down