8000 support Java 10 by BugDiver · Pull Request #182 · getgauge/gauge-java · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

support Java 10 #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ os:
- linux
language: java
jdk:
- oraclejdk8
- oraclejdk10
env:
- GOPATH="/tmp" GAUGE_ROOT="/tmp/gauge" GAUGE_TELEMETRY_ENABLED=false
before_install:
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cache:
environment:
GAUGE_TELEMETRY_ENABLED: false
GAUGE_PREFIX: C:\Program Files\Gauge\bin
JAVA_HOME: C:\Program Files\Java\jdk10
build_script:
- ps: >-
$env:Path="$env:ProgramFiles\Gauge\bin;C:\maven\apache-maven-3.3.9\bin;" + [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Expand Down
59 changes: 8 additions & 51 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.10.0</version>
<version>3.11.1</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand All @@ -36,34 +36,16 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand All @@ -73,14 +55,13 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.0-jre</version>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -146,8 +127,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>10</source>
<target>10</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -226,33 +207,9 @@
</licenses>
<developers>
<developer>
<name>Prateek Baheti</name>
<email>prateektheone@gmail.com</email>
<organization>Thoughtworks</organization>
<organizationUrl>http://thoughtworks.com/</organizationUrl>
</developer>
<developer>
<name>Kashish Munjal</name>
<email>kashishmunjal64@gmail.com</email>
<organization>Thoughtworks</organization>
<organizationUrl>http://thoughtworks.com/</organizationUrl>
</developer>
<developer>
<name>Apoorva M</name>
<email>apoorva_rarefriend@yahoo.com</email>
<organization>Thoughtworks</organization>
<organizationUrl>http://thoughtworks.com/</organizationUrl>
</developer>
<developer>
<name>Srikanth V</name>
<email>srikanth.ddit@gmail.com</email>
<organization>Thoughtworks</organization>
<organizationUrl>http://thoughtworks.com/</organizationUrl>
</developer>
<developer>
<name>Mahendra Kariya</name>
<email>mahendrakariya@gmail.com</email>
<organization>Thoughtworks</organization>
<name>Gauge Team</name>
<email>getgauge@outlook.com</email>
<organization>ThoughtWorks</organization>
<organizationUrl>http://thoughtworks.com/</organizationUrl>
</developer>
</developers>
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/thoughtworks/gauge/GaugeRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.thoughtworks.gauge.connection.GaugeConnector;
import com.thoughtworks.gauge.connection.MessageDispatcher;
import com.thoughtworks.gauge.execution.parameters.parsers.base.ParameterParsingChain;
import com.thoughtworks.gauge.registry.StepRegistry;
import com.thoughtworks.gauge.scan.ClasspathScanner;
import com.thoughtworks.gauge.scan.CustomClassInitializerScanner;
import com.thoughtworks.gauge.scan.HooksScanner;
Expand All @@ -42,17 +43,18 @@ public class GaugeRuntime {
public static void main(String[] args) throws Exception {
int apiPort = readEnvVar(GaugeConstant.GAUGE_API_PORT);
String portInfo = System.getenv("GAUGE_API_PORTS");
StepRegistry stepRegistry = new StepRegistry();
if (portInfo != null && !portInfo.trim().isEmpty()) {
List<String> ports = Arrays.asList(portInfo.split(","));
for (int i = 0, portsSize = ports.size(); i < portsSize; i++) {
if (i == 0) {
connectSynchronously(Integer.parseInt(ports.get(i)), apiPort);
connectSynchronously(Integer.parseInt(ports.get(i)), apiPort, stepRegistry);
} else {
connectInParallel(Integer.parseInt(ports.get(i)), apiPort);
connectInParallel(Integer.parseInt(ports.get(i)), apiPort, stepRegistry);
}
}
} else {
connectSynchronously(readEnvVar(GaugeConstant.GAUGE_INTERNAL_PORT), apiPort);
connectSynchronously(readEnvVar(GaugeConstant.GAUGE_INTERNAL_PORT), apiPort, stepRegistry);
}
for (Thread thread : threads) {
thread.join();
Expand All @@ -68,15 +70,15 @@ private static int readEnvVar(String env) {
return Integer.parseInt(port);
}

private static void connectInParallel(final int gaugeInternalPort, final int gaugeApiPort) {
Thread thread = new Thread(() -> dispatchMessages(makeConnection(gaugeInternalPort, gaugeApiPort)));
private static void connectInParallel(final int gaugeInternalPort, final int gaugeApiPort, StepRegistry stepRegistry) {
Thread thread = new Thread(() -> dispatchMessages(makeConnection(gaugeInternalPort, gaugeApiPort), stepRegistry));
startThread(thread);
}

private static void connectSynchronously(final int gaugeInternalPort, final int gaugeApiPort) {
private static void connectSynchronously(final int gaugeInternalPort, final int gaugeApiPort, StepRegistry stepRegistry) {
final GaugeConnector connector = makeConnection(gaugeInternalPort, gaugeApiPort);
new ClasspathScanner().scan(new StepsScanner(connector), new HooksScanner(), new CustomScreenshotScanner(), new CustomClassInitializerScanner());
Thread thread = new Thread(() -> dispatchMessages(connector));
new ClasspathScanner().scan(new StepsScanner(connector, stepRegistry), new HooksScanner(), new CustomScreenshotScanner(), new CustomClassInitializerScanner());
Thread thread = new Thread(() -> dispatchMessages(connector, stepRegistry));
startThread(thread);
}

Expand All @@ -91,9 +93,9 @@ private static GaugeConnector makeConnection(int gaugeInternalPort, int gaugeApi
return connector;
}

private static void dispatchMessages(GaugeConnector connector) {
private static void dispatchMessages(GaugeConnector connector, StepRegistry stepRegistry) {
try {
new MessageDispatcher(new ParameterParsingChain()).dispatchMessages(connector);
new MessageDispatcher(new ParameterParsingChain(), stepRegistry).dispatchMessages(connector);
} catch (IOException e) {
Thread t = Thread.currentThread();
t.getUncaughtExceptionHandler().uncaughtException(t, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
import com.thoughtworks.gauge.ClassInstanceManager;
import com.thoughtworks.gauge.datastore.DataStoreInitializer;
import com.thoughtworks.gauge.execution.parameters.parsers.base.ParameterParsingChain;
import com.thoughtworks.gauge.processor.ExecuteStepProcessor;
import com.thoughtworks.gauge.processor.IMessageProcessor;
import com.thoughtworks.gauge.processor.KillProcessProcessor;
import com.thoughtworks.gauge.processor.RefactorRequestProcessor;
import com.thoughtworks.gauge.processor.SpecExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.SuiteExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.SuiteExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.ScenarioExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.ScenarioExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.SpecExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.SpecExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.StepExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.StepExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.StepNameRequestProcessor;
import com.thoughtworks.gauge.processor.ExecuteStepProcessor;
import com.thoughtworks.gauge.processor.StepExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.StepNamesRequestProcessor;
import com.thoughtworks.gauge.processor.SuiteExecutionEndingProcessor;
import com.thoughtworks.gauge.processor.SuiteExecutionStartingProcessor;
import com.thoughtworks.gauge.processor.ValidateStepProcessor;
import com.thoughtworks.gauge.processor.KillProcessProcessor;
import com.thoughtworks.gauge.processor.RefactorRequestProcessor;
import com.thoughtworks.gauge.processor.StepNameRequestProcessor;
import com.thoughtworks.gauge.registry.ClassInitializerRegistry;

import com.thoughtworks.gauge.registry.StepRegistry;
import gauge.messages.Messages;

import java.io.ByteArrayOutputStream;
Expand All @@ -54,9 +54,9 @@ public class MessageDispatcher {

private final HashMap<Messages.Message.MessageType, IMessageProcessor> messageProcessors;

public MessageDispatcher(ParameterParsingChain chain) {
public MessageDispatcher(ParameterParsingChain chain, StepRegistry stepRegistry) {
final ClassInstanceManager instanceManager = new ClassInstanceManager(ClassInitializerRegistry.classInitializer());
messageProcessors = new HashMap<Messages.Message.MessageType, IMessageProcessor>() {{
messageProcessors = new HashMap<>() {{
put(Messages.Message.MessageType.ExecutionStarting, new SuiteExecutionStartingProcessor(instanceManager));
put(Messages.Message.MessageType.ExecutionEnding, new SuiteExecutionEndingProcessor(instanceManager));
put(Messages.Message.MessageType.SpecExecutionStarting, new SpecExecutionStartingProcessor(instanceManager));
Expand All @@ -65,15 +65,15 @@ public MessageDispatcher(ParameterParsingChain chain) {
put(Messages.Message.MessageType.ScenarioExecutionEnding, new ScenarioExecutionEndingProcessor(instanceManager));
put(Messages.Message.MessageType.StepExecutionStarting, new StepExecutionStartingProcessor(instanceManager));
put(Messages.Message.MessageType.StepExecutionEnding, new StepExecutionEndingProcessor(instanceManager));
put(Messages.Message.MessageType.ExecuteStep, new ExecuteStepProcessor(instanceManager, chain));
put(Messages.Message.MessageType.StepValidateRequest, new ValidateStepProcessor(instanceManager));
put(Messages.Message.MessageType.StepNamesRequest, new StepNamesRequestProcessor(instanceManager));
put(Messages.Message.MessageType.ExecuteStep, new ExecuteStepProcessor(instanceManager, chain, stepRegistry));
put(Messages.Message.MessageType.StepValidateRequest, new ValidateStepProcessor(instanceManager, stepRegistry));
put(Messages.Message.MessageType.StepNamesRequest, new StepNamesRequestProcessor(instanceManager, stepRegistry));
put(Messages.Message.MessageType.SuiteDataStoreInit, new DataStoreInitializer(instanceManager));
put(Messages.Message.MessageType.SpecDataStoreInit, new DataStoreInitializer(instanceManager));
put(Messages.Message.MessageType.ScenarioDataStoreInit, new DataStoreInitializer(instanceManager));
put(Messages.Message.MessageType.KillProcessRequest, new KillProcessProcessor(instanceManager));
put(Messages.Message.MessageType.StepNameRequest, new StepNameRequestProcessor(instanceManager));
put(Messages.Message.MessageType.RefactorRequest, new RefactorRequestProcessor(instanceManager));
put(Messages.Message.MessageType.StepNameRequest, new StepNameRequestProcessor(instanceManager, stepRegistry));
put(Messages.Message.MessageType.RefactorRequest, new RefactorRequestProcessor(instanceManager, stepRegistry));
}};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public ExecutionContext executionInfoFrom(Messages.ExecutionInfo currentExecutio
stepFrom(currentExecutionInfo.getCurrentStep()));
}

public Specification specificationFrom(Messages.SpecInfo currentSpec) {
private Specification specificationFrom(Messages.SpecInfo currentSpec) {
if (currentSpec.isInitialized()) {
return new Specification(currentSpec.getName(), currentSpec.getFileName(), currentSpec.getIsFailed(), currentSpec.getTagsList());
}
return new Specification();
}

public Scenario scenarioFrom(Messages.ScenarioInfo currentScenario) {
Scenario scenarioFrom(Messages.ScenarioInfo currentScenario) {
if (currentScenario.isInitialized()) {
return new Scenario(currentScenario.getName(), currentScenario.getIsFailed(), currentScenario.getTagsList());
}
Expand Down
CEB7
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public class StepExecutionStage extends AbstractExecutionStage {
private Messages.ExecuteStepRequest executeStepRequest;
private ClassInstanceManager manager;
private ParametersExtractor parametersExtractor;
private StepRegistry registry;

public StepExecutionStage(Messages.ExecuteStepRequest executeStepRequest, ClassInstanceManager manager, ParameterParsingChain chain) {
public StepExecutionStage(Messages.ExecuteStepRequest executeStepRequest, ClassInstanceManager manager, ParameterParsingChain chain, StepRegistry registry) {
this.manager = manager;
this.executeStepRequest = executeStepRequest;
this.parametersExtractor = new ParametersExtractor(chain);
this.registry = registry;
}

public void setNextStage(ExecutionStage stage) {
Expand All @@ -51,7 +53,7 @@ public Spec.ProtoExecutionResult execute(Spec.ProtoExecutionResult previousStage
}

private Spec.ProtoExecutionResult executeStep() {
Method method = StepRegistry.get(executeStepRequest.getParsedStepText());
Method method = registry.get(executeStepRequest.getParsedStepText());

int implementationParamCount = method.getParameterTypes().length;
int numberOfParameters = this.executeStepRequest.getParametersCount();
Expand All @@ -68,7 +70,7 @@ private Spec.ProtoExecutionResult executeStep() {

}

public Spec.ProtoExecutionResult executeStepMethod(MethodExecutor methodExecutor, Method method) {
Spec.ProtoExecutionResult executeStepMethod(MethodExecutor methodExecutor, Method method) {
try {
List<Spec.Parameter> arguments = executeStepRequest.getParametersList();
return methodExecutor.execute(method, parametersExtractor.extract(arguments, method.getParameterTypes()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
public class ExecuteStepProcessor extends MethodExecutionMessageProcessor implements IMessageProcessor {

private final ParameterParsingChain chain;
private StepRegistry registry;

public ExecuteStepProcessor(ClassInstanceManager instanceManager, ParameterParsingChain chain) {
public ExecuteStepProcessor(ClassInstanceManager instanceManager, ParameterParsingChain chain, StepRegistry stepRegistry) {
super(instanceManager);
this.chain = chain;
this.registry = stepRegistry;
}

public Messages.Message process(Messages.Message message) {
Method method = StepRegistry.get(message.getExecuteStepRequest().getParsedStepText());
Method method = registry.get(message.getExecuteStepRequest().getParsedStepText());
ExecutionPipeline pipeline = new ExecutionPipeline(new HookExecutionStage(HooksRegistry.getBeforeClassStepsHooksOfClass(method.getDeclaringClass()), getInstanceManager()));
pipeline.addStages(new StepExecutionStage(message.getExecuteStepRequest(), getInstanceManager(), this.chain),
pipeline.addStages(new StepExecutionStage(message.getExecuteStepRequest(), getInstanceManager(), chain, registry),
new HookExecutionStage(HooksRegistry.getAfterClassStepsHooksOfClass(method.getDeclaringClass()), getInstanceManager()));
Spec.ProtoExecutionResult executionResult = pipeline.start();
Spec.ProtoExecutionResult protoExecutionResult = new MessageCollector().addPendingMessagesTo(executionResult);
Expand Down
3D11
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@
import com.thoughtworks.gauge.StepValue;
import com.thoughtworks.gauge.refactor.JavaRefactoring;
import com.thoughtworks.gauge.refactor.RefactoringResult;
import com.thoughtworks.gauge.registry.StepRegistry;
import gauge.messages.Messages;

import java.util.List;

public class RefactorRequestProcessor implements IMessageProcessor {
public RefactorRequestProcessor(ClassInstanceManager instanceManager) {
private final StepRegistry registry;

public RefactorRequestProcessor(ClassInstanceManager instanceManager, StepRegistry registry) {
this.registry = registry;
}

public Messages.Message process(Messages.Message message) {
Messages.RefactorRequest refactorRequest = message.getRefactorRequest();
RefactoringResult result = new JavaRefactoring(StepValue.from(refactorRequest.getOldStepValue()),
StepValue.from(refactorRequest.getNewStepValue()),
refactorRequest.getParamPositionsList()).performRefactoring();

StepValue oldStepValue = StepValue.from(refactorRequest.getOldStepValue());
StepValue newStepValue = StepValue.from(refactorRequest.getNewStepValue());
List<Messages.ParameterPosition> paramPositions = refactorRequest.getParamPositionsList();
RefactoringResult result = new JavaRefactoring(oldStepValue, newStepValue, paramPositions, registry).performRefactoring();
return createRefactorResponse(message, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
import java.util.Set;

public class StepNameRequestProcessor implements IMessageProcessor {
public StepNameRequestProcessor(ClassInstanceManager instanceManager) {
private final StepRegistry registry;

public StepNameRequestProcessor(ClassInstanceManager instanceManager, StepRegistry registry) {
this.registry = registry;
}

public Messages.Message process(Messages.Message message) {
Set<String> stepAnnotations = StepRegistry.getAllAliasAnnotationTextsFor(message.getStepNameRequest().getStepValue());
Set<String> stepAnnotations = registry.getAllAliasAnnotationTextsFor(message.getStepNameRequest().getStepValue());
boolean hasAlias = false, isStepPresent = false;

if (stepAnnotations.size() > 1) {
Expand Down
Loading
0