Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce running tests on stale sources + Junit 5 #46

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class BootstrapHelper {

public ClassLoader createClassLoader(List<URL> commonUrls, ClassLoader parentClassLoader) throws MalformedURLException {
public static ClassLoader createClassLoader(List<URL> commonUrls, ClassLoader parentClassLoader) throws MalformedURLException {

return new URLClassLoader(commonUrls.toArray(new URL[commonUrls.size()]), parentClassLoader);
}
Expand Down
8 changes: 8 additions & 0 deletions classloader-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@

<artifactId>reststop-classloader-utils</artifactId>

<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package org.kantega.reststop.classloaderutils;

import org.junit.Test;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
*
Expand Down Expand Up @@ -96,7 +98,7 @@ public void treeShouldSortByDependencies() {
assertThat(a, is(sorted.get(0)));
}

@Test(expected = CircularDependencyException.class)
@Test
public void shouldDetectCircularDependency() {

// c depends on b
Expand All @@ -107,7 +109,6 @@ public void shouldDetectCircularDependency() {
a.addDependsOn(c);



PluginInfo.resolveClassloaderOrder(infos);
assertThrows(CircularDependencyException.class, () -> PluginInfo.resolveClassloaderOrder(infos));
}
}
30 changes: 28 additions & 2 deletions integration-tests/hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
<version>1.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-client-impl</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
Expand All @@ -107,7 +114,6 @@
<version>1.0</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -306,10 +312,29 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<version>2.21.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>

<executions>
<execution>
<goals>
Expand All @@ -319,6 +344,7 @@
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.kantega.reststop.helloworld;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;

import javax.xml.namespace.QName;
Expand All @@ -31,8 +31,10 @@
import javax.xml.ws.WebServiceException;
import java.util.Map;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;


/**
*
Expand All @@ -55,12 +57,13 @@ public void shouldRespond() throws TransformerException {
assertThat(textContent, is("Hello, Joe!"));
}

@Test(expected = WebServiceException.class)
@Test
public void shouldFailBecauseOfNullReceiver() throws TransformerException {

Dispatch<Source> helloPort = getDispatch();

helloPort.invoke(new StreamSource(getClass().getResourceAsStream("helloRequest-fail.xml")));
assertThrows(WebServiceException.class,
() -> helloPort.invoke(new StreamSource(getClass().getResourceAsStream("helloRequest-fail.xml"))));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package org.kantega.reststop.helloworld;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kantega.reststop.helloworld.jaxrs.Hello;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.kantega.reststop.helloworld;

import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
Expand All @@ -26,7 +26,7 @@
import java.net.URL;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.kantega.reststop.helloworld.Utils.readPort;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.kantega.reststop.helloworld;

import org.eclipse.jetty.websocket.jsr356.ClientContainer;
import org.eclipse.jetty.websocket.jsr356.decoders.StringDecoder;
import org.eclipse.jetty.websocket.jsr356.encoders.StringEncoder;
import org.junit.jupiter.api.Test;

import javax.websocket.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.kantega.reststop.helloworld.Utils.readPort;

public class WebSocketIT {

@Test
void testToUpper() throws Exception {
Set<String> messages = new HashSet<>(asList("REst", "sTop", "ReststOp"));
Set<String> received = new HashSet<>();

CountDownLatch latch = new CountDownLatch(messages.size());

ClientContainer clientContainer = new ClientContainer();

ClientEndpointConfig config = ClientEndpointConfig.Builder.create()
.configurator(new ClientEndpointConfig.Configurator() {
@Override
public void beforeRequest(Map<String, List<String>> headers) {
super.beforeRequest(headers);
headers.put("Authorization", asList("Basic am9lOmpvZQ=="));
}
})
.decoders(asList(StringDecoder.class))
.encoders(asList(StringEncoder.class))
.build();
clientContainer.start();
Session session = clientContainer.connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig config) {
session.addMessageHandler(new MessageHandler.Whole<String>() {
@Override
public void onMessage(String message) {
received.add(message);
latch.countDown();
}
});
}
}, config, getEndpointURI());

RemoteEndpoint.Basic basicRemote = session.getBasicRemote();
for (String message : messages) {
basicRemote.sendText(message);
}
latch.await();
assertEquals(
messages.stream().map(String::toUpperCase).collect(Collectors.toSet()),
received);
}

private URI getEndpointURI() throws URISyntaxException {
String reststopPort = readPort();
return new URI("ws://localhost:" + reststopPort + "/toupper");
}
}
8 changes: 1 addition & 7 deletions maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,14 @@
<artifactId>org.eclipse.jgit</artifactId>
<version>3.6.2.201501210735-r</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<version>3.5.2</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
package org.kantega.reststop.maven;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.net.URL;
import java.nio.file.Paths;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;


public class MavenPomUtilsTest {

Expand Down
24 changes: 24 additions & 0 deletions plugins/development/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Loading