XCodeManager { void callXcodeBuild(XCodeContext ctx) throws IOException, XCodeException { final CommandLineBuilder commandLineBuilder = new CommandLineBuilder(ctx); LOGGER.info("Executing xcode command: '" + commandLineBuilder.toString() + "'."); final int returnValue = Forker.forkProcess(ctx.getOut(), ctx.getProjectRootDirectory(), commandLineBuilder.createBuildCall()); if (returnValue != 0) { throw new XCodeException("Could not execute xcodebuild for configuration " + ctx.getOptions().getAllOptions().get(Options.ManagedOption.CONFIGURATION.getOptionName())); } }    }
@Test public void straightForwardTestBuildLibWithoutPredecessors() throws Exception { Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.PROJECT.getOptionName(), "MyLibrary.xcodeproj"); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "Release"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "iphoneos"); Options options = new Options(null, managedOptions); final XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), new File(projectDirectory, "MyLibrary/src/xcode"), System.out, null, options); MavenProject mavenProject = EasyMock.createMock(MavenProject.class); Build build = EasyMock.createMock(Build.class); EasyMock.expect(mavenProject.getBuild()).andStubReturn(build); EasyMock.expect(build.getDirectory()).andStubReturn(""); EasyMock.expect(mavenProject.getCompileArtifacts()).andStubReturn(Arrays.asList((Artifact) null)); EasyMock.replay(build, mavenProject); new XCodeManager().callXcodeBuild(context); }
@Ignore @Test public void invalidConfigurationTest() throws Exception { MavenProject mavenProject = EasyMock.createMock(MavenProject.class); Build build = EasyMock.createMock(Build.class); EasyMock.expect(mavenProject.getBuild()).andStubReturn(build); EasyMock.expect(build.getDirectory()).andStubReturn(""); EasyMock.expect(mavenProject.getCompileArtifacts()).andStubReturn(Arrays.asList((Artifact) null)); EasyMock.replay(build, mavenProject); Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "NON-EXISTNG_CONFIGURATION"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "iphoneos"); Options options = new Options(null, managedOptions); final XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), projectDirectory, System.out, null, options); new XCodeManager().callXcodeBuild(context); }
@Test(expected = IOException.class) public void damagedPrintStreamProvidedTest() throws Exception { MavenProject mavenProject = EasyMock.createMock(MavenProject.class); Build build = EasyMock.createMock(Build.class); EasyMock.expect(mavenProject.getBuild()).andStubReturn(build); EasyMock.expect(build.getDirectory()).andStubReturn(""); EasyMock.expect(mavenProject.getCompileArtifacts()).andStubReturn(Arrays.asList((Artifact) null)); EasyMock.replay(build, mavenProject); Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "Release"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "iphoneos"); managedOptions.put(Options.ManagedOption.PROJECT.getOptionName(), "MyLibrary.xcodeproj"); Options options = new Options(null, managedOptions); final XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), projectDirectory, new PrintStream( new ByteArrayOutputStream()) { @Override public void write(byte[] buf, int off, int len) { setError(); } }, null, options); new XCodeManager().callXcodeBuild(context); }