Skip to content
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: 0 additions & 2 deletions allure-java-commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ dependencies {
api(project(":allure-model"))
compileOnly("org.aspectj:aspectjrt")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("org.apache.tika:tika-core")
implementation("org.jooq:joor-java-8")
testImplementation("io.github.benas:random-beans")
testImplementation("io.github.glytching:junit-extensions")
testImplementation("org.apache.commons:commons-lang3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -29,8 +30,6 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import static org.joor.Reflect.on;

/**
* @author charlie (Dmitry Baev).
*/
Expand Down Expand Up @@ -88,9 +87,48 @@ private static String extractProperties(final Object object, final String[] part
.map(child -> extractProperties(child, parts, index))
.collect(JOINER);
}
final Object child = on(object).get(parts[index]);
final Object child = extractChild(object, parts[index]);
return extractProperties(child, parts, index + 1);
}
return ObjectUtils.toString(object);
}

private static Object extractChild(final Object object, final String part) {
final Class<?> type = object == null ? Object.class : object.getClass();
try {
return extractField(object, part, type);
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("Unable to extract " + part + " value from " + type.getName(), e);
}
}

@SuppressWarnings("PMD.EmptyCatchBlock")
private static Object extractField(final Object object, final String part, final Class<?> type)
throws ReflectiveOperationException {
try {
final Field field = type.getField(part);
return fieldValue(object, field);
} catch (NoSuchFieldException e) {
Class<?> t = type;
while (t != null) {
try {
final Field declaredField = t.getDeclaredField(part);
return fieldValue(object, declaredField);
} catch (NoSuchFieldException ignore) {
// Ignore
}
t = t.getSuperclass();
}
throw e;
}
}

private static Object fieldValue(final Object object, final Field field) throws IllegalAccessException {
try {
return field.get(object);
} catch (IllegalAccessException e) {
field.setAccessible(true);
return field.get(object);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import io.qameta.allure.model.Parameter;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.StatusDetails;
import org.apache.tika.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
Expand Down Expand Up @@ -60,6 +60,7 @@
*/
@SuppressWarnings({
"ClassFanOutComplexity",
"ClassDataAbstractionCoupling",
"PMD.ExcessiveImports",
"PMD.TooManyMethods",
"PMD.GodClass",
Expand Down Expand Up @@ -394,14 +395,27 @@ private static Optional<String> readResource(final ClassLoader classLoader, fina
if (Objects.isNull(is)) {
return Optional.empty();
}
final byte[] bytes = IOUtils.toByteArray(is);
final byte[] bytes = toBytes(is);
return Optional.of(new String(bytes, StandardCharsets.UTF_8));
} catch (IOException e) {
LOGGER.warn("Unable to process description resource file", e);
}
return Optional.empty();
}

private static byte[] toBytes(final InputStream is) throws IOException {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final byte[] buffer = new byte[4096];
int n;
do {
n = is.read(buffer);
if (n > 0) {
output.write(buffer, 0, n);
}
} while (-1 != n);
return output.toByteArray();
}

private static boolean separateLines() {
return parseBoolean(loadAllureProperties().getProperty(ALLURE_SEPARATE_LINES_SYSPROP));
}
Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ configure(subprojects) {
dependency("io.github.glytching:junit-extensions:2.4.0")
dependency("org.apache.commons:commons-lang3:3.12.0")
dependency("org.apache.httpcomponents:httpclient:4.5.13")
dependency("org.apache.tika:tika-core:1.26")
dependency("org.aspectj:aspectjrt:1.9.6")
dependency("org.aspectj:aspectjweaver:1.9.6")
dependency("org.assertj:assertj-core:3.19.0")
dependency("org.codehaus.groovy:groovy-all:2.5.13")
dependency("org.freemarker:freemarker:2.3.31")
dependency("org.jboss.resteasy:resteasy-client:4.6.0.Final")
dependency("org.jooq:joor-java-8:0.9.14")
dependency("org.mock-server:mockserver-netty:5.11.2")
dependency("org.mockito:mockito-core:3.10.0")
dependencySet("org.slf4j:1.7.30") {
Expand Down