Skip to content

Commit df4ff8f

Browse files
committed
Ignore the conversion test if running in a non-Mac OS X platform.
1 parent e82d321 commit df4ff8f

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@
8888
</plugins>
8989
</build>
9090
<dependencies>
91+
<dependency>
92+
<groupId>org.apache.commons</groupId>
93+
<artifactId>commons-lang3</artifactId>
94+
<version>3.1</version>
95+
</dependency>
9196
<dependency>
9297
<groupId>commons-codec</groupId>
9398
<artifactId>commons-codec</artifactId>

src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/jaxb/JAXBPlistParser.java

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import javax.xml.parsers.SAXParserFactory;
3838
import javax.xml.transform.sax.SAXSource;
3939

40+
import org.apache.commons.lang3.SystemUtils;
4041
import org.xml.sax.EntityResolver;
4142
import org.xml.sax.InputSource;
4243
import org.xml.sax.SAXException;
@@ -151,6 +152,10 @@ public void convert(String projectFile, String destinationProjectFile) throws IO
151152

152153
public void convert(File projectFile, File destinationProjectFile) throws IOException
153154
{
155+
if (!SystemUtils.IS_OS_MAC_OSX) {
156+
throw new UnsupportedOperationException("The pbxproj file conversion can only be performed on a Mac OS X " +
157+
"operating system as the Mac OS X specific tool 'plutil' gets called.");
158+
}
154159
Process exec = Runtime.getRuntime().exec(
155160
new String[] { "plutil", "-convert", "xml1", "-o", destinationProjectFile.getAbsolutePath(),
156161
projectFile.getAbsolutePath() });

src/test/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/jaxb/JAXBPlistParserTest.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
package com.sap.prd.mobile.ios.mios.xcodeprojreader.jaxb;
2121

2222
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.assertFalse;
2324
import static org.junit.Assert.assertNotNull;
25+
import static org.junit.Assert.assertTrue;
2426

2527
import java.io.ByteArrayInputStream;
2628
import java.io.File;
@@ -34,6 +36,7 @@
3436

3537
import junit.framework.Assert;
3638

39+
import org.apache.commons.lang3.SystemUtils;
3740
import org.custommonkey.xmlunit.XMLAssert;
3841
import org.custommonkey.xmlunit.XMLUnit;
3942
import org.junit.Test;
@@ -93,9 +96,19 @@ public void convertOpenStepToXML() throws Exception
9396
File xmlProj = File.createTempFile("project", ".pbxproj");
9497
xmlProj.deleteOnExit();
9598

96-
parser.convert(fileNameOpenStep, xmlProj.getAbsolutePath());
97-
Plist plist = parser.load(xmlProj.getAbsolutePath());
98-
assertEquals("1.0", plist.getVersion());
99+
try
100+
{
101+
parser.convert(fileNameOpenStep, xmlProj.getAbsolutePath());
102+
Plist plist = parser.load(xmlProj.getAbsolutePath());
103+
assertEquals("1.0", plist.getVersion());
104+
}
105+
catch (UnsupportedOperationException ex)
106+
{
107+
// If we are running on a non Mac OS X system an UnsupportedOperationException is expected
108+
assertFalse("The convert function should only fail on non Mac OS X systems", SystemUtils.IS_OS_MAC_OSX);
109+
assertTrue("Wrong UnsupportedOperationException message", ex.getMessage().contains("Mac OS X"));
110+
}
111+
99112
}
100113

101114
@Test(expected = javax.xml.bind.UnmarshalException.class)

0 commit comments

Comments
 (0)