/**
 * Copyright 2012-2013 LMAX Ltd.
 *
 * Licensed 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.
 */
/**
 *
 * Licensed 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.
 */
package com.lmax.ant.paralleljunit;

import java.util.Queue;

import com.lmax.ant.paralleljunit.remote.controller.RemoteTestRunnerController;
import com.lmax.ant.paralleljunit.remote.controller.RemoteTestRunnerControllerFactory;

import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;

public class Worker implements Runnable
{
    private final int id;
    private final Queue<JUnitTest> testQueue;
    private final ParallelJUnitTaskConfig config;
    private final RemoteTestRunnerControllerFactory remoteTestRunnerControllerFactory;
    private final TestResultCoordinator testResultCoordinator;

    public Worker(final int id, final Queue<JUnitTest> testQueue, final ParallelJUnitTaskConfig config, final RemoteTestRunnerControllerFactory remoteTestRunnerControllerFactory,
                  final TestResultCoordinator testResultCoordinator)
    {
        this.id = id;
        this.testQueue = testQueue;
        this.config = config;
        this.remoteTestRunnerControllerFactory = remoteTestRunnerControllerFactory;
        this.testResultCoordinator = testResultCoordinator;
    }

    public void run()
    {
        final RemoteTestRunnerController remoteTestRunnerController = remoteTestRunnerControllerFactory.create(id, config);
        try
        {
            executeTestsOnRunner(remoteTestRunnerController);
        }
        finally
        {
            remoteTestRunnerController.close();
        }
    }

    private void executeTestsOnRunner(final RemoteTestRunnerController remoteTestRunnerController)
    {
        JUnitTest test;

        while ((test = testQueue.poll()) != null && testResultCoordinator.shouldContinue() && !Thread.interrupted())
        {
            testResultCoordinator.notifyResult(test, remoteTestRunnerController.execute(test), config);
        }
    }
}

@@ -592,570 +592,8 @@
  */%0A
-/**%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 pack

Fix odd file which had 2 license headers