-
Notifications
You must be signed in to change notification settings - Fork 3
3.0.1 snapshot #40
base: master
Are you sure you want to change the base?
3.0.1 snapshot #40
Changes from 2 commits
59d0ff9
70b9187
8cf70ea
fb2455d
bd7792d
99dec14
d97e243
7b16e1a
c00941e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<modelVersion>4.0.0</modelVersion> | ||
<groupId>ru.sbtqa.tag</groupId> | ||
<artifactId>api-factory</artifactId> | ||
<version>3.0-SNAPSHOT</version> | ||
<version>3.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>api-factory</name> | ||
<description>api-factory description</description> | ||
|
@@ -48,6 +48,12 @@ | |
</repository> | ||
</distributionManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>4.3.14.RELEASE</version> | ||
<type>jar</type> | ||
</dependency> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. стандартные отступ для xml - 2 пробела |
||
<dependency> | ||
<groupId>ru.sbtqa.tag</groupId> | ||
<artifactId>datajack</artifactId> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cucumber.runtime.io; | ||
|
||
import static java.util.Arrays.asList; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мне кажется, этого статик импорта можно избежать. |
||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
|
||
import cucumber.runtime.ClassFinder; | ||
import cucumber.runtime.Runtime; | ||
import cucumber.runtime.RuntimeOptions; | ||
|
||
public class CucumberStaticRunner { | ||
|
||
// private String status = "Finished: FAILURE"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше убрать закомментированный код |
||
private static String status = "\nFinished: SUCCESS"; | ||
|
||
public static void startTests(String[] argv) throws Throwable { | ||
byte exitstatus = run(argv, Thread.currentThread().getContextClassLoader()); | ||
System.exit(exitstatus); | ||
} | ||
|
||
public static byte run(String[] argv, ClassLoader classLoader) throws IOException { | ||
RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv))); | ||
|
||
ResourceLoader resourceLoader = new CustomMultiLoader(classLoader); | ||
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); | ||
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); | ||
runtime.run(); | ||
if (runtime.getErrors().size() > 0 || runtime.getSnippets().size() > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мне кажется, здесь мы можем использовать метод isEmpty() вместо size() > 0 |
||
status = "Finished: FAILURE"; | ||
} | ||
System.out.println(status); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. необходимо заменить все println и prinstacktrace на логирование There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут нужно проверить. Добавил вывод в консоль на уровне warn Output to the consolelog4j.rootLogger=WARN |
||
return runtime.exitStatus(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cucumber.runtime.io; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
public class CustomMultiLoader implements ResourceLoader { | ||
public static final String CLASSPATH_SCHEME = "classpath*:"; | ||
public static final String CLASSPATH_SCHEME_TO_REPLACE = "classpath:"; | ||
private final ClasspathResourceLoader classpath; | ||
private final FileResourceLoader fs; | ||
public CustomMultiLoader(ClassLoader classLoader) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно нормальное форматирование, newline и все такое There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. И сделать это нужно во всех новых файлах |
||
classpath = new ClasspathResourceLoader(classLoader); | ||
fs = new FileResourceLoader(); | ||
} | ||
@Override | ||
public Iterable<Resource> resources(String path, String suffix) { | ||
if (isClasspathPath(path)) { | ||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); | ||
String locationPattern = path.replace(CLASSPATH_SCHEME_TO_REPLACE, CLASSPATH_SCHEME) + "/**/*" + suffix; | ||
org.springframework.core.io.Resource[] resources; | ||
try { | ||
resources = resolver.getResources(locationPattern); | ||
} catch (IOException e) { | ||
resources = null; | ||
e.printStackTrace(); | ||
} | ||
return convertToCucumberIterator(resources); | ||
} else { | ||
return fs.resources(path, suffix); | ||
} | ||
} | ||
private Iterable<Resource> convertToCucumberIterator(org.springframework.core.io.Resource[] resources) { | ||
List<Resource> results = new ArrayList<Resource>(); | ||
for (org.springframework.core.io.Resource resource : resources) { | ||
results.add(new ResourceAdapter(resource)); | ||
} | ||
return results; | ||
} | ||
|
||
public static String packageName(String gluePath) { | ||
if (isClasspathPath(gluePath)) { | ||
gluePath = stripClasspathPrefix(gluePath); | ||
} | ||
return gluePath.replace('/', '.').replace('\\', '.'); | ||
} | ||
|
||
private static boolean isClasspathPath(String path) { | ||
if (path.startsWith(CLASSPATH_SCHEME_TO_REPLACE)) { | ||
path = path.replace(CLASSPATH_SCHEME_TO_REPLACE, CLASSPATH_SCHEME); | ||
} | ||
return path.startsWith(CLASSPATH_SCHEME); | ||
} | ||
|
||
private static String stripClasspathPrefix(String path) { | ||
if (path.startsWith(CLASSPATH_SCHEME_TO_REPLACE)) { | ||
path = path.replace(CLASSPATH_SCHEME_TO_REPLACE, CLASSPATH_SCHEME); | ||
} | ||
return path.substring(CLASSPATH_SCHEME.length()); | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cucumber.runtime.io; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class ResourceAdapter implements Resource { | ||
org.springframework.core.io.Resource springResource; | ||
|
||
public ResourceAdapter(org.springframework.core.io.Resource springResource) { | ||
this.springResource = springResource; | ||
} | ||
|
||
public String getPath() { | ||
try { | ||
return springResource.getFile().getPath(); | ||
} catch (IOException e) { | ||
try { | ||
return springResource.getURL().toString(); | ||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Может сюда логирование подключить? |
||
return ""; | ||
} | ||
} | ||
} | ||
|
||
public String getAbsolutePath() { | ||
try { | ||
return springResource.getFile().getAbsolutePath(); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public InputStream getInputStream() throws IOException { | ||
return this.springResource.getInputStream(); | ||
} | ||
|
||
public String getClassName(String extension) { | ||
|
||
String path = this.getPath(); | ||
if (path.startsWith("jar:")) { | ||
path = path.substring(path.lastIndexOf("!") + 2); | ||
return path.substring(0, path.length() - extension.length()).replace('/', '.'); | ||
} else { | ||
path = path.substring(path.lastIndexOf("classes") + 8); | ||
return path.substring(0, path.length() - extension.length()).replace('\\', '.'); | ||
} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В ветке менять версию не надо. Это автоматически произойдет при релизе