Skip to content

Commit

Permalink
Merge pull request #33 from aguibert/rebranding
Browse files Browse the repository at this point in the history
 Rename to MicroShed Testing
  • Loading branch information
aguibert authored Aug 30, 2019
2 parents ae467cb + 5a225c9 commit 44af5d3
Show file tree
Hide file tree
Showing 65 changed files with 168 additions and 183 deletions.
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MicroShed Testing

[![](https://jitpack.io/v/dev-tools-for-enterprise-java/system-test.svg)](https://jitpack.io/#dev-tools-for-enterprise-java/system-test)
[![Build Status](https://travis-ci.org/dev-tools-for-enterprise-java/system-test.svg?branch=master)](https://travis-ci.org/dev-tools-for-enterprise-java/system-test)
[![](https://jitpack.io/v/microshed/microshed-testing.svg)](https://jitpack.io/#microshed/microshed-testing)
[![Build Status](https://travis-ci.org/MicroShed/microshed-testing.svg?branch=master)](https://travis-ci.org/MicroShed/microshed-testing)
[![License](https://img.shields.io/badge/License-ASL%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)

# Goals
Expand All @@ -25,8 +25,8 @@ Then add `system-test` and `junit-jupiter` as test-scoped dependencies:
```xml
<dependencies>
<dependency>
<groupId>com.github.dev-tools-for-enterprise-java</groupId>
<artifactId>system-test</artifactId>
<groupId>com.github.microshed</groupId>
<artifactId>microshed-testing</artifactId>
<version>v0.3-alpha</version>
<scope>test</scope>
</dependency>
Expand All @@ -42,11 +42,11 @@ Then add `system-test` and `junit-jupiter` as test-scoped dependencies:
</dependencies>
```

# How to run locally:
# How to try out a sample locally:

### Run with Gradle:
```
./gradlew :system-test-jaxrs-json:test
./gradlew :microshed-testing-jaxrs-json:test
```

### Run with Maven:
Expand All @@ -68,20 +68,14 @@ To change which app server is used, [un]comment sections of the test app's Docke

# Proposed mockup:
```java
import org.aguibert.testcontainers.framework.MicroProfileApplication;
import org.eclipse.microprofile.system.test.jupiter.MicroProfileTest;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
@MicroProfileTest
@MicroShedTest
public class BasicJAXRSServiceTest {

@Container // (1)
@Container
public static MicroProfileApplication app = new MicroProfileApplication()
.withAppContextRoot("/myservice");

@Inject // (2)
@Inject
public static PersonService personSvc;

@Test
Expand All @@ -96,14 +90,3 @@ public class BasicJAXRSServiceTest {
}
```

### Explanation of mockup
1. Extend Testcontainers with a `MicroProfileApplication` class that can work
for any JEE/MP implementation. By annotating with `@Container`, Testcontainers
will automatically find/build the Dockerfile in this project and start it, then
wait for the application context root to be ready.
2. Use the `@Inject` annotation to create a REST Client proxy of the `PersonService`
class which is being tested. This is basically a convenience for the test client making
HTTP requests on the server and then parsing back the response.
3. Easily invoke HTTP requests on the running server and have the response bound
back into a POJO (or an exception class if an error occurred)

6 changes: 3 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ plugins {
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.eclipse.microprofile.sandbox'
artifactId = 'system-test'
groupId = 'org.microshed'
artifactId = 'microshed-testing'
version = '0.1-SNAPSHOT'

from components.java
}
}
}

description = "MicroProfile System Testing framework"
description = "MicroShed Testing Framework"

dependencies {
compile group: 'javax.inject', name: 'javax.inject', version: '1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test;
package org.microshed.testing;

import java.util.HashSet;
import java.util.Optional;
Expand All @@ -26,7 +26,7 @@
public interface ApplicationEnvironment {

/**
* The default priority returned by an implementation of {@link ApplicationEnvironment.isAvailable()}
* The default priority returned by an implementation of {@link ApplicationEnvironment#isAvailable}
* In general, built-in ApplicationEnvironment implementations have a priority less than the default
* and user-defined priorities will have a greater than default priority.
*/
Expand Down Expand Up @@ -66,7 +66,7 @@ public static ApplicationEnvironment load() {
.sorted((c1, c2) -> c1.getClass().getCanonicalName().compareTo(c2.getClass().getCanonicalName()))
.sorted((c1, c2) -> Integer.compare(c2.getPriority(), c1.getPriority()))
.findFirst();
return selectedEnv.orElseThrow(() -> new IllegalStateException("No available " + ApplicationEnvironment.class + " was discovered."));
return selectedEnv.orElseThrow(() -> new IllegalStateException("No available " + ApplicationEnvironment.class.getSimpleName() + " was discovered."));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test;
package org.microshed.testing;

/**
* Configuration representing application and dependent services already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test;
package org.microshed.testing;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.eclipse.microprofile.system.test.jupiter.MicroProfileTestExtension;
import org.junit.jupiter.api.extension.ExtendWith;
import org.microshed.testing.jupiter.MicroShedTestExtension;

/**
* References a SharedContainerConfiguration to be used by a test class
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(MicroProfileTestExtension.class)
@ExtendWith(MicroShedTestExtension.class)
public @interface SharedContainerConfig {

public Class<? extends SharedContainerConfiguration> value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test;
package org.microshed.testing;

/**
* To be used in conjunction with {@link SharedContainerConfig}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jaxrs;
package org.microshed.testing.jaxrs;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jaxrs;
package org.microshed.testing.jaxrs;

import java.util.Collections;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jupiter;
package org.microshed.testing.jupiter;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -27,7 +27,7 @@

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(MicroProfileTestExtension.class)
public @interface MicroProfileTest {
@ExtendWith(MicroShedTestExtension.class)
public @interface MicroShedTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jupiter;
package org.microshed.testing.jupiter;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;

import javax.inject.Inject;

import org.eclipse.microprofile.system.test.ApplicationEnvironment;
import org.eclipse.microprofile.system.test.jaxrs.RestClientBuilder;
import org.eclipse.microprofile.system.test.jwt.JwtBuilder;
import org.eclipse.microprofile.system.test.jwt.JwtConfig;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionConfigurationException;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.commons.support.AnnotationSupport;
import org.microshed.testing.ApplicationEnvironment;
import org.microshed.testing.jaxrs.RestClientBuilder;
import org.microshed.testing.jwt.JwtBuilder;
import org.microshed.testing.jwt.JwtConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -40,9 +40,9 @@
* Currently this is tied to Testcontainers managing runtime build/deployment, but in a future version
* it could be refactored to allow for a different framework managing the runtime build/deployment.
*/
public class MicroProfileTestExtension implements BeforeAllCallback {
public class MicroShedTestExtension implements BeforeAllCallback {

static final Logger LOGGER = LoggerFactory.getLogger(MicroProfileTestExtension.class);
static final Logger LOGGER = LoggerFactory.getLogger(MicroShedTestExtension.class);

@Override
public void beforeAll(ExtensionContext context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jwt;
package org.microshed.testing.jwt;

import java.security.Key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.system.test.jwt;
package org.microshed.testing.jwt;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.microshed.testing.ManuallyStartedConfiguration
8 changes: 4 additions & 4 deletions modules/liberty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.eclipse.microprofile.sandbox'
artifactId = 'system-test-liberty'
groupId = 'org.microshed'
artifactId = 'microshed-testing-liberty'
version = '0.1-SNAPSHOT'

from components.java
Expand All @@ -17,7 +17,7 @@ publishing {
description = "MicroProfile and JavaEE Testing framework :: Liberty extensions"

dependencies {
compile project(':system-test-testcontainers')
compile project(':microshed-testing-testcontainers')
}

publishToMavenLocal.dependsOn ':system-test-testcontainers:publishToMavenLocal'
publishToMavenLocal.dependsOn ':microshed-testing-testcontainers:publishToMavenLocal'
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.List;
import java.util.Map;

import org.testcontainers.containers.microprofile.spi.ServerAdapter;
import org.microshed.testing.testcontainers.spi.ServerAdapter;
import org.testcontainers.images.builder.ImageFromDockerfile;

public class LibertyAdapter implements ServerAdapter {
Expand Down
10 changes: 5 additions & 5 deletions modules/testcontainers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ plugins {
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.eclipse.microprofile.sandbox'
artifactId = 'system-test-testcontainers'
groupId = 'org.microshed'
artifactId = 'microshed-testing-testcontainers'
version = '0.1-SNAPSHOT'

from components.java
}
}
}

description = "MicroProfile and JavaEE Testing framework"
description = "MicroShed Testing :: Testcontainers extension"

dependencies {
compile project(':system-test-core')
compile project(':microshed-testing-core')
compile "org.testcontainers:junit-jupiter:1.12.0"
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
}

publishToMavenLocal.dependsOn ':system-test-core:publishToMavenLocal'
publishToMavenLocal.dependsOn ':microshed-testing-core:publishToMavenLocal'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.testcontainers.containers.microprofile;
package org.microshed.testing.testcontainers;

import java.nio.file.Path;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.testcontainers.containers.microprofile;
package org.microshed.testing.testcontainers;

import java.io.File;
import java.io.IOException;
Expand All @@ -39,15 +39,15 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import org.eclipse.microprofile.system.test.ApplicationEnvironment;
import org.eclipse.microprofile.system.test.testcontainers.HollowTestcontainersConfiguration;
import org.eclipse.microprofile.system.test.testcontainers.TestcontainersConfiguration;
import org.junit.jupiter.api.extension.ExtensionConfigurationException;
import org.microshed.testing.ApplicationEnvironment;
import org.microshed.testing.testcontainers.config.HollowTestcontainersConfiguration;
import org.microshed.testing.testcontainers.config.TestcontainersConfiguration;
import org.microshed.testing.testcontainers.spi.ServerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.microprofile.spi.ServerAdapter;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitStrategy;
Expand Down Expand Up @@ -258,10 +258,10 @@ public Integer getFirstMappedPort() {
}

/**
* Sets the application context root. The protocol, hostname, and port do not need to be
* included in the <code>appContextRoot</code> parameter. For example, an application
* "foo.war" is available at <code>http://localhost:8080/foo/</code> the context root can
* be set using <code>withAppContextRoot("/foo")</code>.
* @param appContextRoot the application context root. The protocol, hostname, and port do not need to be
* included in the <code>appContextRoot</code> parameter. For example, an application
* "foo.war" is available at <code>http://localhost:8080/foo/</code> the context root can
* be set using <code>withAppContextRoot("/foo")</code>.
*/
public SELF withAppContextRoot(String appContextRoot) {
Objects.requireNonNull(appContextRoot);
Expand Down Expand Up @@ -297,7 +297,7 @@ public SELF withReadinessPath(String readinessUrl) {
*
* @param readinessUrl The HTTP endpoint to be polled for readiness. Once the endpoint
* returns HTTP 200 (OK), the container is considered to be ready.
* @param timeout The amount of time to wait for the container to be ready.
* @param timeoutSeconds The amount of time (in seconds) to wait for the container to be ready.
*/
public SELF withReadinessPath(String readinessUrl, int timeoutSeconds) {
Objects.requireNonNull(readinessUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package org.testcontainers.containers.microprofile;
package org.microshed.testing.testcontainers;

import java.util.function.Consumer;

Expand Down
Loading

0 comments on commit 44af5d3

Please sign in to comment.