/*
 * Copyright 2009 the original author or authors.
 *
 * 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 org.gradle.launcher.daemon.testing;

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.gradle.launcher.daemon.context.DaemonContext;
import org.gradle.launcher.daemon.context.DefaultDaemonContext;

import java.io.File;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * by Szczepan Faber, created at: 2/13/12
 */
public class DaemonContextParser {
    public static DaemonContext parseFrom(String source) {
        Pattern pattern = Pattern.compile("^.*DefaultDaemonContext\\[javaHome=([^\\n]+),daemonRegistryDir=([^\\n]+),pid=([^\\n]+),idleTimeout=(.+?),daemonOpts=([^\\n]+)].*",
                Pattern.MULTILINE + Pattern.DOTALL);
        Matcher matcher = pattern.matcher(source);

        if (matcher.matches()) {
            String javaHome = matcher.group(1);
            String daemonRegistryDir = matcher.group(2);
            Long pid = Long.parseLong(matcher.group(3));
            Integer idleTimeout = Integer.decode(matcher.group(4));
            //below won't work if some jvm opt contain comma but for testing purposes it should do
            List<String> jvmOpts = Lists.newArrayList(Splitter.on(',').split(matcher.group(5)));
            return new DefaultDaemonContext(new File(javaHome), new File(daemonRegistryDir), pid, idleTimeout, jvmOpts);
        } else {
            throw new IllegalStateException("unable to parse DefaultDaemonContext from source: [" + source + "].");
        }
    }
}

@@ -1179,16 +1179,30 @@
 ntext%5C%5C%5B
+uid=(%5B%5E%5C%5Cn%5D+),
 javaHome
@@ -1298,16 +1298,16 @@
 +)%5D.*%22,%0A
-
         
@@ -1432,24 +1432,67 @@
 atches()) %7B%0A
+            String uid = matcher.group(1);%0A
             
@@ -1515,33 +1515,33 @@
 = matcher.group(
-1
+2
 );%0A            S
@@ -1572,33 +1572,33 @@
 = matcher.group(
-2
+3
 );%0A            L
@@ -1636,17 +1636,17 @@
 r.group(
-3
+4
 ));%0A    
@@ -1708,112 +1708,13 @@
 oup(
-4
+5
 ));%0A
-            //below won't work if some jvm opt contain comma but for testing purposes it should do%0A
     
@@ -1800,17 +1800,17 @@
 r.group(
-5
+6
 )));%0A   
@@ -1850,16 +1850,21 @@
 Context(
+uid, 
 new File

Change lost during merge