-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web3j new and import small functionalliy change (#1046)
* small functionality change * changed test method names for clarity. * Updated test name toe more expressive. Added ClassExecutor class to run tests that use system exit as a sub process.
- Loading branch information
1 parent
adeee2c
commit b58beb1
Showing
6 changed files
with
147 additions
and
71 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
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
40 changes: 40 additions & 0 deletions
40
console/src/test/java/org/web3j/console/project/utills/ClassExecutor.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,40 @@ | ||
/* | ||
* Copyright 2019 Web3 Labs 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. | ||
*/ | ||
package org.web3j.console.project.utills; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.web3j.TempFileProvider; | ||
|
||
public class ClassExecutor extends TempFileProvider { | ||
public ProcessBuilder executeClassAsSubProcessAndReturnProcess( | ||
Class classToExecute, List<String> jvmArgs, List<String> args) | ||
throws IOException, InterruptedException { | ||
String javaHome = System.getProperty("java.home"); | ||
String javaBin = javaHome + File.separator + "bin" + File.separator + "java"; | ||
String classPath = System.getProperty("java.class.path"); | ||
String className = classToExecute.getName(); | ||
|
||
List<String> command = new ArrayList<>(); | ||
command.add(javaBin); | ||
command.addAll(jvmArgs); | ||
command.add("-cp"); | ||
command.add(classPath); | ||
command.add(className); | ||
command.addAll(args); | ||
return new ProcessBuilder(command); | ||
} | ||
} |