This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MNG-6261 in repository https://gitbox.apache.org/repos/asf/maven.git
commit d16d5aa67b338d40edb23e8243c25b6974f4ab60 Author: Fabiano C. de Oliveira <fabcipri...@yaho.com.br> AuthorDate: Sun Nov 18 21:52:31 2018 -0200 refactor test case for windows --- .../maven/model/building/FileModelSourceTest.java | 37 +++++++++++--- .../building/FileModelSourceWindowsOnlyTest.java | 59 ---------------------- .../maven/model/building/OnlyOnWindowsRunner.java | 46 ----------------- 3 files changed, 31 insertions(+), 111 deletions(-) diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java index 77436c0..08eba9f 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java @@ -18,28 +18,37 @@ package org.apache.maven.model.building; * specific language governing permissions and limitations * under the License. */ - import java.io.File; import junit.framework.TestCase; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import org.apache.commons.lang3.SystemUtils; +import static org.junit.Assume.assumeTrue; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; /** * * @author fabiano */ -public class FileModelSourceTest - extends TestCase +public class FileModelSourceTest { - + + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + public FileModelSourceTest() { } /** * Test of equals method, of class FileModelSource. */ - public void testEquals() + @Test + public void testEquals() throws Exception { - File tempFile = File.createTempFile("pomTest-", ".xml"); + File tempFile = File.createTempFile( "pomTest-", ".xml" ); tempFile.deleteOnExit(); FileModelSource instance = new FileModelSource( tempFile ); @@ -49,4 +58,20 @@ public class FileModelSourceTest assertTrue( instance.equals( new FileModelSource( tempFile ) ) ); } + @Test + public void testWindowsPaths() + throws Exception + { + assumeTrue( SystemUtils.IS_OS_WINDOWS ); + + File upperCaseFolder = folder.newFolder( "TESTE" ); + String absolutePath = upperCaseFolder.getAbsolutePath(); + File lowerCaseFolder = new File( absolutePath.toLowerCase() ); + + FileModelSource upperCaseFolderSouce = new FileModelSource( upperCaseFolder ); + FileModelSource lowerCaseFolderSouce = new FileModelSource( lowerCaseFolder ); + + assertTrue( upperCaseFolderSouce.equals( lowerCaseFolderSouce ) ); + } + } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceWindowsOnlyTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceWindowsOnlyTest.java deleted file mode 100644 index 9592cc2..0000000 --- a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceWindowsOnlyTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.model.building; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import java.io.File; -import java.net.URI; -import junit.framework.TestCase; -import static junit.framework.TestCase.assertTrue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; - -/** - * - * @author fabiano - */ -@RunWith(value=OnlyOnWindowsRunner.class) -public class FileModelSourceWindowsOnlyTest { - - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - public FileModelSourceWindowsOnlyTest() { - } - - /** - * Test case for MNG-6261 windows case insensitive folder. - */ - @Test - public void testCaseInsensitiveWindowsPath() - throws Exception { - File upperCaseFolder = folder.newFolder("TESTE"); - String absolutePath = upperCaseFolder.getAbsolutePath(); - File lowerCaseFolder = new File(absolutePath.toLowerCase()); - - FileModelSource upperCaseFolderSouce = new FileModelSource(upperCaseFolder); - FileModelSource lowerCaseFolderSouce = new FileModelSource(lowerCaseFolder); - - assertTrue(upperCaseFolderSouce.equals(lowerCaseFolderSouce)); - } - -} diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/OnlyOnWindowsRunner.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/OnlyOnWindowsRunner.java deleted file mode 100644 index 11f186d..0000000 --- a/maven-model-builder/src/test/java/org/apache/maven/model/building/OnlyOnWindowsRunner.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.model.building; - -import org.apache.commons.lang3.SystemUtils; -import org.junit.internal.runners.JUnit4ClassRunner; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * - * @author Fabiano - */ -public class OnlyOnWindowsRunner extends BlockJUnit4ClassRunner -{ - - public OnlyOnWindowsRunner(Class klass) throws InitializationError - { - super(klass); - } - - @Override - public void run(RunNotifier notifier) { - if (SystemUtils.IS_OS_WINDOWS) { - super.run(notifier); - } - } -}