-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from hcoles/split_parent_child
Separate main process code from code that share client classpath
- Loading branch information
Showing
251 changed files
with
1,022 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>pitest-parent</artifactId> | ||
<groupId>org.pitest</groupId> | ||
<version>1.1.12-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>pitest-entry</artifactId> | ||
<name>pitest-entry</name> | ||
<url>http://pitest.org</url> | ||
<description>Pitest entry point</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> | ||
</manifest> | ||
<index>true</index> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<testNGArtifactName>none:none</testNGArtifactName> | ||
|
||
<includes> | ||
<include>org/**/Test*.java</include> | ||
<include>org/**/*Test.java</include> | ||
</includes> | ||
<excludes> | ||
<exclude>**/*$*</exclude> | ||
<exclude>com/*/**.java</exclude> | ||
<exclude>**/FullyCoveredByTestNGTesteeTest.java</exclude> | ||
</excludes> | ||
<excludedGroups>org.pitest.SystemTest</excludedGroups> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
|
||
<!-- for PowerMockAgentTest -javaagent:"${settings.localRepository}"/org/powermock/powermock-module-javaagent/${powermock.version}/powermock-module-javaagent-${powermock.version}.jar --> | ||
<argLine>-Dfoo=foo</argLine> | ||
|
||
<groups>org.pitest.SystemTest</groups> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<includes> | ||
<include>**/*.class</include> | ||
</includes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.pitest</groupId> | ||
<artifactId>pitest</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- for the xstream history store. cannot used shaded version --> | ||
<dependency> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream</artifactId> | ||
<version>1.4.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.pitest</groupId> | ||
<artifactId>pitest</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>nl.jqno.equalsverifier</groupId> | ||
<artifactId>equalsverifier</artifactId> | ||
<version>1.7.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- to verify compatibility --> | ||
<dependency> | ||
<groupId>org.easymock</groupId> | ||
<artifactId>easymock</artifactId> | ||
<version>3.3.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
14 changes: 14 additions & 0 deletions
14
pitest-entry/src/main/java/org/pitest/classinfo/AddlerHash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.pitest.classinfo; | ||
|
||
import java.util.zip.Adler32; | ||
|
||
public class AddlerHash implements HashFunction { | ||
|
||
@Override | ||
public long hash(final byte[] value) { | ||
final Adler32 adler = new Adler32(); | ||
adler.update(value); | ||
return adler.getValue(); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
pitest-entry/src/main/java/org/pitest/classinfo/ClassInfoSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.pitest.classinfo; | ||
|
||
import org.pitest.functional.Option; | ||
|
||
public interface ClassInfoSource { | ||
Option<ClassInfo> fetchClass(ClassName name); | ||
} |
19 changes: 19 additions & 0 deletions
19
pitest-entry/src/main/java/org/pitest/classinfo/NameToClassInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.pitest.classinfo; | ||
|
||
import org.pitest.functional.F; | ||
import org.pitest.functional.Option; | ||
|
||
public class NameToClassInfo implements F<ClassName, Option<ClassInfo>> { | ||
|
||
private final ClassInfoSource repository; | ||
|
||
public NameToClassInfo(final ClassInfoSource repository) { | ||
this.repository = repository; | ||
} | ||
|
||
@Override | ||
public Option<ClassInfo> apply(final ClassName a) { | ||
return this.repository.fetchClass(a); | ||
} | ||
|
||
} |
110 changes: 110 additions & 0 deletions
110
pitest-entry/src/main/java/org/pitest/classinfo/Repository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright 2011 Henry Coles | ||
* | ||
* 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.pitest.classinfo; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.pitest.functional.Option; | ||
|
||
public class Repository implements ClassInfoSource { | ||
|
||
private final HashFunction hashFunction; | ||
private final Map<ClassName, ClassInfo> knownClasses = new HashMap<ClassName, ClassInfo>(); | ||
private final Set<ClassName> unknownClasses = new HashSet<ClassName>(); | ||
private final ClassByteArraySource source; | ||
|
||
public Repository(final ClassByteArraySource source) { | ||
this(source, new AddlerHash()); | ||
} | ||
|
||
Repository(final ClassByteArraySource source, final HashFunction hashFunction) { | ||
this.source = source; | ||
this.hashFunction = hashFunction; | ||
} | ||
|
||
public boolean hasClass(final ClassName name) { | ||
return this.knownClasses.containsKey(name) || querySource(name).hasSome(); | ||
} | ||
|
||
public Option<ClassInfo> fetchClass(final Class<?> clazz) { // NO_UCD (test | ||
// only) | ||
return fetchClass(clazz.getName()); | ||
} | ||
|
||
private Option<ClassInfo> fetchClass(final String name) { | ||
return fetchClass(new ClassName(name)); | ||
} | ||
|
||
@Override | ||
public Option<ClassInfo> fetchClass(final ClassName name) { | ||
final ClassInfo info = this.knownClasses.get(name); | ||
if (info != null) { | ||
return Option.some(info); | ||
} | ||
|
||
final Option<ClassInfo> maybeInfo = nameToClassInfo(name); | ||
if (maybeInfo.hasSome()) { | ||
this.knownClasses.put(name, maybeInfo.value()); | ||
} | ||
return maybeInfo; | ||
} | ||
|
||
private Option<ClassInfo> nameToClassInfo(final ClassName name) { | ||
final Option<byte[]> bytes = querySource(name); | ||
if (bytes.hasSome()) { | ||
final ClassInfoBuilder classData = ClassInfoVisitor.getClassInfo(name, | ||
bytes.value(), this.hashFunction.hash(bytes.value())); | ||
return contructClassInfo(classData); | ||
} else { | ||
return Option.none(); | ||
} | ||
} | ||
|
||
public Option<byte[]> querySource(final ClassName name) { | ||
if (this.unknownClasses.contains(name)) { | ||
return Option.none(); | ||
} | ||
final Option<byte[]> option = this.source.getBytes(name.asJavaName()); | ||
if (option.hasSome()) { | ||
return option; | ||
} | ||
|
||
this.unknownClasses.add(name); | ||
return option; | ||
} | ||
|
||
private Option<ClassInfo> contructClassInfo(final ClassInfoBuilder classData) { | ||
return Option.some(new ClassInfo(resolveClass(classData.superClass), | ||
resolveClass(classData.outerClass), classData)); | ||
} | ||
|
||
private ClassPointer resolveClass(final String clazz) { | ||
if (clazz == null) { | ||
return new DefaultClassPointer(null); | ||
} else { | ||
final ClassInfo alreadyResolved = this.knownClasses.get(ClassName | ||
.fromString(clazz)); | ||
if (alreadyResolved != null) { | ||
return new DefaultClassPointer(alreadyResolved); | ||
} else { | ||
return new DeferredClassPointer(this, ClassName.fromString(clazz)); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.