Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscoo committed Jan 27, 2024
1 parent 753f383 commit 762c81f
Show file tree
Hide file tree
Showing 24 changed files with 2,601 additions and 2,378 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,57 @@
*/
package docs;

import static org.assertj.core.api.Assertions.assertThat;

import io.mateo.junit.GradleBuild;
import io.mateo.junit.GradleCompatibilityExtension;
import java.nio.file.Path;
import org.gradle.testkit.runner.BuildTask;
import org.gradle.testkit.runner.TaskOutcome;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;

class ExamplesFunctionalTests {

@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void jaxwsBindingFile(GradleBuild gradleBuild) {
doTestForScript("jaxws-binding-file", gradleBuild);
}
@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void specifyDataBinding(GradleBuild gradleBuild) {
doTestForScript("specify-data-binding", gradleBuild);
}
@TestTemplate
void jaxwsBindingFile(GradleBuild gradleBuild) {
doTestForScript("jaxws-binding-file", gradleBuild);
}

@TestTemplate
void serviceName(GradleBuild gradleBuild) {
doTestForScript("service-name", gradleBuild);
}
@TestTemplate
void specifyDataBinding(GradleBuild gradleBuild) {
doTestForScript("specify-data-binding", gradleBuild);
}

@TestTemplate
void loadFromArtifact(GradleBuild gradleBuild) {
doTestForScript("loading-wsdl", gradleBuild);
}
@TestTemplate
void serviceName(GradleBuild gradleBuild) {
doTestForScript("service-name", gradleBuild);
}

@TestTemplate
void usingXjcExtensions(GradleBuild gradleBuild) {
doTestForScript("using-xjc-extensions", gradleBuild);
}
@TestTemplate
void loadFromArtifact(GradleBuild gradleBuild) {
doTestForScript("loading-wsdl", gradleBuild);
}

private void doTestForScript(String name, GradleBuild gradleBuild) {
final var rootDir = Path.of("").toAbsolutePath().getParent();
final var scriptPath = rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "examples", name));
@TestTemplate
void usingXjcExtensions(GradleBuild gradleBuild) {
doTestForScript("using-xjc-extensions", gradleBuild);
}

var runner = gradleBuild.script(scriptPath).prepareRunner("wsdl2java");
private void doTestForScript(String name, GradleBuild gradleBuild) {
final var rootDir = Path.of("").toAbsolutePath().getParent();
final var scriptPath = rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "examples", name));

var result = runner.build();
var runner = gradleBuild.script(scriptPath).prepareRunner("wsdl2java");

assertThat(result.task(":wsdl2java")).isNotNull()
.extracting(BuildTask::getOutcome)
.isEqualTo(TaskOutcome.SUCCESS);
}
var result = runner.build();

assertThat(result.task(":wsdl2java"))
.isNotNull()
.extracting(BuildTask::getOutcome)
.isEqualTo(TaskOutcome.SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,89 @@
*/
package docs;

import static org.assertj.core.api.Assertions.assertThat;

import io.mateo.junit.GradleBuild;
import io.mateo.junit.GradleCompatibilityExtension;
import java.nio.file.Path;
import org.gradle.testkit.runner.BuildResult;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;

class GeneratingJavaFunctionalTests {

@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void defaultToolOptions(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("default-tool-options")).build("verify");

assertThat(result.getOutput()).contains("first markGenerated true")
.contains("second markGenerated true")
.contains("third markGenerated true");
}

@TestTemplate
void loggingTask(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("logging-task")).prepareRunner("wsdl2java").build();

assertThat(result.getOutput()).contains("DEBUG org.apache.cxf.common.logging.LogUtils",
"DEBUG org.apache.cxf.tools.wsdlto.core.PluginLoader", "DEBUG org.apache.velocity");
}

@TestTemplate
void verboseLogging(GradleBuild gradleBuild) {
// same as loggingTask, just different samples
var result = gradleBuild.script(scriptFor("verbose-logging")).prepareRunner("wsdl2java").build();

assertThat(result.getOutput()).contains("DEBUG org.apache.cxf.common.logging.LogUtils",
"DEBUG org.apache.cxf.tools.wsdlto.core.PluginLoader", "DEBUG org.apache.velocity");
}

@TestTemplate
void minimalTaskUsage(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("minimal-task-usage")).prepareRunner("verify").build();

assertThat(result.getOutput()).contains(Path.of("path", "to", "example.wsdl").toString());
}

@TestTemplate
void toolOptions(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("tool-options")).prepareRunner("verify").build();

assertThat(result.getOutput()).contains(Path.of("path", "to", "example.wsdl").toString(),
Path.of("build", "generated-java").toString(), "markGenerated=true",
"packageNames=[com.example, com.foo.bar]", "asyncMethods=[foo, bar]");
}

Path scriptFor(String name) {
final Path rootDir = Path.of("").toAbsolutePath().getParent();
return rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "generating-java", name));
}

@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void defaultToolOptions(GradleBuild gradleBuild) {
BuildResult result =
gradleBuild.script(scriptFor("default-tool-options")).build("verify");

assertThat(result.getOutput())
.contains("first markGenerated true")
.contains("second markGenerated true")
.contains("third markGenerated true");
}

@TestTemplate
void loggingTask(GradleBuild gradleBuild) {
BuildResult result = gradleBuild
.script(scriptFor("logging-task"))
.prepareRunner("wsdl2java")
.build();

assertThat(result.getOutput())
.contains(
"DEBUG org.apache.cxf.common.logging.LogUtils",
"DEBUG org.apache.cxf.tools.wsdlto.core.PluginLoader",
"DEBUG org.apache.velocity");
}

@TestTemplate
void verboseLogging(GradleBuild gradleBuild) {
// same as loggingTask, just different samples
var result = gradleBuild
.script(scriptFor("verbose-logging"))
.prepareRunner("wsdl2java")
.build();

assertThat(result.getOutput())
.contains(
"DEBUG org.apache.cxf.common.logging.LogUtils",
"DEBUG org.apache.cxf.tools.wsdlto.core.PluginLoader",
"DEBUG org.apache.velocity");
}

@TestTemplate
void minimalTaskUsage(GradleBuild gradleBuild) {
BuildResult result = gradleBuild
.script(scriptFor("minimal-task-usage"))
.prepareRunner("verify")
.build();

assertThat(result.getOutput())
.contains(Path.of("path", "to", "example.wsdl").toString());
}

@TestTemplate
void toolOptions(GradleBuild gradleBuild) {
BuildResult result = gradleBuild
.script(scriptFor("tool-options"))
.prepareRunner("verify")
.build();

assertThat(result.getOutput())
.contains(
Path.of("path", "to", "example.wsdl").toString(),
Path.of("build", "generated-java").toString(),
"markGenerated=true",
"packageNames=[com.example, com.foo.bar]",
"asyncMethods=[foo, bar]");
}

Path scriptFor(String name) {
final Path rootDir = Path.of("").toAbsolutePath().getParent();
return rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "generating-java", name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,49 @@
*/
package docs;

import static org.assertj.core.api.Assertions.assertThat;

import io.mateo.junit.GradleBuild;
import io.mateo.junit.GradleCompatibilityExtension;
import java.nio.file.Path;
import org.gradle.testkit.runner.BuildResult;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;

class GeneratingJavaScriptFunctionalTests {

@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void minimalTaskUsage(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("minimal-task-usage")).prepareRunner("verify").build();

assertThat(result.getOutput()).contains(Path.of("path", "to", "example.wsdl").toString());
}

@TestTemplate
void toolOptions(GradleBuild gradleBuild) {
BuildResult result = gradleBuild.script(scriptFor("tool-options")).prepareRunner("verify").build();

assertThat(result.getOutput()).contains(Path.of("path", "to", "example.wsdl").toString(),
Path.of("build", "example-generated-js").toString(),
Path.of("path", "to", "example-catalog.xml").toString(),
"packagePrefixes=[UriPrefixPair[uri='https://example.com', prefix='example']]", "verbose=true");
}

Path scriptFor(String name) {
final var rootDir = Path.of("").toAbsolutePath().getParent();
return rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "generating-javascript", name));
}

@RegisterExtension
static GradleCompatibilityExtension extension = new GradleCompatibilityExtension("current");

@TestTemplate
void minimalTaskUsage(GradleBuild gradleBuild) {
BuildResult result = gradleBuild
.script(scriptFor("minimal-task-usage"))
.prepareRunner("verify")
.build();

assertThat(result.getOutput())
.contains(Path.of("path", "to", "example.wsdl").toString());
}

@TestTemplate
void toolOptions(GradleBuild gradleBuild) {
BuildResult result = gradleBuild
.script(scriptFor("tool-options"))
.prepareRunner("verify")
.build();

assertThat(result.getOutput())
.contains(
Path.of("path", "to", "example.wsdl").toString(),
Path.of("build", "example-generated-js").toString(),
Path.of("path", "to", "example-catalog.xml").toString(),
"packagePrefixes=[UriPrefixPair[uri='https://example.com', prefix='example']]",
"verbose=true");
}

Path scriptFor(String name) {
final var rootDir = Path.of("").toAbsolutePath().getParent();
return rootDir.resolve(Path.of("documentation", "src", "docs", "gradle", "generating-javascript", name));
}
}
Loading

0 comments on commit 762c81f

Please sign in to comment.