diff --git a/.travis.yml b/.travis.yml
index 3938f169f..77978f992 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,7 @@ sudo: true
language: java
install: ./gradlew clean
jdk:
- - oraclejdk8
-addons:
- apt:
- packages:
- - oracle-java8-installer
+ - openjdk8
+
+script:
+ - ./gradlew check -i
diff --git a/README.md b/README.md
index f2d07ab63..26bee39ed 100644
--- a/README.md
+++ b/README.md
@@ -366,3 +366,10 @@ plugins {
```
Maven users can use Shade plugin or equivalent (Maven assembly plugin).
+# Thanks to our Sponsors
+
+*  YourKit supports open source projects with innovative and intelligent tools
+for monitoring and profiling Java and .NET applications.
+YourKit is the creator of YourKit Java Profiler,
+YourKit .NET Profiler,
+and YourKit YouMonitor.
diff --git a/build.gradle b/build.gradle
index 3eab0c1b4..d4b678dfd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -63,7 +63,3 @@ subprojects {
}
-task wrapper(type: Wrapper) {
- gradleVersion = '2.14.1'
-}
-
diff --git a/gradle.properties b/gradle.properties
index 61ceaf011..3537f3600 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,29 +1,29 @@
-version=1.1.1
-springVersion=5.1.2.RELEASE
-springBootVersion=2.1.0.RELEASE
-jerseyVersion=2.27
-grizzlyVersion=2.4.3
-cyclopsVersion=10.0.4
+version=1.2.7
+springVersion=5.1.8.RELEASE
+springBootVersion=2.1.6.RELEASE
+jerseyVersion=2.28
+grizzlyVersion=2.4.4
+cyclopsVersion=10.3.3
hamcrestVersion=1.3
-hibernateVersion=5.3.7.Final
-hibernateValidator=6.0.13.Final
-springDataJPA=1.10.5.RELEASE
-guavaVersion=27.0-jre
-jacksonVersion=2.9.7
-guavaDatatypeVersion=2.9.7
+hibernateVersion=5.4.2.Final
+hibernateValidator=6.0.16.Final
+springDataJPA=2.1.8.RELEASE
+guavaVersion=27.1-jre
+jacksonVersion=2.9.8
+guavaDatatypeVersion=2.9.8
logbackVersion=1.1.3
-slf4jVersion=1.7.13
+slf4jVersion=1.7.26
aspectJVersion=1.8.7
jtaVersion=1.1
springMetricsVersion=3.1.3
datadogMetricsVersion=1.1.6
apacheHttpClientVersion=4.5.1
apacheHttpClientVersionAsync=4.1.1
-hikariCPVersion=2.4.6
+hikariCPVersion=3.3.1
curatorVersion=3.1.0
ebayCORSVersion=1.0.1
-dbcp2Version=2.1.1
+dbcp2Version=2.6.0
log4jVersion=1.2.17
s3Version=1.10.42
-tomcatVersion=9.0.13
+tomcatVersion=9.0.19
commonsIOVersion=2.5
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 994ef2076..738dba9f4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
diff --git a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Finder.java b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Finder.java
index 540a95e2a..ff7b52b45 100644
--- a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Finder.java
+++ b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Finder.java
@@ -1,7 +1,10 @@
package com.oath.micro.server.application.registry;
import java.io.File;
+import java.nio.charset.Charset;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -29,13 +32,17 @@ public Finder(RegisterConfig config) {
}
public List find(final Optional re) {
-
- List entries = findDir(new File(config.getOutputDir()));
- if (re.isPresent()) {
- entries = entries.stream().filter(e -> e.matches(re.get()))
- .collect(Collectors.toList());
+ try {
+ List entries = findDir(new File(config.getOutputDir()));
+ if (re.isPresent()) {
+ entries = entries.stream().filter(e -> e.matches(re.get()))
+ .collect(Collectors.toList());
+ }
+ return entries;
+ } catch (Exception e) {
+ logger.error("Failed to find entries. Error: {}", e.getMessage(), e);
+ return Collections.emptyList();
}
- return entries;
}
private List findDir(File dir) {
@@ -49,12 +56,10 @@ private List findDir(File dir) {
}
if (next.isFile()) {
try {
- String fileString = FileUtils.readFileToString(next);
+ String fileString = FileUtils.readFileToString(next, Charset.defaultCharset());
result.add(JacksonUtil.convertFromJson(fileString, RegisterEntry.class));
} catch (Exception e) {
- logger.error("Error loading service entry from disk {}", e,
- next.getAbsolutePath());
-
+ logger.error("Error loading service entry from disk {}, Error: {}", next.getAbsolutePath(), e.getMessage(), e);
}
}
});
diff --git a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Job.java b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Job.java
index fc5c04b6c..4b75ce32a 100644
--- a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Job.java
+++ b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/Job.java
@@ -7,6 +7,7 @@
import javax.annotation.PostConstruct;
+import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,15 +22,15 @@
public class Job {
private final Logger logger = LoggerFactory.getLogger(getClass());
- private final AsyncRestClient rest = new AsyncRestClient(
- 100, 2000);
+ private final AsyncRestClient rest = new AsyncRestClient(100, 2000);
private final String apiUrl;
private final ApplicationRegisterImpl app;
- private final String uuid = UUID.randomUUID()
- .toString();
+ private final String uuid = UUID.randomUUID().toString();
private final String resourcePath;
private final RegistryHealthChecker checker;
private final RegistryStatsChecker statsChecker;
+ @Getter
+ private int scheduled =0;
@Autowired
public Job(@Value("${service.registry.url:#{null}}") String apiUrl, ApplicationRegisterImpl app,
@@ -48,10 +49,11 @@ public Job(@Value("${service.registry.url:#{null}}") String apiUrl, ApplicationR
@PostConstruct
@Scheduled(fixedDelayString = "${service.registry.delay:1000}")
public synchronized void schedule() {
+ scheduled++;
try {
if (app.getApplication() != null && apiUrl != null) {
app.getApplication()
- .forEach(moduleEntry -> sendPing(moduleEntry));
+ .forEach(this::sendPing);
}
} catch (Exception e) {
logger.error("Failed to register services due to exception {}", e.getMessage(), e);
@@ -63,17 +65,14 @@ private void sendPing(RegisterEntry moduleEntry) {
.withUuid(uuid)
.withHealth(checker.isOk() ? Health.OK : Health.ERROR)
.withStats(nonEmptyOrNull(statsChecker.stats()));
- try {
- logger.debug("Posting {} to " + apiUrl + resourcePath,
- JacksonUtil.serializeToJson(entry));
- rest.post(apiUrl + resourcePath, JacksonUtil.serializeToJson(entry))
- .join();
- } catch (Exception e) {
- logger
- .warn("Failed posting {} to {}" + resourcePath, JacksonUtil.serializeToJson(entry),
- apiUrl);
+ String payload = JacksonUtil.serializeToJson(entry);
+ try {
+ logger.debug("Posting {} to {}{}", payload, apiUrl, resourcePath);
+ rest.post(apiUrl + resourcePath, payload).join();
+ } catch (Exception e) {
+ logger.warn("Failed posting {} to {}{}, Error: {}", payload, apiUrl, resourcePath, e.getMessage(), e);
}
}
diff --git a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/ServiceRegistryResource.java b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/ServiceRegistryResource.java
index 7a46de38a..471444b46 100644
--- a/micro-application-register/src/main/java/com/oath/micro/server/application/registry/ServiceRegistryResource.java
+++ b/micro-application-register/src/main/java/com/oath/micro/server/application/registry/ServiceRegistryResource.java
@@ -48,7 +48,7 @@ public void list(@Context UriInfo uriInfo, @Suspended AsyncResponse response) {
cleaner.clean();
response.resume(finder.find(UriInfoParser.toRegisterEntry(uriInfo)));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ logger.error("list failed with error: {}", e.getMessage(), e);
response.resume(Arrays.asList("Bad Request: " + e.getMessage()));
}
}));
@@ -65,7 +65,7 @@ public void schedule(@Suspended AsyncResponse response) {
job.schedule();
response.resume(HashMapBuilder.of("status", "success"));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ logger.error("schedule failed with error: {}", e.getMessage(), e);
response.resume(HashMapBuilder.of("status", "failure"));
}
}));
@@ -83,10 +83,9 @@ public void register(@Suspended AsyncResponse response, RegisterEntry entry) {
register.register(entry);
response.resume(HashMapBuilder.of("status", "complete"));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ logger.error("register failed with error: {}", e.getMessage(), e);
response.resume(HashMapBuilder.of("status", "failure"));
}
}));
}
-
}
diff --git a/micro-async-data-loader/build.gradle b/micro-async-data-loader/build.gradle
index ba787936c..08a5d844c 100644
--- a/micro-async-data-loader/build.gradle
+++ b/micro-async-data-loader/build.gradle
@@ -10,7 +10,6 @@ dependencies {
compile project(':micro-manifest-comparator')
testCompile project(':micro-grizzly-with-jersey')
testCompile project(':micro-couchbase')
- testCompile 'com.github.johnmcclean-aol:couchbasemock:master'
}
modifyPom {
diff --git a/micro-async-data-writer/build.gradle b/micro-async-data-writer/build.gradle
index b73fd425e..d0fe1d84f 100644
--- a/micro-async-data-writer/build.gradle
+++ b/micro-async-data-writer/build.gradle
@@ -10,7 +10,6 @@ dependencies {
compile project(':micro-manifest-comparator')
testCompile project(':micro-grizzly-with-jersey')
testCompile project(':micro-couchbase')
- testCompile 'com.github.johnmcclean-aol:couchbasemock:master'
}
modifyPom {
diff --git a/micro-boot/README.md b/micro-boot/README.md
index dace93a8c..796d575d2 100644
--- a/micro-boot/README.md
+++ b/micro-boot/README.md
@@ -2,8 +2,9 @@
[micro-boot example apps](https://github.com/aol/micro-server/tree/master/micro-boot/src/test/java/app)
-**micro-boot** allows Microserver front ends to use Spring Boot backends (in other words it adds Spring Boot as a plugin to Microserver). To use full-stack Spring Boot with Microserver (and Jersey) see the [micro-spring-boot plugin](https://github.com/aol/micro-server/tree/master/micro-spring-boot) (in other words to use Microserver as a plugin to Spring Boot use micro-sprint-boot rather than this plugin).
-
+**micro-boot** allows Microserver front ends to use Microserver plugins with Spring Boot without configuring support for the micro-jersey plugin. Rest and Web end points in Microserver
+plugins may not be available (but the Spring beans will be and can be used to expose the same data in a different manner).
+To use full-stack Spring Boot with Microserver (and. Jersey) see the [micro-spring-boot plugin](https://github.com/aol/micro-server/tree/master/micro-spring-boot).
## A simple example with one resource
* Annotate your classes with @Microboot to let Spring Boot know the base package for auto-scanning Spring beans.
@@ -12,42 +13,40 @@
* You can now use the @Microserver annotation for configuration (except for base auto-scan packages)
+[Spring Boot Hello World example](https://spring.io/guides/gs/spring-boot/) converted to a micro-boot test
```java
-@Microboot //configure this package as the base for autoscan
-//optionally use @Microserver here for more configuration options
-public class SimpleExample {
-
- RestClient rest = new RestClient(10_000,1_000);
-
-
- public static void main (String[] args){
-
- new MicroserverApp(()-> "simple-app").start();
-
- assertThat(rest.get("http://localhost:8080/simple-app/status/ping"),equalTo("ok"));
-
- }
-
-
-
+@Microserver
+@MicroBoot
+public class Application {
+
+
+ AsyncRestClient rest = new AsyncRestClient(1000,1000).withAccept("text/plain");
+
+ @Test
+ public void runAppAndBasicTest() throws InterruptedException, ExecutionException {
+
+ new MicroserverApp( ()-> "spring-mvc");
+ Thread.sleep(2000);
+
+ assertThat(rest.get("http://localhost:8080/spring-mvc").get(),is("Greetings from Spring Boot with Microserver!"));
+
+ }
+
+
}
-@Rest
-@Path("/status")
-public class SimpleResource{
-
-
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
-
- return "ok";
- }
-
-
+
+
+@RestController
+public class HelloController {
+
+ @RequestMapping("/")
+ public String index() {
+ return "Greetings from Spring Boot with Microserver!";
+ }
+
}
+
```
## To use
diff --git a/micro-boot/build.gradle b/micro-boot/build.gradle
index 195cea8de..9f0d479e3 100644
--- a/micro-boot/build.gradle
+++ b/micro-boot/build.gradle
@@ -4,15 +4,35 @@ dependencies {
compile 'org.springframework.boot:spring-boot:' + springBootVersion
compile 'org.springframework.boot:spring-boot-autoconfigure:' + springBootVersion
compile project(':micro-core')
- testCompile group: 'com.google.guava', name: 'guava', version: guavaVersion
- testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: hamcrestVersion
- testCompile project(':micro-jackson-configuration')
- testCompile project(':micro-grizzly')
+
+ compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version: "$jerseyVersion"
+ compile(group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: "$jerseyVersion") {
+ exclude(module: 'jackson-xc')
+ exclude(module: 'jackson-core-asl')
+ exclude(module: 'jackson-jaxrs')
+ exclude(module: 'jackson-mapper-asl')
+ }
+ compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: "$jerseyVersion"
+
+ compile "org.glassfish.jersey.media:jersey-media-multipart:$jerseyVersion"
+ compile "org.glassfish.jersey.ext:jersey-spring4:$jerseyVersion"
+ compile "org.glassfish.jersey.ext:jersey-bean-validation:$jerseyVersion"
+
+ compile project(':micro-jackson-configuration')
+
+ testCompile("org.springframework.boot:spring-boot-starter-web:"+ springBootVersion)
+ testCompile 'org.springframework.boot:spring-boot-starter-test:' + springBootVersion
+ testCompile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: "$jerseyVersion"
+ testCompile 'org.apache.tomcat.embed:tomcat-embed-core:' + tomcatVersion
+
+ testCompile project(':micro-application-register')
+ testCompile project(':micro-cors')
testCompile project(':micro-swagger')
testCompile project(':micro-client')
testCompile project(':micro-events')
- testCompile project(':micro-jersey')
testCompile project(':micro-metrics')
+ testCompile project(':micro-guava')
+
testCompile "com.oath.cyclops:cyclops-futurestream:$cyclopsVersion"
}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/boot/BootFrontEndApplicationConfigurator.java b/micro-boot/src/main/java/com/oath/micro/server/boot/BootFrontEndApplicationConfigurator.java
new file mode 100644
index 000000000..0c683bea2
--- /dev/null
+++ b/micro-boot/src/main/java/com/oath/micro/server/boot/BootFrontEndApplicationConfigurator.java
@@ -0,0 +1,113 @@
+package com.oath.micro.server.boot;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequestListener;
+
+import com.oath.cyclops.types.persistent.PersistentList;
+import com.oath.micro.server.GlobalState;
+import com.oath.micro.server.module.MicroserverEnvironment;
+import cyclops.reactive.ReactiveSeq;
+import cyclops.reactive.collections.immutable.LinkedListX;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+import org.springframework.boot.web.servlet.ServletContextInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.ContextLoader;
+
+
+import com.oath.micro.server.config.Config;
+import com.oath.micro.server.module.Module;
+import com.oath.micro.server.module.ModuleDataExtractor;
+import com.oath.micro.server.servers.FilterConfigurer;
+import com.oath.micro.server.servers.ServletConfigurer;
+import com.oath.micro.server.servers.ServletContextListenerConfigurer;
+import com.oath.micro.server.servers.model.FilterData;
+import com.oath.micro.server.servers.model.ServerData;
+import com.oath.micro.server.servers.model.ServletData;
+import com.oath.micro.server.spring.SpringBuilder;
+
+public class BootFrontEndApplicationConfigurator extends SpringBootServletInitializer implements SpringBuilder {
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public ConfigurableApplicationContext createSpringApp(Config config, Class...classes) {
+
+
+ List classList = new ArrayList();
+ classList.addAll(Arrays.asList(classes));
+
+
+ SpringApplicationBuilder builder = new SpringApplicationBuilder(classList.toArray(new Class[0]));
+
+
+
+
+ return builder.application().run();
+ }
+
+ @Override
+ public Class[] classes(Config config, Class... classes) {
+ List classList = new ArrayList();
+ classList.addAll(Arrays.asList(classes));
+
+ return ReactiveSeq.fromIterable(classList)
+ .toArray(i->new Class[i]);
+
+ }
+
+ @Component
+ static class MyWebAppInitializer implements ServletContextInitializer {
+
+ private final MicroserverEnvironment microserverEnvironment;
+ private final Module module;
+ private final ApplicationContext rootContext;
+ @Autowired(required=false)
+ public MyWebAppInitializer(MicroserverEnvironment env, ApplicationContext rootContext, Module m){
+ this.microserverEnvironment = env;
+ this.rootContext = rootContext;
+ this.module = m;
+ }
+ @Autowired(required=false)
+ public MyWebAppInitializer(MicroserverEnvironment env, ApplicationContext rootContext){
+ this(env,rootContext, GlobalState.state.getModules().firstValue(null));
+ }
+
+ @Override
+ public void onStartup(ServletContext webappContext) throws ServletException {
+
+ ModuleDataExtractor extractor = new ModuleDataExtractor(module);
+ microserverEnvironment.assureModule(module);
+ String fullRestResource = "/" + module.getContext() + "/*";
+
+ ServerData serverData = new ServerData(microserverEnvironment.getModuleBean(module).getPort(),
+ Arrays.asList(),
+ rootContext, fullRestResource, module);
+ List filterDataList = extractor.createFilteredDataList(serverData);
+ List servletDataList = extractor.createServletDataList(serverData);
+ new ServletConfigurer(serverData, LinkedListX.fromIterable(servletDataList)).addServlets(webappContext);
+
+ new FilterConfigurer(serverData, LinkedListX.fromIterable(filterDataList)).addFilters(webappContext);
+ PersistentList servletContextListenerData = LinkedListX.fromIterable(module.getListeners(serverData)).filter(i->!(i instanceof ContextLoader));
+ PersistentList servletRequestListenerData = LinkedListX.fromIterable(module.getRequestListeners(serverData));
+
+ new ServletContextListenerConfigurer(serverData, servletContextListenerData, servletRequestListenerData).addListeners(webappContext);
+
+ }
+
+ }
+
+
+}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/boot/BootPlugin.java b/micro-boot/src/main/java/com/oath/micro/server/boot/BootPlugin.java
new file mode 100644
index 000000000..fa93c7333
--- /dev/null
+++ b/micro-boot/src/main/java/com/oath/micro/server/boot/BootPlugin.java
@@ -0,0 +1,44 @@
+package com.oath.micro.server.boot;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+import javax.ws.rs.core.FeatureContext;
+
+import cyclops.reactive.collections.mutable.MapX;
+import cyclops.reactive.collections.mutable.SetX;
+import cyclops.reactive.companion.MapXs;
+import org.glassfish.jersey.CommonProperties;
+
+
+import com.oath.micro.server.Plugin;
+import com.oath.micro.server.spring.SpringBuilder;
+
+/**
+ *
+ * @author johnmcclean
+ *
+ */
+public class BootPlugin implements Plugin{
+
+
+ /**
+ * @return Engine for building Spring Context
+ */
+ public SpringBuilder springBuilder(){
+ return new BootFrontEndApplicationConfigurator();
+ }
+
+ @Override
+ public Set springClasses() {
+ return SetX.empty();
+ }
+
+ @Override
+ public Function> jacksonFeatureProperties(){
+ return context-> new HashMap<>();
+ }
+
+}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/boot/config/Microboot.java b/micro-boot/src/main/java/com/oath/micro/server/boot/MicroBoot.java
similarity index 87%
rename from micro-boot/src/main/java/com/oath/micro/server/boot/config/Microboot.java
rename to micro-boot/src/main/java/com/oath/micro/server/boot/MicroBoot.java
index ad00fc258..46916cfcc 100644
--- a/micro-boot/src/main/java/com/oath/micro/server/boot/config/Microboot.java
+++ b/micro-boot/src/main/java/com/oath/micro/server/boot/MicroBoot.java
@@ -1,4 +1,4 @@
-package com.oath.micro.server.boot.config;
+package com.oath.micro.server.boot;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -13,6 +13,6 @@
@Target(ElementType.TYPE)
@Component
@SpringBootApplication(exclude = SpringDataWebAutoConfiguration.class)
-public @interface Microboot{
+public @interface MicroBoot {
}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/rest/jersey/SpringBootJerseyRestApplication.java b/micro-boot/src/main/java/com/oath/micro/server/rest/jersey/SpringBootJerseyRestApplication.java
new file mode 100644
index 000000000..dd1894c1a
--- /dev/null
+++ b/micro-boot/src/main/java/com/oath/micro/server/rest/jersey/SpringBootJerseyRestApplication.java
@@ -0,0 +1,87 @@
+package com.oath.micro.server.rest.jersey;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import com.oath.micro.server.rest.jackson.JacksonUtil;
+import cyclops.reactive.collections.immutable.LinkedListX;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.server.ServerProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+
+import com.oath.micro.server.GlobalState;
+import com.oath.micro.server.auto.discovery.Rest;
+import com.oath.micro.server.auto.discovery.RestResource;
+import com.oath.micro.server.module.JaxRsProvider;
+import com.oath.micro.server.module.Module;
+import com.oath.micro.server.module.ModuleDataExtractor;
+
+import javax.ws.rs.ext.Provider;
+
+public class SpringBootJerseyRestApplication extends ResourceConfig {
+
+ @Autowired(required=false)
+ public SpringBootJerseyRestApplication(ApplicationContext context){
+ this(context, GlobalState.state.getModules().firstValue(null));
+ }
+
+ @Autowired(required=false)
+ public SpringBootJerseyRestApplication(ApplicationContext context,Module module){
+ ModuleDataExtractor extractor = new ModuleDataExtractor(module);
+
+ LinkedListX allResources = extractor.getRestResources(context);
+
+ System.out.println("Resources " + allResources);
+ Map serverProperties = module.getServerProperties();
+ if (allResources != null) {
+ for (Object next : allResources) {
+ if(isSingleton(next))
+ register(next);
+ else
+ register(next.getClass());
+ }
+ }
+
+ if (serverProperties.isEmpty()) {
+ property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
+ //http://stackoverflow.com/questions/25755773/bean-validation-400-errors-are-returning-default-error-page-html-instead-of-re
+ property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
+ } else {
+ for (Map.Entry entry : serverProperties.entrySet()) {
+ property(entry.getKey(), entry.getValue());
+ }
+ }
+
+
+ context.getBeansOfType(AbstractBinder.class).forEach((n,e)->register(e));
+
+ JacksonJaxbJsonProvider p = new JacksonJaxbJsonProvider();
+ p.setMapper(JacksonUtil.getMapper());
+ register(p);
+ module.getDefaultJaxRsPackages()
+ .stream()
+ .forEach(e -> packages(e));
+ module.getDefaultResources()
+ .stream()
+ .forEach(e -> register(e));
+
+
+ module.getResourceConfigManager().accept(new JaxRsProvider<>(this));
+ }
+
+
+ private boolean isSingleton(Object next) {
+ if(next instanceof RestResource)
+ return ((RestResource)next).isSingleton();
+ Rest rest = next.getClass().getAnnotation(Rest.class);
+ if(rest == null)
+ return !(next instanceof Class);
+ return rest.isSingleton();
+ }
+
+
+
+
+}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootApplicationConfigurator.java b/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootApplicationConfigurator.java
deleted file mode 100644
index 144cc5024..000000000
--- a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootApplicationConfigurator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.oath.micro.server.spring.boot;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import cyclops.reactive.ReactiveSeq;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.ConfigurableApplicationContext;
-
-import com.oath.micro.server.config.Config;
-import com.oath.micro.server.spring.SpringBuilder;
-
-public class BootApplicationConfigurator implements SpringBuilder {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- public ConfigurableApplicationContext createSpringApp(Config config, Class...classes) {
-
-
- List classList = new ArrayList();
- classList.addAll(Arrays.asList(classes));
- classList.add(JerseyApplication.class);
- SpringApplicationBuilder builder = new SpringApplicationBuilder(classList.toArray(new Class[0]));
- new JerseyApplication(classList).config(builder);
-
- return builder.application().run();
- }
-
- @Override
- public Class[] classes(Config config, Class... classes) {
- List classList = new ArrayList();
- classList.addAll(Arrays.asList(classes));
- return ReactiveSeq.fromIterable(new JerseyApplication(classList).classes).appendAll(classList)
- .toArray(i->new Class[i]);
- }
-
-
-}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootPlugin.java b/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootPlugin.java
deleted file mode 100644
index 8f0ffdb72..000000000
--- a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/BootPlugin.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.oath.micro.server.spring.boot;
-
-import com.oath.micro.server.Plugin;
-import com.oath.micro.server.spring.SpringBuilder;
-
-/**
- *
- * @author johnmcclean
- *
- */
-public class BootPlugin implements Plugin{
-
-
- /**
- * @return Engine for building Spring Context
- */
- public SpringBuilder springBuilder(){
- return new BootApplicationConfigurator();
- }
-
-
-}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseyApplication.java b/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseyApplication.java
deleted file mode 100644
index cae468f7c..000000000
--- a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseyApplication.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.oath.micro.server.spring.boot;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Properties;
-
-import org.springframework.boot.builder.SpringApplicationBuilder;
-
-import org.springframework.boot.web.server.WebServer;
-import org.springframework.boot.web.server.WebServerException;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-
-import com.oath.micro.server.module.MicroserverEnvironment;
-import com.oath.micro.server.servers.AccessLogLocationBean;
-import com.oath.micro.server.spring.properties.PropertyFileConfig;
-
-
-@Configuration
-@PropertySource("classpath:spring-boot-microserver.properties")
-public class JerseyApplication extends SpringBootServletInitializer {
-
- List classes;
-
- public JerseyApplication(){
- classes = new ArrayList<>();
- }
-
- public JerseyApplication(List classes2) {
- classes = new ArrayList<>();
- classes.addAll(classes2);
- classes.add(JerseyApplication.class);
- classes.add(PropertyFileConfig.class);
- classes.add(MicroserverEnvironment.class);
- classes.add(AccessLogLocationBean.class);
- }
-
-
- @Override
- protected SpringApplicationBuilder configure(
- SpringApplicationBuilder application) {
-
- return application.sources(classes.toArray(new Class[0]));
- }
-
- public SpringApplicationBuilder config(SpringApplicationBuilder builder) {
- return configure(builder);
-
- }
-
- @Bean
- public AccessLogLocationBean createAccessLogLocationBean(
- ApplicationContext rootContext) {
- Properties props = (Properties) rootContext.getBean("propertyFactory");
- String location = Optional.ofNullable(
- (String) props.get("access.log.output")).orElse("./logs/");
- return new AccessLogLocationBean(location);
- }
-
-
-
-
-
-
- @Bean
- public ServletWebServerFactory servletContainer() {
-
- return (initializers) -> {
- return new Container();
- };
-
-
- }
-
- static class Container implements WebServer {
-
- @Override
- public void start() throws WebServerException {
-
-
- }
-
- @Override
- public void stop() throws WebServerException {
-
- }
-
- @Override
- public int getPort() {
-
- return 0;
- }
-
- }
-
-}
diff --git a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseySpringBootFrontEndApplication.java b/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseySpringBootFrontEndApplication.java
deleted file mode 100644
index 88d03368c..000000000
--- a/micro-boot/src/main/java/com/oath/micro/server/spring/boot/JerseySpringBootFrontEndApplication.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.oath.micro.server.spring.boot;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Properties;
-
-import com.oath.micro.server.module.MicroserverEnvironment;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-
-import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-
-import com.oath.micro.server.servers.AccessLogLocationBean;
-import com.oath.micro.server.spring.properties.PropertyFileConfig;
-
-
-@Configuration
-@PropertySource("classpath:spring-boot-microserver.properties")
-public class JerseySpringBootFrontEndApplication extends SpringBootServletInitializer {
-
- List classes;
-
- public JerseySpringBootFrontEndApplication(){
- classes = new ArrayList<>();
- }
-
- public JerseySpringBootFrontEndApplication(List classes2) {
- classes = new ArrayList<>();
- classes.addAll(classes2);
- classes.add(JerseySpringBootFrontEndApplication.class);
- classes.add(PropertyFileConfig.class);
- classes.add(MicroserverEnvironment.class);
- classes.add(AccessLogLocationBean.class);
- }
-
-
- @Override
- protected SpringApplicationBuilder configure(
- SpringApplicationBuilder application) {
-
- return application.sources(classes.toArray(new Class[0]));
- }
-
- public SpringApplicationBuilder config(SpringApplicationBuilder builder) {
- return configure(builder);
-
- }
-
- @Bean
- public AccessLogLocationBean createAccessLogLocationBean(
- ApplicationContext rootContext) {
- Properties props = (Properties) rootContext.getBean("propertyFactory");
- String location = Optional.ofNullable(
- (String) props.get("access.log.output")).orElse("./logs/");
- return new AccessLogLocationBean(location);
- }
-
-
-
-
-
-
-
-}
diff --git a/micro-boot/src/main/resources/META-INF/services/com.oath.micro.server.Plugin b/micro-boot/src/main/resources/META-INF/services/com.oath.micro.server.Plugin
index e726bf190..cdb0f8ada 100644
--- a/micro-boot/src/main/resources/META-INF/services/com.oath.micro.server.Plugin
+++ b/micro-boot/src/main/resources/META-INF/services/com.oath.micro.server.Plugin
@@ -1 +1 @@
-com.oath.micro.server.spring.boot.BootPlugin
\ No newline at end of file
+com.oath.micro.server.boot.BootPlugin
diff --git a/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncAppRunner.java b/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncAppRunner.java
deleted file mode 100644
index 7737faf12..000000000
--- a/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncAppRunner.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package app.boot.com.oath.micro.server;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.rest.client.nio.AsyncRestClient;
-
-@Microserver @Microboot
-public class AsyncAppRunner {
-
-
- AsyncRestClient rest = new AsyncRestClient(1000,1000).withAccept("text/plain");
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp( ()-> "async-app");
- server.start();
-
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
- Thread.sleep(2000);
-
- assertThat(rest.get("http://localhost:8080/async-app/async/expensive").get(),is(";test!;test!;test!"));
-
- }
-
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncResource.java b/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncResource.java
deleted file mode 100644
index e783ec439..000000000
--- a/micro-boot/src/test/java/app/boot/com/oath/micro/server/AsyncResource.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package app.boot.com.oath.micro.server;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.container.AsyncResponse;
-import javax.ws.rs.container.Suspended;
-
-import cyclops.futurestream.SimpleReact;
-import org.springframework.stereotype.Component;
-
-
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.oath.micro.server.rest.client.nio.AsyncRestClient;
-import com.google.common.collect.ImmutableList;
-
-@Path("/async")
-@Component
-public class AsyncResource implements RestResource{
-
- private final SimpleReact simpleReact =new SimpleReact();
- private final ImmutableList urls = ImmutableList.of("http://localhost:8080/async-app/async/ping2",
- "http://localhost:8080/async-app/async/ping",
- "http://localhost:8080/async-app/async/ping",
- "http://localhost:8080/async-app/async/ping");
-
- private final AsyncRestClient client = new AsyncRestClient(1000,1000).withAccept("text/plain");
-
- @GET
- @Path("/expensive")
- @Produces("text/plain")
- public void expensive(@Suspended AsyncResponse asyncResponse){
-
- simpleReact.fromStream(urls.stream()
- .>map(it -> client.get(it)))
- .onFail(it -> "")
- .peek(it ->
- System.out.println(it))
- .allOf(data -> {
- System.out.println(data);
- return asyncResponse.resume(String.join(";", (List)data)); });
-
- }
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "test!";
- }
-
-
-}
diff --git a/micro-boot/src/test/java/app/boot/com/oath/micro/server/SimpleApp.java b/micro-boot/src/test/java/app/boot/com/oath/micro/server/SimpleApp.java
deleted file mode 100644
index 29820978c..000000000
--- a/micro-boot/src/test/java/app/boot/com/oath/micro/server/SimpleApp.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package app.boot.com.oath.micro.server;
-
-import com.oath.micro.server.MicroserverApp;
-
-
-public class SimpleApp {
-
- public static void main(String[] args){
- new MicroserverApp(()->"test-app").run();
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppResource.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppResource.java
deleted file mode 100644
index a5e3944a1..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppResource.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import java.util.List;
-
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-
-@AltAppRestResource
-@Path("/alt-status")
-public class AltAppResource {
-
- @POST
- @Produces("application/json")
- @Path("/ping")
- public List ping(ImmutableEntity entity) {
- return entity.getList();
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppRestResource.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppRestResource.java
deleted file mode 100644
index 617581f1b..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/AltAppRestResource.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.oath.micro.server.auto.discovery.Rest;
-
-@Rest
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface AltAppRestResource {
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppLocalMain.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppLocalMain.java
deleted file mode 100644
index d2690d56d..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppLocalMain.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import java.util.Arrays;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.module.EmbeddedModule;
-
-@Microserver @Microboot//(basePackages = { "app.boot.embedded.com.oath.micro.server" })
-public class EmbeddedAppLocalMain {
-
-
- public static void main(String[] args) throws InterruptedException {
-
- new MicroserverApp(
- EmbeddedModule.tagInterfaceModule(Arrays.asList(TestAppRestResource.class),"test-app"),
- EmbeddedModule.tagInterfaceModule(Arrays.asList(AltAppRestResource.class),"alternative-app")).start();
-
-
-
- }
-
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppTest.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppTest.java
deleted file mode 100644
index a94e9109e..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/EmbeddedAppTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-
-import javax.ws.rs.NotFoundException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.util.concurrent.ListenableFuture;
-import org.springframework.util.concurrent.ListenableFutureCallback;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.module.EmbeddedModule;
-import com.oath.micro.server.testing.RestAgent;
-import com.google.common.collect.ImmutableList;
-
-public class EmbeddedAppTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
-
- @Before
- public void startServer(){
- server = new MicroserverApp(EmbeddedAppLocalMain.class,
- EmbeddedModule.annotationModule(Arrays.asList(TestAppRestResource.class),"test-app"),
- EmbeddedModule.annotationModule(Arrays.asList(AltAppRestResource.class),"alternative-app"));
- server.start();
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void confirmExpectedUrlsPresentTest() throws InterruptedException, ExecutionException{
-
- assertThat(rest.get("http://localhost:8080/test-app/test-status/ping"),is("test!"));
-
-
- assertThat((List)rest.post("http://localhost:8081/alternative-app/alt-status/ping",new ImmutableEntity("value",ImmutableList.of("hello","world")),List.class),
- hasItem("hello"));
-
- }
-
-
- @Test
- public void nonBlockingRestClientTest(){
- assertThat(rest.get("http://localhost:8080/test-app/test-status/rest-calls"),is("-*test!-*test!"));
- }
-
- CompletableFuture toCompletableFuture(
- final ListenableFuture listenableFuture
- ) {
- //create an instance of CompletableFuture
- CompletableFuture completable = new CompletableFuture() {
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- // propagate cancel to the listenable future
- boolean result = listenableFuture.cancel(mayInterruptIfRunning);
- super.cancel(mayInterruptIfRunning);
- return result;
- }
- };
-
- // add callback
- listenableFuture.addCallback(new ListenableFutureCallback() {
- @Override
- public void onSuccess(T result) {
- completable.complete(result);
- }
-
- @Override
- public void onFailure(Throwable t) {
- completable.completeExceptionally(t);
- }
- });
- return completable;
- }
-
- @Test(expected=NotFoundException.class)
- public void confirmAltAppCantUseTestAppResources(){
-
- assertThat(rest.get("http://localhost:8080/alternative-app/test-status/ping"),is("test!"));
-
- }
- @Test(expected=NotFoundException.class)
- public void confirmTestAppCantUseAltAppResources(){
-
- assertThat((List)rest.post("http://localhost:8081/test-app/alt-status/ping",new ImmutableEntity("value",ImmutableList.of("hello","world")),List.class),
- hasItem("hello"));
-
- }
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/ImmutableEntity.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/ImmutableEntity.java
deleted file mode 100644
index 1e291b624..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/ImmutableEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Builder;
-
-import com.google.common.collect.ImmutableList;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "")
-@XmlRootElement(name = "immutable")
-@Getter
-@AllArgsConstructor
-@Builder
-public class ImmutableEntity {
-
- private final String value;
- private final ImmutableList list;
-
- public ImmutableEntity() {
- this(null,null);
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppResource.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppResource.java
deleted file mode 100644
index be67056f6..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppResource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import cyclops.futurestream.SimpleReact;
-import org.springframework.beans.factory.annotation.Autowired;
-
-
-import com.oath.micro.server.rest.client.nio.NIORestClient;
-import com.google.common.collect.ImmutableList;
-//@Component
-@TestAppRestResource
-@Path("/test-status")
-public class TestAppResource {
-
- private final SimpleReact simpleReact = new SimpleReact();
- private final NIORestClient template;
- private final ImmutableList urls = ImmutableList.of("http://localhost:8081/alternative-app/alt-status/ping",
- "http://localhost:8080/test-app/test-status/ping",
- "http://localhost:8082/simple-app/status/ping",
- "http://localhost:8080/test-app/test-status/ping");
-
- @Autowired
- public TestAppResource(NIORestClient template) {
-
- this.template = template;
- }
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "test!";
- }
-
- @GET
- @Produces("text/plain")
- @Path("/rest-calls")
- public String restCallResult(){
-
- return simpleReact
- .fromStream(urls.stream()
- .map(it -> template.getForEntity(it,String.class)))
- .then(it -> it.getBody())
- .then(it -> "*"+it)
- .peek(loadedAndModified -> System.out.println(loadedAndModified))
- .block().stream().reduce("", (acc,next) -> acc+"-"+next);
-
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppRestResource.java b/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppRestResource.java
deleted file mode 100644
index 537c78247..000000000
--- a/micro-boot/src/test/java/app/boot/embedded/com/oath/micro/server/TestAppRestResource.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package app.boot.embedded.com.oath.micro.server;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.oath.micro.server.auto.discovery.Rest;
-
-@Rest
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface TestAppRestResource{
-
-}
diff --git a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventRunnerTest.java b/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventRunnerTest.java
deleted file mode 100644
index 29350f6bc..000000000
--- a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventRunnerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package app.boot.events.com.oath.micro.server;
-
-
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.rest.client.nio.AsyncRestClient;
-import com.oath.micro.server.testing.RestAgent;
-
-@Microserver @Microboot
-public class EventRunnerTest {
-
- RestAgent rest = new RestAgent();
- private final AsyncRestClient client = new AsyncRestClient(1000,1000).withAccept("application/json");
- MicroserverApp server;
-
-
- @Before
- public void startServer(){
-
- server = new MicroserverApp(()-> "event-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
-
-
- assertThat(rest.get("http://localhost:8080/event-app/status/ping"),is("ok"));
-
- assertThat(client.get("http://localhost:8080/event-app/active/jobs").get(),
- containsString("startedAt"));
- assertThat(client.get("http://localhost:8080/event-app/active/requests").get(),
- containsString("startedAt"));
- assertThat(client.get("http://localhost:8080/event-app/manifest").get(),
- containsString("Manifest"));
-
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventStatusResource.java b/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventStatusResource.java
deleted file mode 100644
index fadef80d6..000000000
--- a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/EventStatusResource.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package app.boot.events.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.oath.micro.server.events.RequestEvents;
-import com.google.common.eventbus.EventBus;
-
-@Component
-@Path("/status")
-public class EventStatusResource implements RestResource {
-
-
-
-
- private final EventBus bus;
-
- @Autowired
- public EventStatusResource(EventBus bus ){
- this.bus = bus;
- }
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- bus.post(RequestEvents.start("get", 1l));
- try{
- return "ok";
- }finally{
- bus.post(RequestEvents.finish("get",1l));
- }
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Job.java b/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Job.java
deleted file mode 100644
index 733a8c2ae..000000000
--- a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Job.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package app.boot.events.com.oath.micro.server;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.events.ScheduledJob;
-import com.oath.micro.server.events.SystemData;
-
-@Component
-public class Job implements ScheduledJob{
-
- @Override
- public SystemData scheduleAndLog() {
- return SystemData.builder().errors(0).processed(2).build();
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Schedular.java b/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Schedular.java
deleted file mode 100644
index a14db58f9..000000000
--- a/micro-boot/src/test/java/app/boot/events/com/oath/micro/server/Schedular.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package app.boot.events.com.oath.micro.server;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-
-@Component
-public class Schedular {
-
- private final Job job;
-
- @Autowired
- public Schedular(final Job job){
- this.job=job;
- }
-
- @Scheduled(fixedDelay=1)
- public synchronized void scheduleTask(){
- job.scheduleAndLog();
- }
-}
diff --git a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/AutodiscoveredFilter.java b/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/AutodiscoveredFilter.java
deleted file mode 100644
index 7e5aa145e..000000000
--- a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/AutodiscoveredFilter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package app.boot.filter.com.oath.micro.server;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.AutoFilterConfiguration;
-
-import lombok.Getter;
-
-@Component
-public class AutodiscoveredFilter implements AutoFilterConfiguration {
-
- @Getter
- private static volatile int called= 0;
-
- @Override
- public String[] getMapping() {
- return new String[] { "/*" };
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
-
- }
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
-
- called++;
- chain.doFilter(request, response);
- }
-
- @Override
- public void destroy() {
-
-
- }
-
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/ConfiguredFilter.java b/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/ConfiguredFilter.java
deleted file mode 100644
index 325bf3944..000000000
--- a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/ConfiguredFilter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package app.boot.filter.com.oath.micro.server;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import lombok.Getter;
-
-public class ConfiguredFilter implements Filter {
-
- @Getter
- private static volatile int called= 0;
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- called++;
- chain.doFilter(request, response);
-
- }
-
- @Override
- public void destroy() {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterAppLocalMain.java b/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterAppLocalMain.java
deleted file mode 100644
index bbe48664c..000000000
--- a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterAppLocalMain.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package app.boot.filter.com.oath.micro.server;
-
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-
-import com.oath.micro.server.MicroserverApp;
-@Configuration
-@ComponentScan(basePackages = { "app.filter.com.oath.micro.server" })
-public class FilterAppLocalMain {
-
-
-
-
- public static void main(String[] args) throws InterruptedException {
-
- new MicroserverApp( FilterAppLocalMain.class, () -> "filter-app")
- .run();
- }
-
- }
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterRunnerTest.java b/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterRunnerTest.java
deleted file mode 100644
index 09d56426b..000000000
--- a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterRunnerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package app.boot.filter.com.oath.micro.server;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import javax.servlet.Filter;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.module.ConfigurableModule;
-import com.oath.micro.server.testing.RestAgent;
-import com.google.common.collect.ImmutableMap;
-
-@Ignore
-public class FilterRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
- Map filters = ImmutableMap.of("/filter-app/status/ping2",new ConfiguredFilter());
- server = new MicroserverApp( FilterAppLocalMain.class, ConfigurableModule.builder().context("filter-app").filters(filters ).build());
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void testAutoDiscoveredFilter() throws InterruptedException, ExecutionException{
- Thread.sleep(100);
- assertThat(AutodiscoveredFilter.getCalled(),is(0));
- assertThat(rest.get("http://localhost:8080/filter-app/status/ping"),is("ok"));
- assertThat(AutodiscoveredFilter.getCalled(),is(0));
- }
- @Test
- public void testConfiguredFilter() throws InterruptedException, ExecutionException{
- Thread.sleep(100);
- assertThat(ConfiguredFilter.getCalled(),is(0));
- assertThat(rest.get("http://localhost:8080/filter-app/status/ping2"),is("ok"));
- assertThat(ConfiguredFilter.getCalled(),is(1));
- }
-
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterStatusResource.java b/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterStatusResource.java
deleted file mode 100644
index 1025bae8f..000000000
--- a/micro-boot/src/test/java/app/boot/filter/com/oath/micro/server/FilterStatusResource.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package app.boot.filter.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-
-@Component
-@Path("/status")
-public class FilterStatusResource implements RestResource {
-
-
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "ok";
- }
- @GET
- @Produces("text/plain")
- @Path("/ping2")
- public String ping2() {
- return "ok";
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppResource.java b/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppResource.java
deleted file mode 100644
index cce09ece4..000000000
--- a/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppResource.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package app.guava.com.oath.micro.server;
-
-import java.util.List;
-import java.util.Optional;
-
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-@Component
-@Path("/status")
-public class GuavaAppResource implements RestResource {
-
- @POST
- @Produces("application/json")
- @Path("/ping")
- public List ping(ImmutableGuavaEntity entity) {
- return entity.getList();
- }
- @POST
- @Produces("application/json")
- @Path("/optional")
- public Optional optional(Jdk8Entity entity) {
- return entity.getName();
- }
-
-}
diff --git a/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppTest.java b/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppTest.java
deleted file mode 100644
index eea7d0ff0..000000000
--- a/micro-boot/src/test/java/app/guava/com/oath/micro/server/GuavaAppTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package app.guava.com.oath.micro.server;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-
-import com.oath.cyclops.types.futurestream.SimpleReactStream;
-import cyclops.futurestream.SimpleReact;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.rest.jackson.JacksonUtil;
-import com.oath.micro.server.testing.RestAgent;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-
-@Microserver @Microboot
-public class GuavaAppTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
-
- ImmutableGuavaEntity entity;
- Jdk8Entity present;
- Jdk8Entity absent;
-
- SimpleReact simpleReact = new SimpleReact();
- SimpleReactStream stream;
-
- @Before
- public void startServer() {
- stream = simpleReact.ofAsync(
- () -> server = new MicroserverApp(GuavaAppTest.class,
- () -> "guava-app")).then(server -> server.start());
-
- entity = ImmutableGuavaEntity.builder().value("value")
- .list(ImmutableList.of("hello", "world"))
- .mapOfSets(ImmutableMap.of("key1", ImmutableSet.of(1, 2, 3)))
- .multiMap(ImmutableMultimap.of("1", 2, "1", 2, "2", 4)).build();
-
- JacksonUtil.convertFromJson(JacksonUtil.serializeToJson(entity),
- ImmutableGuavaEntity.class);
-
- present = Jdk8Entity.builder().name(Optional.of("test")).build();
-
- JacksonUtil.convertFromJson(JacksonUtil.serializeToJson(present),
- Optional.class);
- absent = Jdk8Entity.builder().name(Optional.empty()).build();
- }
-
- @After
- public void stopServer() {
- server.stop();
- }
-
- @Test
- public void confirmExpectedUrlsPresentTest() throws InterruptedException,
- ExecutionException {
-
- stream.block();
-
- assertThat((List) rest.post(
- "http://localhost:8080/guava-app/status/ping", entity,
- List.class), hasItem("hello"));
-
- }
-
- @Test
- public void confirmOptionalConversionWorking() throws InterruptedException,
- ExecutionException {
-
- stream.block();
-
- assertThat(rest.post("http://localhost:8080/guava-app/status/optional",
- present, String.class), is("\"test\""));
-
- assertThat(rest.post("http://localhost:8080/guava-app/status/optional",
- absent, String.class), is("null"));
-
- }
-
-}
diff --git a/micro-boot/src/test/java/app/guava/com/oath/micro/server/ImmutableGuavaEntity.java b/micro-boot/src/test/java/app/guava/com/oath/micro/server/ImmutableGuavaEntity.java
deleted file mode 100644
index e4e706907..000000000
--- a/micro-boot/src/test/java/app/guava/com/oath/micro/server/ImmutableGuavaEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package app.guava.com.oath.micro.server;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Builder;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "")
-@XmlRootElement(name = "immutable")
-@Getter
-@AllArgsConstructor
-@Builder
-public class ImmutableGuavaEntity {
-
- private final String value;
- private final ImmutableList list;
- private final ImmutableMap mapOfSets;
- private final ImmutableMultimap multiMap;
-
- public ImmutableGuavaEntity() {
- this(null,null,null,null);
- }
-
-}
diff --git a/micro-boot/src/test/java/app/guava/com/oath/micro/server/Jdk8Entity.java b/micro-boot/src/test/java/app/guava/com/oath/micro/server/Jdk8Entity.java
deleted file mode 100644
index df2b8662e..000000000
--- a/micro-boot/src/test/java/app/guava/com/oath/micro/server/Jdk8Entity.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package app.guava.com.oath.micro.server;
-
-import java.util.Optional;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Builder;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "")
-@XmlRootElement(name = "optional")
-@Getter
-@AllArgsConstructor
-@Builder
-public class Jdk8Entity {
-
- private final Optional name;
-
- public Jdk8Entity(){
- name = Optional.empty();
- }
-}
diff --git a/micro-boot/src/test/java/app/listeners/com/oath/micro/server/AutodiscoveredListener.java b/micro-boot/src/test/java/app/listeners/com/oath/micro/server/AutodiscoveredListener.java
deleted file mode 100644
index a3dfdff21..000000000
--- a/micro-boot/src/test/java/app/listeners/com/oath/micro/server/AutodiscoveredListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package app.listeners.com.oath.micro.server;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import lombok.Getter;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class AutodiscoveredListener implements ServletContextListener {
-
- @Getter
- private static volatile int called= 0;
-
- @Override
- public void contextInitialized(ServletContextEvent sce) {
- called ++;
-
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent sce) {
-
-
- }
-
-
-
-
-
-
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/listeners/com/oath/micro/server/ListenerRunnerTest.java b/micro-boot/src/test/java/app/listeners/com/oath/micro/server/ListenerRunnerTest.java
deleted file mode 100644
index c72304ea1..000000000
--- a/micro-boot/src/test/java/app/listeners/com/oath/micro/server/ListenerRunnerTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package app.listeners.com.oath.micro.server;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import javax.servlet.ServletContextListener;
-
-import nonautoscan.com.oath.micro.server.ConfiguredListener;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.module.ConfigurableModule;
-import com.oath.micro.server.testing.RestAgent;
-import com.google.common.collect.ImmutableList;
-
-
-@Microserver @Microboot
-public class ListenerRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
- List listeners = ImmutableList.of(new ConfiguredListener());
- server = new MicroserverApp( ListenerRunnerTest.class, ConfigurableModule.builder().context("listener-app").listeners(listeners ).build());
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void testListeners() throws InterruptedException, ExecutionException{
-
- assertThat(AutodiscoveredListener.getCalled(),is(1));
- assertThat(ConfiguredListener.getCalled(),is(1));
- }
-
-
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsRunnerTest.java b/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsRunnerTest.java
deleted file mode 100644
index df9410e6b..000000000
--- a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsRunnerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package app.metrics.boot.com.oath.micro.server;
-
-
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.spring.metrics.CodahaleMetricsConfigurer;
-import com.oath.micro.server.testing.RestAgent;
-
-@Microboot
-public class MetricsRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
- CodahaleMetricsConfigurer.setInit( metricRegistry -> TestReporter
- .forRegistry(metricRegistry)
- .build()
- .start(10, TimeUnit.MILLISECONDS));
-
- server = new MicroserverApp( ()-> "simple-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException, IOException{
-
-
-
-
-
- assertThat(rest.get("http://localhost:8080/simple-app/metrics/ping"),is("ok"));
-
-
- assertThat(TestReporter.getTimer().size(),greaterThan(0));
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsStatusResource.java b/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsStatusResource.java
deleted file mode 100644
index c7389afdd..000000000
--- a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/MetricsStatusResource.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package app.metrics.boot.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-
-
-import com.oath.micro.server.auto.discovery.RestResource;
-
-@Component
-@Path("/metrics")
-public class MetricsStatusResource implements RestResource {
-
- @Autowired
- TimedResource timed;
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- timed.times();
- return "ok";
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TestReporter.java b/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TestReporter.java
deleted file mode 100644
index 8c69aa2e3..000000000
--- a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TestReporter.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package app.metrics.boot.com.oath.micro.server;
-
-import java.io.PrintStream;
-import java.util.Locale;
-import java.util.SortedMap;
-import java.util.TimeZone;
-import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
-
-import lombok.Getter;
-
-import com.codahale.metrics.Clock;
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.Timer;
-
-
-public class TestReporter extends ScheduledReporter {
-
- @Getter
- private static volatile SortedMap timer = new TreeMap<>();
-
- protected TestReporter(MetricRegistry registry, String name,
- MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) {
- super(registry, name, filter, rateUnit, durationUnit);
-
- }
-
-
- public static Builder forRegistry(MetricRegistry registry) {
- return new Builder(registry);
- }
-
- @Override
- public void report(SortedMap gauges,
- SortedMap counters,
- SortedMap histograms,
- SortedMap meters, SortedMap timers) {
- this.timer = timers;
-
-
- }
-
- public static class Builder {
- private final MetricRegistry registry;
- private PrintStream output;
- private Locale locale;
- private Clock clock;
- private TimeZone timeZone;
- private TimeUnit rateUnit;
- private TimeUnit durationUnit;
- private MetricFilter filter;
-
- private Builder(MetricRegistry registry) {
- this.registry = registry;
- this.output = System.out;
- this.locale = Locale.getDefault();
- this.clock = Clock.defaultClock();
- this.timeZone = TimeZone.getDefault();
- this.rateUnit = TimeUnit.SECONDS;
- this.durationUnit = TimeUnit.MILLISECONDS;
- this.filter = MetricFilter.ALL;
- }
-
- /**
- * Write to the given {@link PrintStream}.
- *
- * @param output a {@link PrintStream} instance.
- * @return {@code this}
- */
- public Builder outputTo(PrintStream output) {
- this.output = output;
- return this;
- }
-
- /**
- * Format numbers for the given {@link Locale}.
- *
- * @param locale a {@link Locale}
- * @return {@code this}
- */
- public Builder formattedFor(Locale locale) {
- this.locale = locale;
- return this;
- }
-
- /**
- * Use the given {@link Clock} instance for the time.
- *
- * @param clock a {@link Clock} instance
- * @return {@code this}
- */
- public Builder withClock(Clock clock) {
- this.clock = clock;
- return this;
- }
-
- /**
- * Use the given {@link TimeZone} for the time.
- *
- * @param timeZone a {@link TimeZone}
- * @return {@code this}
- */
- public Builder formattedFor(TimeZone timeZone) {
- this.timeZone = timeZone;
- return this;
- }
-
- /**
- * Convert rates to the given time unit.
- *
- * @param rateUnit a unit of time
- * @return {@code this}
- */
- public Builder convertRatesTo(TimeUnit rateUnit) {
- this.rateUnit = rateUnit;
- return this;
- }
-
- /**
- * Convert durations to the given time unit.
- *
- * @param durationUnit a unit of time
- * @return {@code this}
- */
- public Builder convertDurationsTo(TimeUnit durationUnit) {
- this.durationUnit = durationUnit;
- return this;
- }
-
- /**
- * Only report metrics which match the given filter.
- *
- * @param filter a {@link MetricFilter}
- * @return {@code this}
- */
- public Builder filter(MetricFilter filter) {
- this.filter = filter;
- return this;
- }
-
- /**
- * Builds a {@link ConsoleReporter} with the given properties.
- *
- * @return a {@link ConsoleReporter}
- */
- public TestReporter build() {
- return new TestReporter(registry,
- // output,
- "name",
- // locale,
- // clock,
- // timeZone,
- this.filter,
- rateUnit,
- durationUnit
- );
- }
- }
-
-
-}
-
diff --git a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TimedResource.java b/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TimedResource.java
deleted file mode 100644
index efafe3099..000000000
--- a/micro-boot/src/test/java/app/metrics/boot/com/oath/micro/server/TimedResource.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package app.metrics.boot.com.oath.micro.server;
-
-import org.springframework.stereotype.Component;
-
-import com.codahale.metrics.annotation.Timed;
-
-@Component
-public class TimedResource {
-
-
- @Timed
- public String times(){
-
- return "ok!";
- }
-}
diff --git a/micro-boot/src/test/java/app/minimal/com/oath/micro/server/MinimalClassTest.java b/micro-boot/src/test/java/app/minimal/com/oath/micro/server/MinimalClassTest.java
deleted file mode 100644
index 68475d3fb..000000000
--- a/micro-boot/src/test/java/app/minimal/com/oath/micro/server/MinimalClassTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package app.minimal.com.oath.micro.server;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.auto.discovery.Rest;
-import com.oath.micro.server.testing.RestAgent;
-
-@Rest
-@Path("/single")
-public class MinimalClassTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp(()-> "minimal-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
-
-
- assertThat(rest.get("http://localhost:8080/minimal-app/single/ping"),is("ok1"));
-
- }
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "ok1";
- }
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/GenericRestClientResource.java b/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/GenericRestClientResource.java
deleted file mode 100644
index 3b6b9ee90..000000000
--- a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/GenericRestClientResource.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package app.rest.client.com.oath.micro.server;
-
-import java.util.List;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-@Component
-@Path("/rest")
-public class GenericRestClientResource implements RestResource {
-
-
- @GET
- @Produces("application/json")
- @Path("/get")
- public List get() {
-
- return ImmutableList.of("ok");
- }
-
- @POST
- @Produces("application/json")
- @Path("/post")
- public ImmutableSet post(ImmutableMap map) {
-
- return ImmutableSet.copyOf(map.values());
- }
-
- @PUT
- @Produces("application/json")
- @Path("/put")
- public ImmutableSet put(ImmutableMap map) {
-
- return ImmutableSet.copyOf(map.values());
- }
- @DELETE
- @Produces("application/json")
- @Path("/delete")
- public List delete(ImmutableMap map) {
-
- return ImmutableList.of("ok");
- }
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/MyEntity.java b/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/MyEntity.java
deleted file mode 100644
index c075fa67f..000000000
--- a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/MyEntity.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package app.rest.client.com.oath.micro.server;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-
-@EqualsAndHashCode
-@Getter
-public class MyEntity {
-
- private final String name ="myEntity";
-
-}
diff --git a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientResource.java b/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientResource.java
deleted file mode 100644
index 90c119ba5..000000000
--- a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientResource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package app.rest.client.com.oath.micro.server;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-@Component
-@Path("/generics")
-public class RestClientResource implements RestResource {
-
- private final ImmutableList result = ImmutableList.of(new MyEntity());
- @GET
- @Produces("application/json")
- @Path("/get")
- public ImmutableList get() {
-
- return result;
- }
-
- @POST
- @Produces("application/json")
- @Path("/post")
- public ImmutableList post(ImmutableMap map) {
-
- return result;
- }
-
- @PUT
- @Produces("application/json")
- @Path("/put")
- public ImmutableList put(ImmutableMap map) {
-
- return result;
- }
- @DELETE
- @Produces("application/json")
- @Path("/delete")
- public ImmutableList delete(ImmutableMap map) {
-
- return result;
- }
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientTest.java b/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientTest.java
deleted file mode 100644
index f456a0271..000000000
--- a/micro-boot/src/test/java/app/rest/client/com/oath/micro/server/RestClientTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-
-package app.rest.client.com.oath.micro.server;
-
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.web.client.RestClientException;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.rest.client.nio.AsyncRestClient;
-import com.oath.micro.server.rest.client.nio.NIORestClient;
-import com.oath.micro.server.rest.client.nio.SpringConfig;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-@Microserver @Microboot
-public class RestClientTest {
-
- private final AsyncRestClient> listClient = new AsyncRestClient(1000,1000).withResponse(List.class);
- private final AsyncRestClient> setClient = new AsyncRestClient(1000,1000).withResponse(ImmutableSet.class);;
- private final AsyncRestClient> genericsClient = new AsyncRestClient(1000,1000).withGenericResponse(ImmutableList.class, MyEntity.class);
-
- private final NIORestClient rest = new SpringConfig().restClient();
-
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp( RestClientTest.class, ()-> "rest-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
- /*
- * Simpler with JaxRsNIOClient
- */
- @Test
- public void testCRUD() throws InterruptedException, ExecutionException{
-
-
- assertThat(listClient.get("http://localhost:8080/rest-app/rest/get").get().get(0),is("ok"));
- assertThat(setClient.post("http://localhost:8080/rest-app/rest/post",ImmutableMap.of(1,"hello")).get(),is(ImmutableSet.of("hello")));
- assertThat(setClient.put("http://localhost:8080/rest-app/rest/put",ImmutableMap.of(1,"hello")).get(),is(ImmutableSet.of("hello")));
- assertThat(listClient.delete("http://localhost:8080/rest-app/rest/delete").get().get(0),is("ok"));
- }
-
- @Test
- public void testCRUDGenerics() throws InterruptedException, ExecutionException{
-
-
- assertThat(genericsClient.get("http://localhost:8080/rest-app/generics/get").get().get(0),is(new MyEntity()));
- assertThat(genericsClient.post("http://localhost:8080/rest-app/generics/post",ImmutableMap.of(1,"hello")).get(),is(ImmutableList.of(new MyEntity())));
- assertThat(genericsClient.put("http://localhost:8080/rest-app/generics/put",ImmutableMap.of(1,"hello")).get(),is(ImmutableList.of(new MyEntity())));
- assertThat(genericsClient.delete("http://localhost:8080/rest-app/generics/delete").get().get(0),is(new MyEntity()));
- }
-
- /**
- * More complex with Spring REST Template Based NIORestTemplate
- *
- */
-
- @Test
- public void testCRUDSpring() throws InterruptedException, ExecutionException, RestClientException, URISyntaxException{
-
-
- assertThat(rest.getForEntity(new URI("http://localhost:8080/rest-app/rest/get"),List.class).get().getBody().get(0),is("ok"));
-
- assertThat(rest.postForEntity("http://localhost:8080/rest-app/rest/post", new HttpEntity(ImmutableMap.of(1,"hello")), ImmutableSet.class).get().getBody(),is(ImmutableSet.of("hello")));
- assertThat( rest.put("http://localhost:8080/rest-app/rest/put",new HttpEntity(ImmutableMap.of(1,"hello")),ImmutableSet.class).get()
- ,is(nullValue()));
- assertThat(rest.delete("http://localhost:8080/rest-app/rest/delete").get(),is(nullValue()));
- }
-
- @Test
- public void testCRUDGenericsSpring() throws InterruptedException, ExecutionException{
-
-
- assertThat(rest.exchange("http://localhost:8080/rest-app/generics/get",HttpMethod.GET,null,new ParameterizedTypeReference>(){})
- .get().getBody().get(0),is(new MyEntity()));
-
- assertThat(rest.exchange("http://localhost:8080/rest-app/generics/post",HttpMethod.POST,new HttpEntity(ImmutableMap.of(1,"hello")),new ParameterizedTypeReference>(){})
- .get().getBody(),is(ImmutableList.of(new MyEntity())));
-
- assertThat(rest.exchange("http://localhost:8080/rest-app/generics/put",HttpMethod.PUT,new HttpEntity(ImmutableMap.of(1,"hello")),new ParameterizedTypeReference>(){})
- .get().getBody(),is(ImmutableList.of(new MyEntity())));
-
- assertThat(rest.exchange("http://localhost:8080/rest-app/generics/delete",HttpMethod.DELETE,null,new ParameterizedTypeReference>(){})
- .get().getBody().get(0),is(new MyEntity()));
-
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AppRunnerLocalMain.java b/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AppRunnerLocalMain.java
deleted file mode 100644
index 217fc92d4..000000000
--- a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AppRunnerLocalMain.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package app.servlet.com.oath.micro.server;
-
-
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-
-import com.oath.micro.server.MicroserverApp;
-
-@Configuration
-@ComponentScan(basePackages = { "app.servlet.com.oath.micro.server" })
-public class AppRunnerLocalMain {
-
-
- public static void main(String[] args) throws InterruptedException {
-
- new MicroserverApp( AppRunnerLocalMain.class, () -> "test-app")
- .run();
- }
-
-}
diff --git a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AutodiscoveredServlet.java b/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AutodiscoveredServlet.java
deleted file mode 100644
index 66cbfd59c..000000000
--- a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/AutodiscoveredServlet.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package app.servlet.com.oath.micro.server;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.AutoServletConfiguration;
-
-@Component
-public class AutodiscoveredServlet extends HttpServlet implements AutoServletConfiguration {
-
- @Override
- public String[] getMapping() {
- return new String[] { "/servlet" };
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
-
- resp.setContentType("text/html");
- resp.getWriter().write("hello world");
- }
-
-}
diff --git a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ConfiguredServlet.java b/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ConfiguredServlet.java
deleted file mode 100644
index 65de82291..000000000
--- a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ConfiguredServlet.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package app.servlet.com.oath.micro.server;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public class ConfiguredServlet extends HttpServlet {
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- resp.setContentType("text/html");
- resp.getWriter().write("configured servlet");
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletRunnerTest.java b/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletRunnerTest.java
deleted file mode 100644
index 39f3896e3..000000000
--- a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletRunnerTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package app.servlet.com.oath.micro.server;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import javax.servlet.Servlet;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.module.ConfigurableModule;
-import com.oath.micro.server.testing.RestAgent;
-
-public class ServletRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
- Map servlets = new HashMap<>();
- servlets.put("/configured", new ConfiguredServlet());
- server = new MicroserverApp( AppRunnerLocalMain.class, ConfigurableModule.builder().context("test-app").servlets(servlets ).build());
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
- assertThat(rest.get("http://localhost:8080/test-app/servlet/ping"),is("ok"));
-
- }
-
- @Test
- public void autoDiscoveredServletTest() throws InterruptedException, ExecutionException{
-
-
- assertThat(rest.get("http://localhost:8080/servlet"),is("hello world"));
-
- }
-
- @Test
- public void configuredServletTest() throws InterruptedException, ExecutionException{
-
-
- assertThat(rest.get("http://localhost:8080/configured"),is("configured servlet"));
-
- }
-
-
-}
diff --git a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletStatusResource.java b/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletStatusResource.java
deleted file mode 100644
index 6d86eeb84..000000000
--- a/micro-boot/src/test/java/app/servlet/com/oath/micro/server/ServletStatusResource.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package app.servlet.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-
-@Component
-@Path("/servlet")
-public class ServletStatusResource implements RestResource {
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "ok";
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleRunnerTest.java b/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleRunnerTest.java
deleted file mode 100644
index cf8c92d17..000000000
--- a/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleRunnerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package app.simple.com.oath.micro.server;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.testing.RestAgent;
-
-@Microserver @Microboot
-public class SimpleRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp( SimpleRunnerTest.class, ()-> "simple-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
-
-
- assertThat(rest.get("http://localhost:8080/simple-app/status/ping"),is("ok"));
-
-
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleStatusResource.java b/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleStatusResource.java
deleted file mode 100644
index 97265ed02..000000000
--- a/micro-boot/src/test/java/app/simple/com/oath/micro/server/SimpleStatusResource.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package app.simple.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-
-@Component
-@Qualifier("simpleStatusResource")
-@Path("/status")
-public class SimpleStatusResource implements RestResource {
-
-
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
-
- return "ok";
- }
-
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/single/main/com/oath/micro/server/SingleClassApp.java b/micro-boot/src/test/java/app/single/main/com/oath/micro/server/SingleClassApp.java
deleted file mode 100644
index 04d145ba8..000000000
--- a/micro-boot/src/test/java/app/single/main/com/oath/micro/server/SingleClassApp.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package app.single.main.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.junit.Ignore;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.MicroserverApp;
-
-@Configuration
-@ComponentScan(basePackages = { "app.simple.com.aol.micro.server" })
-@Component
-@Path("/status") @Ignore
-public class SingleClassApp {
-
- public static void main(String[] args){
- new MicroserverApp( SingleClassApp.class, ()-> "simple-app");
- }
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return "ok";
- }
-
-}
diff --git a/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyBean.java b/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyBean.java
deleted file mode 100644
index 328b7d185..000000000
--- a/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyBean.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package app.spring.com.oath.micro.server;
-
-import javax.inject.Inject;
-
-import lombok.Getter;
-
-@Getter
-public class MyBean {
-
- @Inject
- private MyDependency injected;
-}
diff --git a/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyDependency.java b/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyDependency.java
deleted file mode 100644
index 1ca23b15b..000000000
--- a/micro-boot/src/test/java/app/spring/com/oath/micro/server/MyDependency.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package app.spring.com.oath.micro.server;
-
-import lombok.Getter;
-
-import org.springframework.stereotype.Component;
-
-@Component
-@Getter
-public class MyDependency {
-
- private String data = "hello world";
-}
diff --git a/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringRunnerTest.java b/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringRunnerTest.java
deleted file mode 100644
index 0a799afda..000000000
--- a/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringRunnerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package app.spring.com.oath.micro.server;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.annotation.Bean;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.boot.config.Microboot;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.testing.RestAgent;
-/**@Configuration
-@ComponentScan(basePackages = { "app.spring.com.aol.micro.server" })**/
-@Microserver @Microboot
-public class SpringRunnerTest {
-
- RestAgent rest = new RestAgent();
-
- @Bean
- public MyBean mybean(){
- return new MyBean();
- }
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp( SpringRunnerTest.class, ()-> "spring-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void testAutoWiring() throws InterruptedException, ExecutionException{
-
- assertThat(rest.get("http://localhost:8080/spring-app/spring/ping"),is("hello world"));
-
- }
-
-
-
-
-
-}
diff --git a/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringStatusResource.java b/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringStatusResource.java
deleted file mode 100644
index ae0c817de..000000000
--- a/micro-boot/src/test/java/app/spring/com/oath/micro/server/SpringStatusResource.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package app.spring.com.oath.micro.server;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-
-@Component
-@Path("/spring")
-public class SpringStatusResource implements RestResource {
-
- @Autowired
- private MyBean mybean;
-
- @GET
- @Produces("text/plain")
- @Path("/ping")
- public String ping() {
- return mybean.getInjected().getData();
- }
- @GET
- @Produces("text/plain")
- @Path("/ping2")
- public String ping2() {
- return "ok";
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/app/spring/mvc/Application.java b/micro-boot/src/test/java/app/spring/mvc/Application.java
new file mode 100644
index 000000000..46d261f76
--- /dev/null
+++ b/micro-boot/src/test/java/app/spring/mvc/Application.java
@@ -0,0 +1,32 @@
+package app.spring.mvc;
+import java.util.concurrent.ExecutionException;
+
+import com.oath.micro.server.MicroserverApp;
+import com.oath.micro.server.config.Microserver;
+import com.oath.micro.server.rest.client.nio.AsyncRestClient;
+import com.oath.micro.server.boot.MicroBoot;
+import org.junit.Test;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@Microserver
+@MicroBoot
+public class Application {
+
+
+ AsyncRestClient rest = new AsyncRestClient(1000,1000).withAccept("text/plain");
+
+ @Test
+ public void runAppAndBasicTest() throws InterruptedException, ExecutionException {
+
+ MicroserverApp app = new MicroserverApp( ()-> "spring-mvc");
+ Thread.sleep(2000);
+
+ assertThat(rest.get("http://localhost:8080/spring-mvc").get(),is("Greetings from Spring Boot with Microserver!"));
+ ((ConfigurableApplicationContext)app.getSpringContext()).close();
+ }
+
+
+}
diff --git a/micro-boot/src/test/java/app/spring/mvc/HelloController.java b/micro-boot/src/test/java/app/spring/mvc/HelloController.java
new file mode 100644
index 000000000..34136b6e9
--- /dev/null
+++ b/micro-boot/src/test/java/app/spring/mvc/HelloController.java
@@ -0,0 +1,15 @@
+package app.spring.mvc;
+
+
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestController
+public class HelloController {
+
+ @RequestMapping("/")
+ public String index() {
+ return "Greetings from Spring Boot with Microserver!";
+ }
+
+}
diff --git a/micro-boot/src/test/java/app/spring/plugin/RegistryController.java b/micro-boot/src/test/java/app/spring/plugin/RegistryController.java
new file mode 100644
index 000000000..cafd4e139
--- /dev/null
+++ b/micro-boot/src/test/java/app/spring/plugin/RegistryController.java
@@ -0,0 +1,30 @@
+package app.spring.plugin;
+
+
+import com.oath.micro.server.application.registry.Job;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class RegistryController {
+
+ private final Job job;
+
+ @Autowired
+ public RegistryController(Job job){
+ this.job = job;
+ }
+
+ @RequestMapping("/")
+ public String index() {
+ return "Greetings from Spring Boot with Microserver!";
+ }
+
+ @RequestMapping("/scheduled")
+ public String scheduled() {
+ return ""+job.getScheduled();
+ }
+
+}
diff --git a/micro-boot/src/test/java/app/spring/plugin/RegistryTest.java b/micro-boot/src/test/java/app/spring/plugin/RegistryTest.java
new file mode 100644
index 000000000..370635b89
--- /dev/null
+++ b/micro-boot/src/test/java/app/spring/plugin/RegistryTest.java
@@ -0,0 +1,37 @@
+package app.spring.plugin;
+
+import com.oath.micro.server.MicroserverApp;
+import com.oath.micro.server.boot.MicroBoot;
+import com.oath.micro.server.config.Microserver;
+import com.oath.micro.server.rest.client.nio.AsyncRestClient;
+import org.junit.Test;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import java.util.concurrent.ExecutionException;
+
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+@Microserver
+@MicroBoot
+public class RegistryTest {
+
+
+ AsyncRestClient rest = new AsyncRestClient(1000,1000).withAccept("text/plain");
+
+ @Test
+ public void runAppAndBasicTest() throws InterruptedException, ExecutionException {
+
+ MicroserverApp app = new MicroserverApp( ()-> "spring-mvc");
+ Thread.sleep(3000);
+
+ assertThat(rest.get("http://localhost:8080/spring-mvc/scheduled").get(),is(not("0")));
+
+ ((ConfigurableApplicationContext)app.getSpringContext()).close();
+
+ }
+
+
+}
diff --git a/micro-boot/src/test/java/app/swagger/com/oath/micro/server/StatsResource.java b/micro-boot/src/test/java/app/swagger/com/oath/micro/server/StatsResource.java
deleted file mode 100644
index 848d10205..000000000
--- a/micro-boot/src/test/java/app/swagger/com/oath/micro/server/StatsResource.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package app.swagger.com.oath.micro.server;
-
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.springframework.stereotype.Component;
-
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.google.common.collect.ImmutableList;
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-
-@Path("/stats")
-@Component
-@Api(value = "/stats", description = "Resource to show stats for a box using sigar")
-public class StatsResource implements RestResource {
-
-
-
- @GET
- @Path("/ping")
- @Produces("application/json")
- @ApiOperation(value = "Make a ping call", response = List.class)
- public List getMachineStats() {
- return ImmutableList.of(1);
- }
-}
diff --git a/micro-boot/src/test/java/app/swagger/com/oath/micro/server/SwaggerRunnerTest.java b/micro-boot/src/test/java/app/swagger/com/oath/micro/server/SwaggerRunnerTest.java
deleted file mode 100644
index 5f9c6351c..000000000
--- a/micro-boot/src/test/java/app/swagger/com/oath/micro/server/SwaggerRunnerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package app.swagger.com.oath.micro.server;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.testing.RestAgent;
-
-@Configuration
-@ComponentScan(basePackages = { "app.swagger.com.oath.micro.server" })
-public class SwaggerRunnerTest {
-
-
- RestAgent rest = new RestAgent();
-
- MicroserverApp server;
- @Before
- public void startServer(){
-
- server = new MicroserverApp( SwaggerRunnerTest.class, ()-> "swagger-app");
- server.start();
-
- }
-
- @After
- public void stopServer(){
- server.stop();
- }
-
- @Test
- public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
-
-
- assertThat(rest.getJson("http://localhost:8080/api-docs/stats"),containsString("Make a ping call"));
-
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ConfiguredListener.java b/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ConfiguredListener.java
deleted file mode 100644
index cc1161808..000000000
--- a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ConfiguredListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package nonautoscan.com.oath.micro.server;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import lombok.Getter;
-
-public class ConfiguredListener implements ServletContextListener {
-
- @Getter
- private static volatile int called= 0;
-
- @Override
- public void contextInitialized(ServletContextEvent sce) {
- called ++;
-
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent sce) {
-
-
- }
-
-}
\ No newline at end of file
diff --git a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/PropertyFileConfigTest.java b/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/PropertyFileConfigTest.java
deleted file mode 100644
index 7f341009e..000000000
--- a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/PropertyFileConfigTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package nonautoscan.com.oath.micro.server;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.oath.micro.server.config.Config;
-import com.oath.micro.server.spring.properties.PropertyFileConfig;
-public class PropertyFileConfigTest {
-
-
-
-
-
- PropertyFileConfig config;
- @Before
- public void setUp() {
- config = new PropertyFileConfig();
- }
-
- @Test
- public void testPropertyPlaceholderConfigurer() throws IOException {
- Config.instance();
- assertThat( config.propertyPlaceholderConfigurer(),notNullValue());
- }
-
-
-
-}
diff --git a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ScheduleAndAsyncConfigTest.groovy b/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ScheduleAndAsyncConfigTest.groovy
deleted file mode 100644
index 6d9a98704..000000000
--- a/micro-boot/src/test/java/nonautoscan/com/oath/micro/server/ScheduleAndAsyncConfigTest.groovy
+++ /dev/null
@@ -1,56 +0,0 @@
-package nonautoscan.com.oath.micro.server
-
-import groovy.transform.CompileStatic
-
-import org.junit.Before
-import org.junit.Test
-import org.mockito.Mockito
-import org.springframework.scheduling.config.ScheduledTaskRegistrar
-@CompileStatic
-class ScheduleAndAsyncConfigTest {
-
-
- ScheduleAndAsyncConfig config
- @Before
- public void setup(){
- config = new ScheduleAndAsyncConfig()
- config.schedulerThreadPoolSize=3
- config.executorThreadPoolSize=3
- }
- @Test
- public void testSetExecutorThreadPoolSize() {
- assert config.@executorThreadPoolSize==3
- }
-
-
- @Test
- public void testSetSchedulerThreadPoolSize() {
-
- assert config.@schedulerThreadPoolSize==3
- }
-
- @Test
- public void testGetAsyncExecutor() {
- assert config.asyncExecutor !=null
- }
-
- @Test
- public void testConfigureTasks() {
- ScheduledTaskRegistrar mock = Mockito.mock(ScheduledTaskRegistrar)
- config.configureTasks(mock)
- Mockito.verify(mock).setScheduler(Mockito.anyObject())
- }
-
- @Test
- public void testTaskScheduler() {
- assert config.taskScheduler()!=null
- }
-
- @Test
- public void testTaskExecutor() {
- assert config.taskExecutor() != null
- }
-
-
-
-}
diff --git a/micro-boot/src/test/resources/META-INF/MANIFEST.MF b/micro-boot/src/test/resources/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..b614b3f50
--- /dev/null
+++ b/micro-boot/src/test/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+Created-By: 1.7.0_06 (Oracle Corporation)
\ No newline at end of file
diff --git a/micro-client/README.md b/micro-client/README.md
index c38a9b6cf..b222fdf65 100644
--- a/micro-client/README.md
+++ b/micro-client/README.md
@@ -48,7 +48,6 @@ public class EndPoint {
private final EventBus bus;
private final NIORestClient restClient;
private final String URL;
- private final AtomicLong correlationId = new AtomicLong(0);
@Autowired
public EndPoint(NIORestClient restClient,EventBus bus, @Value("${url:}") String URL){
@@ -67,7 +66,7 @@ public class EndPoint {
public void async(RequestType query,@Suspended AsyncResponse asyncResponse){
- final long correlationId = this.correlationId.incrementAndGet();
+ final String correlationId = UUID.randomUUID().toString();
bus.post(RequestEvents.start(query, correlationId,"standard-query",HashMapBuilder.of("ip",QueryIPRetriever.getIpAddress())));
builder.from(this.restClient.postForEntity(URL, new HttpEntity(JacksonUtil.serializeToJson(convertList(query)),headers),String.class))
.sync()
diff --git a/micro-client/src/test/java/app/events/com/oath/micro/server/EventRunnerTest.java b/micro-client/src/test/java/app/events/com/oath/micro/server/EventRunnerTest.java
index 562e234ac..306b04ec7 100644
--- a/micro-client/src/test/java/app/events/com/oath/micro/server/EventRunnerTest.java
+++ b/micro-client/src/test/java/app/events/com/oath/micro/server/EventRunnerTest.java
@@ -1,27 +1,25 @@
package app.events.com.oath.micro.server;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.locks.LockSupport;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
import com.oath.micro.server.MicroserverApp;
import com.oath.micro.server.config.Microserver;
import com.oath.micro.server.rest.client.nio.AsyncRestClient;
import com.oath.micro.server.testing.RestAgent;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.concurrent.ExecutionException;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
@Microserver
public class EventRunnerTest {
RestAgent rest = new RestAgent();
- private final AsyncRestClient client = new AsyncRestClient(200,200).withAccept("application/json");
+ private final AsyncRestClient client = new AsyncRestClient(30000,30000).withAccept("application/json");
MicroserverApp server;
diff --git a/micro-client/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java b/micro-client/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
index eade4dc04..75ed47c04 100644
--- a/micro-client/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
+++ b/micro-client/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
@@ -29,12 +29,12 @@ public EventStatusResource(EventBus bus ){
@Produces("text/plain")
@Path("/ping")
public String ping() {
- bus.post(RequestEvents.start("get", 1l));
+ bus.post(RequestEvents.start("get", "1"));
try{
return "ok";
}finally{
- bus.post(RequestEvents.finish("get",1l));
+ bus.post(RequestEvents.finish("get","1"));
}
}
-}
\ No newline at end of file
+}
diff --git a/micro-core/src/main/java/com/oath/micro/server/servers/model/ServerData.java b/micro-core/src/main/java/com/oath/micro/server/servers/model/ServerData.java
index 444bd305d..f858e92ba 100644
--- a/micro-core/src/main/java/com/oath/micro/server/servers/model/ServerData.java
+++ b/micro-core/src/main/java/com/oath/micro/server/servers/model/ServerData.java
@@ -71,5 +71,13 @@ private void logMissingPath(Object resource) {
}
}
+ public String getNormalizedContextPath(){
+ if("".equals(module.getContext()))
+ return "";
+ else
+ return "/"+module.getContext();
+
+ }
+
}
diff --git a/micro-couchbase/build.gradle b/micro-couchbase/build.gradle
index 6f071f952..3b7e1b0da 100644
--- a/micro-couchbase/build.gradle
+++ b/micro-couchbase/build.gradle
@@ -18,7 +18,6 @@ dependencies {
}
testCompile group: 'com.cyrusinnovation', name: 'mockito-groovy-support', version: '1.3'
testCompile 'cglib:cglib-nodep:2.2'
- testCompile 'com.github.johnmcclean-aol:couchbasemock:master'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: hamcrestVersion
testCompile project(':micro-grizzly-with-jersey')
}
diff --git a/micro-curator/build.gradle b/micro-curator/build.gradle
index 9dc97a953..803f4b622 100644
--- a/micro-curator/build.gradle
+++ b/micro-curator/build.gradle
@@ -12,7 +12,7 @@ sourceSets {
}
task integTest(type: Test) {
- testClassesDir = sourceSets.integTest.output.classesDir
+ testClassesDirs = sourceSets.integTest.output.classesDirs
classpath = sourceSets.integTest.runtimeClasspath
}
diff --git a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/ConfigureElasticache.java b/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/ConfigureElasticache.java
deleted file mode 100644
index 3ae3dd345..000000000
--- a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/ConfigureElasticache.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.oath.micro.server.elasticache;
-
-
-
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-
-import net.spy.memcached.MemcachedClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.net.InetSocketAddress;
-
-@Slf4j
-@Configuration
-public class ConfigureElasticache {
-
-
- private final String hostname;
- private final int port;
- private final int retryAfterSecs;
- private final int maxRetries;
-
- @Autowired
- public ConfigureElasticache( @Value("${elasticache.hostname:null}") String hostname,
- @Value("${elasticache.port:6379}") int port,
- @Value("${elasticache.retry.after.seconds:1}") int retryAfterSecs,
- @Value("${elasticache.max.retries:3}") int maxRetries) {
- this.hostname = hostname;
- this.port = port;
- this.retryAfterSecs = retryAfterSecs;
- this.maxRetries = maxRetries;
- }
-
-
- @Bean(name = "transientCache")
- public DistributedCacheManager transientCache() throws IOException, URISyntaxException {
- try {
- log.info("Creating Memcached Data connection for elasticache cluster: {}", hostname);
- return new TransientElasticacheDataConnection(createMemcachedClient(), retryAfterSecs, maxRetries);
- }
- catch (Exception e) {
- log.error("Failed to create transient data connection", e);
- return null;
- }
- }
-
- @Bean(name = "memcachedClient")
- public MemcachedClient createMemcachedClient() throws IOException {
- try {
- log.info("Starting an instance of memcache client towards elasticache cluster");
- return new MemcachedClient(new InetSocketAddress(hostname, port));
- } catch (IOException e) {
- log.error("Could not initilise connection to elasticache cluster", e);
- return null;
- }
-
- }
-}
-
diff --git a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/DistributedCacheManager.java b/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/DistributedCacheManager.java
deleted file mode 100644
index 28c1eac8f..000000000
--- a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/DistributedCacheManager.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.oath.micro.server.elasticache;
-import java.util.Optional;
-
-public interface DistributedCacheManager {
- void setConnectionTested(boolean result);
- boolean isAvailable();
- boolean add(String key, int exp, V value);
- Optional get(String key);
-}
diff --git a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/TransientElasticacheDataConnection.java b/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/TransientElasticacheDataConnection.java
deleted file mode 100644
index 372770a1d..000000000
--- a/micro-elasticache/src/main/java/com/oath/micro/server/elasticache/TransientElasticacheDataConnection.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.oath.micro.server.elasticache;
-
-import lombok.extern.slf4j.Slf4j;
-
-import java.util.Optional;
-import net.spy.memcached.MemcachedClient;
-
-
-@Slf4j
-public class TransientElasticacheDataConnection implements DistributedCacheManager {
-
- private volatile boolean available = false;
- private final MemcachedClient memcachedClient;
- private final int retryAfterSec;
- private final int maxTry;
-
- public TransientElasticacheDataConnection(MemcachedClient memcachedClient,int retryAfterSec, int maxTry) {
- this.memcachedClient = memcachedClient;
- this.retryAfterSec = retryAfterSec;
- this.maxTry = maxTry;
- }
-
- @Override
- public boolean add(final String key, int exp, final Object value) {
-
- log.trace("Memcached add operation on key '{}', with value:{}", key, value);
- boolean success = false;
- int tryCount = 0;
-
- do {
- try {
- if (tryCount > 0) {
- Thread.sleep(retryAfterSec * 1000);
- log.warn("retrying operation #{}", tryCount);
- }
- tryCount++;
- success = memcachedClient.add(key, exp, value)
- .get();
- } catch (final Exception e) {
- log.warn("memcache set: {}", e.getMessage());
- }
- } while (!success && tryCount < maxTry);
-
- if (!success) {
- log.error("Failed to add key to Elasticache {}", key);
- }
- if (success && tryCount > 1) {
- log.info("Connection restored OK to Elasticache cluster");
- }
-
- available = success;
- return success;
- }
-
- @Override
- public Optional get(String key) {
- return (Optional) Optional.ofNullable(memcachedClient.get(key));
- }
-
- @Override
- public boolean isAvailable() {
- return available;
- }
-
- @Override
- public final void setConnectionTested(final boolean available) {
- this.available = available;
- }
-}
\ No newline at end of file
diff --git a/micro-elasticache/src/main/resources/META-INF/services/com.oath.micro.server.Plugin b/micro-elasticache/src/main/resources/META-INF/services/com.oath.micro.server.Plugin
deleted file mode 100644
index 79998ec6f..000000000
--- a/micro-elasticache/src/main/resources/META-INF/services/com.oath.micro.server.Plugin
+++ /dev/null
@@ -1 +0,0 @@
-com.oath.micro.server.elasticache.ElasticachePlugin
\ No newline at end of file
diff --git a/micro-elasticache/src/test/java/com/oath/micros/server/elasticache/TransientElasticacheDataConnectionTest.java b/micro-elasticache/src/test/java/com/oath/micros/server/elasticache/TransientElasticacheDataConnectionTest.java
deleted file mode 100644
index fa07d2262..000000000
--- a/micro-elasticache/src/test/java/com/oath/micros/server/elasticache/TransientElasticacheDataConnectionTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.oath.micros.server.elasticache;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.stub;
-import static org.junit.Assert.assertEquals;
-import com.oath.micro.server.elasticache.TransientElasticacheDataConnection;
-import net.spy.memcached.internal.OperationFuture;
-import org.junit.Before;
-import org.junit.Test;
-import net.spy.memcached.MemcachedClient;
-import java.util.Optional;
-
-public class TransientElasticacheDataConnectionTest {
-
- MemcachedClient memcachedClient;
-
- @Before
- public void setup() {
- memcachedClient = mock(MemcachedClient.class);
-
- stub(memcachedClient.get("key1")).toReturn("value1");
- stub(memcachedClient.get("key2")).toReturn("value2");
- OperationFuture mockedFuture = mock(OperationFuture.class);
- stub(memcachedClient.add("keyAdd", 3600, "valueadd")).toReturn(mockedFuture);
- }
-
- @Test
- public void happyPathGetTest() {
- TransientElasticacheDataConnection transientClient = new TransientElasticacheDataConnection(memcachedClient, 3, 1);
- assertEquals(Optional.ofNullable("value1"), transientClient.get("key1"));
- assertEquals(Optional.ofNullable("value2"), transientClient.get("key2"));
- }
-
- @Test
- public void notExistingKeyGetTest() {
- TransientElasticacheDataConnection transientClient = new TransientElasticacheDataConnection(memcachedClient, 3, 1);
- assertEquals(Optional.empty(), transientClient.get("key3"));
- }
-
- @Test
- public void notExistingKeyPutTest() {
- TransientElasticacheDataConnection transientClient = new TransientElasticacheDataConnection(memcachedClient, 3, 1);
- assertEquals(false, transientClient.add("keyAdd", 3600, "valueadd"));
- }
-
- @Test
- public void testIsAvailableFalse() {
- TransientElasticacheDataConnection transientClient = new TransientElasticacheDataConnection(memcachedClient, 3, 1);
- transientClient.setConnectionTested(false);
- assertEquals(false, transientClient.isAvailable());
- }
-
- @Test
- public void testIsAvailableTrue() {
- TransientElasticacheDataConnection transientClient = new TransientElasticacheDataConnection(memcachedClient, 3, 1);
- transientClient.setConnectionTested(true);
- assertEquals(true, transientClient.isAvailable());
- }
-
-
-
-}
\ No newline at end of file
diff --git a/micro-event-metrics/src/main/java/com/oath/micro/server/event/metrics/TimerManager.java b/micro-event-metrics/src/main/java/com/oath/micro/server/event/metrics/TimerManager.java
index 71fcaf091..31c75cedc 100644
--- a/micro-event-metrics/src/main/java/com/oath/micro/server/event/metrics/TimerManager.java
+++ b/micro-event-metrics/src/main/java/com/oath/micro/server/event/metrics/TimerManager.java
@@ -9,7 +9,7 @@
public class TimerManager {
- private final Cache contexts;
+ private final Cache contexts;
public TimerManager(long maxSize, int minutesUntilExpire) {
contexts = CacheBuilder.newBuilder()
@@ -18,13 +18,13 @@ public TimerManager(long maxSize, int minutesUntilExpire) {
.build();
}
- public void complete(long id) {
+ public void complete(String id) {
Maybe.ofNullable(contexts.getIfPresent(id))
- .forEach(c -> c.stop());
+ .forEach(Context::stop);
contexts.invalidate(id);
}
- public void start(long id, Context context) {
+ public void start(String id, Context context) {
contexts.put(id, context);
}
diff --git a/micro-event-metrics/src/test/java/app/event/metrics/com/oath/micro/server/EventStatusResource.java b/micro-event-metrics/src/test/java/app/event/metrics/com/oath/micro/server/EventStatusResource.java
index 46e1e6caa..d63d91407 100644
--- a/micro-event-metrics/src/test/java/app/event/metrics/com/oath/micro/server/EventStatusResource.java
+++ b/micro-event-metrics/src/test/java/app/event/metrics/com/oath/micro/server/EventStatusResource.java
@@ -6,6 +6,8 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Meter;
import cyclops.reactive.collections.mutable.MapX;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -32,11 +34,11 @@ public EventStatusResource(EventBus bus, MetricRegistry metrics) {
@Produces("text/plain")
@Path("/ping")
public String ping() {
- bus.post(RequestEvents.start("get", 1l));
+ bus.post(RequestEvents.start("get", "1"));
try {
return "ok";
} finally {
- bus.post(RequestEvents.finish("get", 1l));
+ bus.post(RequestEvents.finish("get", "1"));
}
}
@@ -44,16 +46,16 @@ public String ping() {
@Produces("application/json")
@Path("/counters")
public Map counters() {
- return (MapX) MapX.fromMap(metrics.getCounters())
- .bimap(k -> k, v -> v.getCount());
+ return MapX.fromMap(metrics.getCounters())
+ .bimap(k -> k, Counter::getCount);
}
@GET
@Produces("application/json")
@Path("/meters")
public Map meters() {
- return (MapX) MapX.fromMap(metrics.getMeters())
- .bimap(k -> k, v -> v.getCount());
+ return MapX.fromMap(metrics.getMeters())
+ .bimap(k -> k, Meter::getCount);
}
}
diff --git a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherConfigOffTest.java b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherConfigOffTest.java
index de0f9bf9a..855105b6d 100644
--- a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherConfigOffTest.java
+++ b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherConfigOffTest.java
@@ -35,9 +35,8 @@ public void setup() {
@Test
public void queriesStartMeterInc() {
- catcher.requestStart(new AddQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestStart(new AddQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.meter(this.config.getPrefix() + ".request-start-test")
@@ -48,9 +47,8 @@ public void queriesStartMeterInc() {
@Test
public void queriesEndMeterInc() {
- catcher.requestComplete(new RemoveQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestComplete(new RemoveQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.meter(this.config.getPrefix() + ".request-end-test")
@@ -61,9 +59,8 @@ public void queriesEndMeterInc() {
@Test
public void queriesCounterInc() {
- catcher.requestStart(new AddQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestStart(new AddQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count")
@@ -74,9 +71,8 @@ public void queriesCounterInc() {
@Test
public void queriesCounterDec() {
- catcher.requestComplete(new RemoveQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestComplete(new RemoveQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count")
@@ -87,8 +83,7 @@ public void queriesCounterDec() {
@Test
public void jobsCounterDec() {
- catcher.jobComplete(new JobCompleteEvent(
- 10l, "test", 10l, 5l));
+ catcher.jobComplete(new JobCompleteEvent("10", "test", 10l, 5l));
assertThat(registry.counter(this.config.getPrefix() + ".jobs-active-test-count")
.getCount(),
equalTo(0l));
@@ -97,15 +92,13 @@ public void jobsCounterDec() {
@Test
public void queriesTimer() {
- catcher.requestStart(new AddQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestStart(new AddQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
- catcher.requestComplete(new RemoveQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestComplete(new RemoveQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.timer(this.config.getPrefix() + ".request-end-test-timer")
@@ -116,8 +109,7 @@ public void queriesTimer() {
@Test
public void jobsMeterInc() {
- catcher.jobStarted(new JobStartEvent(
- 10l, "test"));
+ catcher.jobStarted(new JobStartEvent("10", "test"));
assertThat(registry.meter(this.config.getPrefix() + ".job-meter-test")
.getMeanRate(),
equalTo(0.0));
@@ -126,8 +118,7 @@ public void jobsMeterInc() {
@Test
public void jobsCounterInc() {
- catcher.jobStarted(new JobStartEvent(
- 10l, "test"));
+ catcher.jobStarted(new JobStartEvent("10", "test"));
assertThat(registry.counter(this.config.getPrefix() + ".jobs-active-test-count")
.getCount(),
equalTo(0l));
diff --git a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherTest.java b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherTest.java
index 057b74411..46f027f01 100644
--- a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherTest.java
+++ b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/MetricsCatcherTest.java
@@ -39,7 +39,7 @@ public void queriesStartMeterInc() {
catcher.requestStart(new AddQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.meter(this.config.getPrefix() + ".request-start-test-meter")
@@ -52,7 +52,7 @@ public void queriesEndMeterInc() {
catcher.requestComplete(new RemoveQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.meter(this.config.getPrefix() + ".request-end-test")
@@ -65,7 +65,7 @@ public void queriesCounterInc() {
catcher.requestStart(new AddQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count")
@@ -78,7 +78,7 @@ public void queriesCounterDec() {
catcher.requestComplete(new RemoveQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count")
@@ -91,7 +91,7 @@ public void queriesIntervalCounterInc() {
catcher.requestStart(new AddQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.getGauges().size(), equalTo(2));
@@ -104,7 +104,7 @@ public void queriesIntervalCounterDec() {
catcher.requestComplete(new RemoveQuery(
RequestData.builder()
- .correlationId(10l)
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.getGauges().size(), equalTo(2));
@@ -118,8 +118,7 @@ public void queriesIntervalCounterDec() {
@Test
public void jobsCounterDec() {
- catcher.jobComplete(new JobCompleteEvent(
- 10l, "test", 10l, 5l));
+ catcher.jobComplete(new JobCompleteEvent("10", "test", 10l, 5l));
assertThat(registry.counter(this.config.getPrefix() + ".jobs-active-test-count")
.getCount(),
equalTo(-1l));
@@ -128,15 +127,13 @@ public void jobsCounterDec() {
@Test
public void queriesTimer() {
- catcher.requestStart(new AddQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestStart(new AddQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
- catcher.requestComplete(new RemoveQuery(
- RequestData.builder()
- .correlationId(10l)
+ catcher.requestComplete(new RemoveQuery(RequestData.builder()
+ .correlationId("10")
.type("test")
.build()));
assertThat(registry.timer(this.config.getPrefix() + ".request-end-test-timer")
@@ -147,8 +144,7 @@ public void queriesTimer() {
@Test
public void jobsMeterInc() {
- catcher.jobStarted(new JobStartEvent(
- 10l, "test"));
+ catcher.jobStarted(new JobStartEvent("10", "test"));
assertThat(registry.meter(this.config.getPrefix() + ".job-meter-test")
.getMeanRate(),
greaterThan(0.0));
@@ -157,8 +153,7 @@ public void jobsMeterInc() {
@Test
public void jobsCounterInc() {
- catcher.jobStarted(new JobStartEvent(
- 10l, "test"));
+ catcher.jobStarted(new JobStartEvent("10", "test"));
assertThat(registry.counter(this.config.getPrefix() + ".jobs-active-test-count")
.getCount(),
equalTo(1l));
diff --git a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/TimerManagerTest.java b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/TimerManagerTest.java
index 3e677412c..176fb5f71 100644
--- a/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/TimerManagerTest.java
+++ b/micro-event-metrics/src/test/java/com/oath/micro/server/event/metrics/TimerManagerTest.java
@@ -18,14 +18,14 @@ public void setup() {
@Test
public void whenValueNotPresentNoError() {
- manager.complete(1l);
+ manager.complete("1");
}
@Test
public void whenValueAddedAndRemovedStopCalled() {
Context c = Mockito.mock(Context.class);
- manager.start(1l, c);
- manager.complete(1l);
+ manager.start("1", c);
+ manager.complete("1");
Mockito.verify(c, Mockito.times(1))
.stop();
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/JobCompleteEvent.java b/micro-events/src/main/java/com/oath/micro/server/events/JobCompleteEvent.java
index 7e71b80af..3bedd3dce 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/JobCompleteEvent.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/JobCompleteEvent.java
@@ -10,7 +10,7 @@
public class JobCompleteEvent {
private final Date date = new Date();
- private final long correlationId;
+ private final String correlationId;
private final String type;
private final long errors;
private final long dataSize;
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/JobStartEvent.java b/micro-events/src/main/java/com/oath/micro/server/events/JobStartEvent.java
index 0c3329545..21603f2ba 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/JobStartEvent.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/JobStartEvent.java
@@ -10,7 +10,7 @@
public class JobStartEvent {
private final Date date = new Date();
- private final long correlationId;
+ private final String correlationId;
private final String type;
}
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/JobsBeingExecuted.java b/micro-events/src/main/java/com/oath/micro/server/events/JobsBeingExecuted.java
index 344a4fa64..2cc5ca271 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/JobsBeingExecuted.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/JobsBeingExecuted.java
@@ -79,9 +79,8 @@ private Object executeScheduledJob(final ProceedingJoinPoint pjp, final String t
events.active(id, data);
SystemData retVal = null;
- long correlationId = r.nextLong();
- eventBus.post(new JobStartEvent(
- correlationId, type));
+ String correlationId = String.valueOf(r.nextLong());
+ eventBus.post(new JobStartEvent(correlationId, type));
try {
retVal = Optional.ofNullable(((SystemData) pjp.proceed()))
@@ -92,12 +91,11 @@ private Object executeScheduledJob(final ProceedingJoinPoint pjp, final String t
logSystemEvent(pjp, type, data, retVal);
retVal = Optional.ofNullable(retVal)
.orElse(SystemData.builder()
- .correlationId("" + correlationId)
+ .correlationId(correlationId)
.errors(0l)
.processed(0l)
.build());
- eventBus.post(new JobCompleteEvent(
- correlationId, type, retVal.getErrors(), retVal.getProcessed()));
+ eventBus.post(new JobCompleteEvent(correlationId, type, retVal.getErrors(), retVal.getProcessed()));
}
}
@@ -108,12 +106,7 @@ private void logSystemEvent(final ProceedingJoinPoint pjp, final String type, Jo
.getClass());
loggingRateLimiter.capacityAvailable(pjp.getTarget()
.getClass(),
- this.maxLoggingCapacity, new Runnable() {
- @Override
- public void run() {
- postEvent(pjp, type, data, active);
- }
- });
+ this.maxLoggingCapacity, () -> postEvent(pjp, type, data, active));
}
private void postEvent(ProceedingJoinPoint pjp, String type, JobExecutingData data, SystemData retVal) {
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java b/micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java
index b1e549a51..3ca1f8f42 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java
@@ -31,7 +31,7 @@ public class LabelledEvents {
* @param bus EventBus to post events to
* @param labels Query labels to post to event bus
*/
- public static void start(T query, long correlationId, EventBus bus, String... labels) {
+ public static void start(T query, String correlationId, EventBus bus, String... labels) {
for (String label : labels) {
AddLabelledQuery next = start(query, correlationId, label, null);
@@ -48,7 +48,7 @@ public static void start(T query, long correlationId, EventBus bus, String..
* @param label - allows queries to be grouped by label
* @return Start event to pass to the Events systems EventBus
*/
- public static AddLabelledQuery start(T query, long correlationId, String label) {
+ public static AddLabelledQuery start(T query, String correlationId, String label) {
return start(query, correlationId, label, null);
}
@@ -61,7 +61,7 @@ public static AddLabelledQuery start(T query, long correlationId, String
* @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint
* @return Start event to pass to the Events systems EventBus
*/
- public static AddLabelledQuery start(T query, long correlationId, String label, Object additionalData) {
+ public static AddLabelledQuery start(T query, String correlationId, String label, Object additionalData) {
return new AddLabelledQuery(
RequestData.builder()
@@ -93,7 +93,7 @@ public static AddLabelledQuery start(T query, long correlationId, String
* @param bus EventBus to post events to
* @param labels Query types to post to event bus
*/
- public static void finish(T query, long correlationId, EventBus bus, String... labels) {
+ public static void finish(T query, String correlationId, EventBus bus, String... labels) {
for (String type : labels) {
RemoveLabelledQuery next = finish(query, correlationId, type);
bus.post(next);
@@ -107,7 +107,7 @@ public static void finish(T query, long correlationId, EventBus bus, String.
* @param label - allows queries to be grouped by type
* @return RemoveLabelledQuery event to pass to the Events systems EventBus
*/
- public static RemoveLabelledQuery finish(T query, long correlationId, String label) {
+ public static RemoveLabelledQuery finish(T query, String correlationId, String label) {
return new RemoveLabelledQuery<>(
RequestData.builder()
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java b/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java
index 42b10f58f..b218fc7c4 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java
@@ -20,7 +20,7 @@ public class RequestEvents {
* @param correlationId - Identifier
* @return Start event to pass to the Events systems EventBus
*/
- public static AddQuery start(T query, long correlationId) {
+ public static AddQuery start(T query, String correlationId) {
return start(query, correlationId, "default", null);
}
@@ -32,7 +32,7 @@ public static AddQuery start(T query, long correlationId) {
* @param type - allows queries to be grouped by type
* @return Start event to pass to the Events systems EventBus
*/
- public static AddQuery start(T query, long correlationId, String type) {
+ public static AddQuery start(T query, String correlationId, String type) {
return start(query, correlationId, type, null);
}
@@ -55,7 +55,7 @@ public static AddQuery start(T query, long correlationId, String type) {
* @param bus EventBus to post events to
* @param types Query types to post to event bus
*/
- public static void start(T query, long correlationId, EventBus bus, String... types) {
+ public static void start(T query, String correlationId, EventBus bus, String... types) {
for (String type : types) {
AddQuery next = start(query, correlationId, type, null);
@@ -73,10 +73,9 @@ public static void start(T query, long correlationId, EventBus bus, String..
* @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint
* @return Start event to pass to the Events systems EventBus
*/
- public static AddQuery start(T query, long correlationId, String type, Object additionalData) {
+ public static AddQuery start(T query, String correlationId, String type, Object additionalData) {
- return new AddQuery(
- RequestData.builder()
+ return new AddQuery(RequestData.builder()
.query(query)
.correlationId(correlationId)
.type(type)
@@ -91,7 +90,7 @@ public static AddQuery start(T query, long correlationId, String type, Ob
* @param correlationId - Identifier
* @return Finish event to pass to the Events systems EventBus
*/
- public static RemoveQuery finish(T query, long correlationId) {
+ public static RemoveQuery finish(T query, String correlationId) {
return finish(query, correlationId, "default");
}
@@ -116,7 +115,7 @@ public static RemoveQuery finish(T query, long correlationId) {
* @param bus EventBus to post events to
* @param types Query types to post to event bus
*/
- public static void finish(T query, long correlationId, EventBus bus, String... types) {
+ public static void finish(T query, String correlationId, EventBus bus, String... types) {
for (String type : types) {
RemoveQuery next = finish(query, correlationId, type);
bus.post(next);
@@ -131,10 +130,9 @@ public static void finish(T query, long correlationId, EventBus bus, String.
* @param type - allows queries to be grouped by type
* @return
*/
- public static RemoveQuery finish(T query, long correlationId, String type) {
+ public static RemoveQuery finish(T query, String correlationId, String type) {
- return new RemoveQuery<>(
- RequestData.builder()
+ return new RemoveQuery<>(RequestData.builder()
.query(query)
.correlationId(correlationId)
.type(type)
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/RequestTypes.java b/micro-events/src/main/java/com/oath/micro/server/events/RequestTypes.java
index 3271eed14..0554fe91a 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/RequestTypes.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/RequestTypes.java
@@ -30,8 +30,7 @@ public RequestTypes(EventBus bus, boolean queryCapture) {
@Override
public String toString() {
- Map result = toMap();
- return JacksonUtil.serializeToJson(result);
+ return JacksonUtil.serializeToJson(toMap());
}
public Map toMap() {
@@ -42,8 +41,7 @@ public Map toMap() {
@Subscribe
public void finished(RemoveQuery data) {
String key = data.getData().type;
- map.computeIfAbsent(key, k -> new RequestsBeingExecuted(
- bus, k)).events.finished(buildId(data.getData()));
+ map.computeIfAbsent(key, k -> new RequestsBeingExecuted(bus, k)).events.finished(buildId(data.getData()));
}
@@ -51,21 +49,18 @@ public void finished(RemoveQuery data) {
public void processing(AddQuery data) {
String id = buildId(data.getData());
String key = data.getData().type;
- map.computeIfAbsent(key, k -> new RequestsBeingExecuted(
- bus, k)).events.active(id, data.getData());
+ map.computeIfAbsent(key, k -> new RequestsBeingExecuted(bus, k)).events.active(id, data.getData());
}
private String buildId(RequestData data) {
- String id = "" + data.correlationId;
- return id;
+ return data.correlationId;
}
public static class AddQuery extends AddEvent> {
public AddQuery(RequestData data) {
- super(
- data);
+ super(data);
}
}
@@ -73,8 +68,7 @@ public AddQuery(RequestData data) {
public static class RemoveQuery extends RemoveEvent> {
public RemoveQuery(RequestData data) {
- super(
- data);
+ super(data);
}
}
@@ -82,8 +76,7 @@ public RemoveQuery(RequestData data) {
public static class AddLabelledQuery extends AddEvent> {
public AddLabelledQuery(RequestData data) {
- super(
- data);
+ super(data);
}
}
@@ -91,8 +84,7 @@ public AddLabelledQuery(RequestData data) {
public static class RemoveLabelledQuery extends RemoveEvent> {
public RemoveLabelledQuery(RequestData data) {
- super(
- data);
+ super(data);
}
}
@@ -103,7 +95,7 @@ public RemoveLabelledQuery(RequestData data) {
@Getter
public static class RequestData extends BaseEventInfo {
- private final long correlationId;
+ private final String correlationId;
private final T query;
diff --git a/micro-events/src/main/java/com/oath/micro/server/events/SystemData.java b/micro-events/src/main/java/com/oath/micro/server/events/SystemData.java
index d19f6b972..3a2055187 100644
--- a/micro-events/src/main/java/com/oath/micro/server/events/SystemData.java
+++ b/micro-events/src/main/java/com/oath/micro/server/events/SystemData.java
@@ -28,7 +28,6 @@ private SystemData(long processed, long errors, Map dataMap) {
this.processed = processed;
this.errors = errors;
this.dataMap = dataMap;
- this.correlationId = "" + r.nextLong();
-
+ this.correlationId = String.valueOf(r.nextLong());
}
}
diff --git a/micro-events/src/main/java/com/oath/micro/server/rest/resources/ManifestResource.java b/micro-events/src/main/java/com/oath/micro/server/rest/resources/ManifestResource.java
index 2011e4cf3..4ea6e3d09 100644
--- a/micro-events/src/main/java/com/oath/micro/server/rest/resources/ManifestResource.java
+++ b/micro-events/src/main/java/com/oath/micro/server/rest/resources/ManifestResource.java
@@ -28,24 +28,18 @@
@Component
public class ManifestResource implements CommonRestResource, SingletonRestResource{
-
private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-
@GET
@Produces("application/json")
public void mainfest(@Suspended AsyncResponse asyncResponse, @Context ServletContext context) {
-
- ReactiveSeq.of("/META-INF/MANIFEST.MF")
- .map(url->context.getResourceAsStream(url))
- .map(this::getManifest)
- .foldFuture(WorkerThreads.ioExecutor.get(),
- s->s.forEach(Long.MAX_VALUE,result->asyncResponse.resume(result)));
-
-
- }
+ ReactiveSeq.of("/META-INF/MANIFEST.MF")
+ .map(url -> context.getResourceAsStream(url))
+ .map(this::getManifest)
+ .foldFuture(WorkerThreads.ioExecutor.get(),
+ s -> s.forEach(Long.MAX_VALUE, result -> asyncResponse.resume(result)));
+ }
public Map getManifest(final InputStream input) {
@@ -64,4 +58,4 @@ public Map getManifest(final InputStream input) {
return retMap;
}
-}
\ No newline at end of file
+}
diff --git a/micro-events/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java b/micro-events/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
index bbccb6abb..9c7a2fddf 100644
--- a/micro-events/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
+++ b/micro-events/src/test/java/app/events/com/oath/micro/server/EventStatusResource.java
@@ -26,11 +26,11 @@ public EventStatusResource(EventBus bus) {
@Produces("text/plain")
@Path("/ping")
public String ping() {
- bus.post(RequestEvents.start("get", 1l));
+ bus.post(RequestEvents.start("get", "1"));
try {
return "ok";
} finally {
- bus.post(RequestEvents.finish("get", 1l));
+ bus.post(RequestEvents.finish("get", "1"));
}
}
@@ -38,12 +38,12 @@ public String ping() {
@Produces("text/plain")
@Path("/ping-custom")
public String pingCustom() {
- bus.post(RequestEvents.start("get", 1l, "custom"));
+ bus.post(RequestEvents.start("get", "1", "custom"));
try {
return "ok";
} finally {
- bus.post(RequestEvents.finish("get", 1l, "custom"));
+ bus.post(RequestEvents.finish("get", "1", "custom"));
}
}
-}
\ No newline at end of file
+}
diff --git a/micro-events/src/test/java/app/multi/events/com/oath/micro/server/MultiEventStatusResource.java b/micro-events/src/test/java/app/multi/events/com/oath/micro/server/MultiEventStatusResource.java
index d0aa27fb2..483ce2e90 100644
--- a/micro-events/src/test/java/app/multi/events/com/oath/micro/server/MultiEventStatusResource.java
+++ b/micro-events/src/test/java/app/multi/events/com/oath/micro/server/MultiEventStatusResource.java
@@ -26,11 +26,11 @@ public MultiEventStatusResource(EventBus bus) {
@Produces("text/plain")
@Path("/ping")
public String ping() {
- RequestEvents.start("get", 1l, bus, "typeA", "custom");
+ RequestEvents.start("get", "1", bus, "typeA", "custom");
try {
return "ok";
} finally {
- RequestEvents.finish("get", 1l, bus, "typeA", "custom");
+ RequestEvents.finish("get", "1", bus, "typeA", "custom");
}
}
@@ -38,12 +38,12 @@ public String ping() {
@Produces("text/plain")
@Path("/ping-custom")
public String pingCustom() {
- RequestEvents.start("get", 1l, bus, "typeA", "custom");
+ RequestEvents.start("get", "1", bus, "typeA", "custom");
try {
return "ok";
} finally {
- RequestEvents.finish("get", 1l, bus, "typeA", "custom");
+ RequestEvents.finish("get", "1", bus, "typeA", "custom");
}
}
-}
\ No newline at end of file
+}
diff --git a/micro-events/src/test/java/com/oath/micro/server/events/LabelledEventsTest.java b/micro-events/src/test/java/com/oath/micro/server/events/LabelledEventsTest.java
index 3d34d84cb..9bf0a6ad6 100644
--- a/micro-events/src/test/java/com/oath/micro/server/events/LabelledEventsTest.java
+++ b/micro-events/src/test/java/com/oath/micro/server/events/LabelledEventsTest.java
@@ -14,14 +14,14 @@
public class LabelledEventsTest {
String query;
- long corrId;
+ String corrId;
String label;
String addData;
@Before
public void setUp() {
query = "query as string";
- corrId = 1234;
+ corrId = "1234";
label = "label";
addData = "additional data";
}
diff --git a/micro-events/src/test/java/com/oath/micro/server/events/RequestsBeingExecutedTest.java b/micro-events/src/test/java/com/oath/micro/server/events/RequestsBeingExecutedTest.java
index 245e48e28..08cd008cf 100644
--- a/micro-events/src/test/java/com/oath/micro/server/events/RequestsBeingExecutedTest.java
+++ b/micro-events/src/test/java/com/oath/micro/server/events/RequestsBeingExecutedTest.java
@@ -18,59 +18,57 @@ public class RequestsBeingExecutedTest {
@Before
public void setup() {
bus = new EventBus();
- requests = new RequestsBeingExecuted(
- bus);
- types = new RequestTypes(
- bus, true);
+ requests = new RequestsBeingExecuted(bus);
+ types = new RequestTypes(bus, true);
types.getMap()
.put("default", requests);
}
@Test
public void oneEvent() {
- bus.post(RequestEvents.start("data", 100l));
+ bus.post(RequestEvents.start("data", "100"));
assertThat(requests.events(), is(1));
}
@Test
public void twoEvents() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 120l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "120"));
assertThat(requests.events(), is(2));
}
@Test
public void twoIdenticalEvents() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 100l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "100"));
assertThat(requests.events(), is(2));
}
@Test
public void oneEventSize() {
- bus.post(RequestEvents.start("data", 100l));
+ bus.post(RequestEvents.start("data", "100"));
assertThat(requests.size(), is(1));
}
@Test
public void twoEventsSize() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 120l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "120"));
assertThat(requests.size(), is(2));
}
@Test
public void twoIdenticalEventsSize() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 100l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "100"));
assertThat(requests.size(), is(1));
}
@Test
public void twoEventsOneFinished() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 120l));
- bus.post(RequestEvents.finish("data", 120l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "120"));
+ bus.post(RequestEvents.finish("data", "120"));
assertThat(requests.events(), is(2));
assertThat(requests.size(), is(1));
}
@@ -82,20 +80,19 @@ public void twoEventsDifferentTypesOneFinishedDefaultTypeIsIgnored() {
types.getMap()
.put("typeA", requests);
- bus.post(RequestEvents.start("data", 130l));
- bus.post(RequestEvents.start("data", 120l, "typeA", "data2"));
- bus.post(RequestEvents.finish("data", 120l, "typeA"));
+ bus.post(RequestEvents.start("data", "130"));
+ bus.post(RequestEvents.start("data", "120", "typeA", "data2"));
+ bus.post(RequestEvents.finish("data", "120", "typeA"));
assertThat(requests.events(), is(1));
assertThat(requests.size(), is(0));
}
@Test
public void testToString() {
- bus.post(RequestEvents.start("data", 100l));
- bus.post(RequestEvents.start("data", 120l));
- bus.post(RequestEvents.finish("data", 120l));
+ bus.post(RequestEvents.start("data", "100"));
+ bus.post(RequestEvents.start("data", "120"));
+ bus.post(RequestEvents.finish("data", "120"));
- System.out.println(requests.toString());
assertThat(requests.toString(), containsString("\"removed\":1"));
assertThat(requests.toString(), containsString("\"added\":2"));
diff --git a/micro-events/src/test/java/com/oath/micro/server/rest/resources/ActiveResourceTest.java b/micro-events/src/test/java/com/oath/micro/server/rest/resources/ActiveResourceTest.java
index afc30c027..6adfee8fb 100644
--- a/micro-events/src/test/java/com/oath/micro/server/rest/resources/ActiveResourceTest.java
+++ b/micro-events/src/test/java/com/oath/micro/server/rest/resources/ActiveResourceTest.java
@@ -51,8 +51,8 @@ public void setUp() throws Exception {
@Test
public void testactiveRequests() {
- bus.post(RequestEvents.start("query", 1l));
- bus.post(RequestEvents.start("query", 2l, "partition", ImmutableMap.of()));
+ bus.post(RequestEvents.start("query", "1"));
+ bus.post(RequestEvents.start("query", "2", "partition", ImmutableMap.of()));
MockAsyncResponse response = new MockAsyncResponse<>();
active.activeRequests(response, null);
assertThat(convert(response.response()).get("events"), is(1));
@@ -62,8 +62,8 @@ public void testactiveRequests() {
@Test
public void whenQueriesWithTheSameIdToDifferentTypesEventsIs1ForBoth() {
- bus.post(RequestEvents.start("query", 1l));
- bus.post(RequestEvents.start("query", 1l, "partition", ImmutableMap.of()));
+ bus.post(RequestEvents.start("query", "1"));
+ bus.post(RequestEvents.start("query", "1", "partition", ImmutableMap.of()));
MockAsyncResponse response = new MockAsyncResponse<>();
active.activeRequests(response, null);
assertThat(convert(response.response()).get("events"), is(1));
@@ -73,8 +73,8 @@ public void whenQueriesWithTheSameIdToDifferentTypesEventsIs1ForBoth() {
@Test
public void whenQueriesWithTheSameIdButSameTypesEventsIs2ButSizeIs1() {
- bus.post(RequestEvents.start("query", 1l));
- bus.post(RequestEvents.start("query", 1l));
+ bus.post(RequestEvents.start("query", "1"));
+ bus.post(RequestEvents.start("query", "1"));
MockAsyncResponse response = new MockAsyncResponse<>();
active.activeRequests(response, null);
assertThat(convert(response.response()).get("events"), is(2));
diff --git a/micro-grizzly-with-jersey/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java b/micro-grizzly-with-jersey/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
index 958912e7a..f75309862 100644
--- a/micro-grizzly-with-jersey/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
+++ b/micro-grizzly-with-jersey/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
@@ -19,11 +19,8 @@ public class TestAppResource implements TestAppRestResource {
private final SimpleReact simpleReact = new SimpleReact();
private final RestAgent template = new RestAgent();
- private final List urls = Arrays.asList("http://localhost:8081/alternative-app/alt-status/ping",
- "http://localhost:8080/test-app/test-status/ping",
- "http://localhost:8082/simple-app/status/ping",
- "http://localhost:8080/test-app/test-status/ping");
-
+ private final List urls = Arrays.asList(
+ "http://localhost:8080/test-app/test-status/ping","http://localhost:8080/test-app/test-status/ping");
@GET
diff --git a/micro-boot/src/test/java/app/single/com/oath/micro/server/SingleClassTest.java b/micro-grizzly-with-jersey/src/test/java/app/root/context/single/RootSingleClassTest.java
similarity index 75%
rename from micro-boot/src/test/java/app/single/com/oath/micro/server/SingleClassTest.java
rename to micro-grizzly-with-jersey/src/test/java/app/root/context/single/RootSingleClassTest.java
index bc1a5a5b1..8bdb62290 100644
--- a/micro-boot/src/test/java/app/single/com/oath/micro/server/SingleClassTest.java
+++ b/micro-grizzly-with-jersey/src/test/java/app/root/context/single/RootSingleClassTest.java
@@ -1,52 +1,48 @@
-package app.single.com.oath.micro.server;
+package app.root.context.single;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.ExecutionException;
+import com.oath.micro.server.MicroserverApp;
+import com.oath.micro.server.auto.discovery.RestResource;
+import com.oath.micro.server.config.Microserver;
+import com.oath.micro.server.testing.RestAgent;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.oath.micro.server.MicroserverApp;
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.oath.micro.server.config.Microserver;
-import com.oath.micro.server.testing.RestAgent;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
@Microserver
@Path("/single")
-@Ignore
-public class SingleClassTest implements RestResource{
+public class RootSingleClassTest implements RestResource{
RestAgent rest = new RestAgent();
-
+
MicroserverApp server;
@Before
public void startServer(){
-
- server = new MicroserverApp( ()-> "simple-app");
+
+ server = new MicroserverApp( RootSingleClassTest.class, ()-> "");
server.start();
}
-
+
@After
public void stopServer(){
server.stop();
}
-
+
@Test
public void runAppAndBasicTest() throws InterruptedException, ExecutionException{
-
-
-
- assertThat(rest.get("http://localhost:8080/simple-app/single/ping"),is("ok"));
-
+
+
+
+ assertThat(rest.get("http://localhost:8080/single/ping"),is("ok"));
+
}
@GET
@@ -55,6 +51,6 @@ public void runAppAndBasicTest() throws InterruptedException, ExecutionException
public String ping() {
return "ok";
}
-
-
-}
\ No newline at end of file
+
+
+}
diff --git a/micro-grizzly/src/main/java/com/oath/micro/server/servers/grizzly/GrizzlyApplication.java b/micro-grizzly/src/main/java/com/oath/micro/server/servers/grizzly/GrizzlyApplication.java
index 8d444deb1..ca46b1a50 100644
--- a/micro-grizzly/src/main/java/com/oath/micro/server/servers/grizzly/GrizzlyApplication.java
+++ b/micro-grizzly/src/main/java/com/oath/micro/server/servers/grizzly/GrizzlyApplication.java
@@ -49,13 +49,13 @@ public class GrizzlyApplication implements ServerApplication {
private final PersistentList servletData;
private final PersistentList servletContextListenerData;
private final PersistentList servletRequestListenerData;
-
+
public GrizzlyApplication(AllData serverData) {
this.serverData = serverData.getServerData();
this.filterData = serverData.getFilterDataList();
this.servletData = serverData.getServletDataList();
this.servletContextListenerData = serverData.getServletContextListeners();
- this.servletRequestListenerData = serverData.getServletRequestListeners();
+ this.servletRequestListenerData = serverData.getServletRequestListeners();
}
public void run(CompletableFuture start, JaxRsServletConfigurer jaxRsConfigurer, CompletableFuture end) {
@@ -64,7 +64,7 @@ public void run(CompletableFuture start, JaxRsServletConfigurer jaxRsConfigurer
new ServletContextListenerConfigurer(serverData, servletContextListenerData, servletRequestListenerData);
-
+
jaxRsConfigurer.addServlet(this.serverData,webappContext);
new ServletConfigurer(serverData, servletData).addServlets(webappContext);
@@ -80,7 +80,7 @@ public void run(CompletableFuture start, JaxRsServletConfigurer jaxRsConfigurer
startServer(webappContext, httpServer, start, end);
}
-
+
private void addSSL(HttpServer httpServer) {
try {
@@ -100,10 +100,10 @@ private void startServer(WebappContext webappContext, HttpServer httpServer, Com
webappContext.deploy(httpServer);
try {
logger.info("Starting application {} on port {}", serverData.getModule().getContext(), serverData.getPort());
- logger.info("Browse to http://localhost:{}/{}/application.wadl", serverData.getPort(), serverData.getModule().getContext());
+ logger.info("Browse to http://localhost:{}{}/application.wadl", serverData.getPort(), serverData.getNormalizedContextPath());
logger.info("Configured resource classes :-");
serverData.extractResources()
- .forEach(t -> logger.info(t._1() + " : " + "http://localhost:" + serverData.getPort() + "/" + serverData.getModule().getContext() + t._2()));
+ .forEach(t -> logger.info(t._1() + " : " + "http://localhost:" + serverData.getPort() + "/" + serverData.getNormalizedContextPath() + t._2()));
;
httpServer.start();
start.complete(true);
@@ -138,7 +138,7 @@ private void addAccessLog(HttpServer httpServer) {
}
}
-
+
private NetworkListener createSSLListener(int port, SSLProperties sslProperties) {
diff --git a/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/EmbeddedAppTest.java b/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/EmbeddedAppTest.java
index 83eb220c1..16c1876ee 100644
--- a/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/EmbeddedAppTest.java
+++ b/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/EmbeddedAppTest.java
@@ -3,6 +3,7 @@
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;
@@ -54,7 +55,9 @@ public void confirmExpectedUrlsPresentTest() throws InterruptedException, Execut
@Test
public void nonBlockingRestClientTest(){
- assertThat(rest.get("http://localhost:8080/test-app/test-status/rest-calls"),is("-*test!-*test!"));
+
+ assertThat(rest.get("http://localhost:8080/test-app/test-status/rest-calls"), is("-*test!-*test!"));
+
}
CompletableFuture toCompletableFuture(
diff --git a/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java b/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
index 958912e7a..9661a9672 100644
--- a/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
+++ b/micro-grizzly/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
@@ -19,10 +19,8 @@ public class TestAppResource implements TestAppRestResource {
private final SimpleReact simpleReact = new SimpleReact();
private final RestAgent template = new RestAgent();
- private final List urls = Arrays.asList("http://localhost:8081/alternative-app/alt-status/ping",
- "http://localhost:8080/test-app/test-status/ping",
- "http://localhost:8082/simple-app/status/ping",
- "http://localhost:8080/test-app/test-status/ping");
+ private final List urls = Arrays.asList(
+ "http://localhost:8080/test-app/test-status/ping","http://localhost:8080/test-app/test-status/ping");
@@ -43,7 +41,7 @@ public String restCallResult(){
.then(it -> "*"+it)
.peek(loadedAndModified -> System.out.println(loadedAndModified))
.block().stream().reduce("", (acc,next) -> acc+"-"+next);
-
+
}
}
diff --git a/micro-guava/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java b/micro-guava/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
index 0876343ad..e416ccc4d 100644
--- a/micro-guava/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
+++ b/micro-guava/src/test/java/app/embedded/com/oath/micro/server/TestAppResource.java
@@ -11,17 +11,18 @@
import com.oath.micro.server.testing.RestAgent;
import com.google.common.collect.ImmutableList;
+
+import java.util.Arrays;
+import java.util.List;
+
@Component
@Path("/test-status")
public class TestAppResource implements TestAppRestResource {
private final SimpleReact simpleReact = new SimpleReact();
private final RestAgent template = new RestAgent();
- private final ImmutableList urls = ImmutableList.of("http://localhost:8081/alternative-app/alt-status/ping",
- "http://localhost:8080/test-app/test-status/ping",
- "http://localhost:8082/simple-app/status/ping",
- "http://localhost:8080/test-app/test-status/ping");
-
+ private final List urls = Arrays.asList(
+ "http://localhost:8080/test-app/test-status/ping","http://localhost:8080/test-app/test-status/ping");
@GET
diff --git a/micro-jackson-configuration/build.gradle b/micro-jackson-configuration/build.gradle
index 62eccd8ad..2edaaa295 100644
--- a/micro-jackson-configuration/build.gradle
+++ b/micro-jackson-configuration/build.gradle
@@ -2,6 +2,7 @@ description = 'micro-jackson-configuration'
dependencies {
compile project(':micro-core')
+ compile("com.oath.cyclops:cyclops-jackson-integration:$cyclopsVersion")
}
modifyPom {
diff --git a/micro-jackson-configuration/src/main/java/com/oath/micro/server/jackson/CoreJacksonConfigurator.java b/micro-jackson-configuration/src/main/java/com/oath/micro/server/jackson/CoreJacksonConfigurator.java
index f3d94be57..ba5f7300d 100644
--- a/micro-jackson-configuration/src/main/java/com/oath/micro/server/jackson/CoreJacksonConfigurator.java
+++ b/micro-jackson-configuration/src/main/java/com/oath/micro/server/jackson/CoreJacksonConfigurator.java
@@ -2,6 +2,7 @@
import java.util.Optional;
+import com.oath.cyclops.jackson.CyclopsModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -32,6 +33,7 @@ public void accept(ObjectMapper mapper) {
.forEach(m -> mapper.registerModule(m));
mapper.registerModule(new Jdk8Module());
+ mapper.registerModule(new CyclopsModule());
}
}
diff --git a/micro-jackson-configuration/src/test/java/com/oath/micro/server/rest/JacksonUtilTest.java b/micro-jackson-configuration/src/test/java/com/oath/micro/server/rest/JacksonUtilTest.java
index cccc3173e..fd66ec7f4 100644
--- a/micro-jackson-configuration/src/test/java/com/oath/micro/server/rest/JacksonUtilTest.java
+++ b/micro-jackson-configuration/src/test/java/com/oath/micro/server/rest/JacksonUtilTest.java
@@ -50,7 +50,7 @@ public void serialiseAndDeserialise() {
.contains("blah"));
}
- @Test @Ignore
+ @Test
public void serializeToPersistentList() {
LinkedListX list = LinkedListX.of(1, 2, 3, 4);
@@ -58,7 +58,7 @@ public void serializeToPersistentList() {
Seq stack = JacksonUtil.convertFromJson(jsonString, Seq.class);
- assertThat(stack, equalTo(list.reverse()));
+ assertThat(stack, equalTo(list));
}
}
diff --git a/micro-jersey/src/main/java/com/oath/micro/server/rest/jersey/JerseyRestApplication.java b/micro-jersey/src/main/java/com/oath/micro/server/rest/jersey/JerseyRestApplication.java
index fdfa1b927..1c387758c 100644
--- a/micro-jersey/src/main/java/com/oath/micro/server/rest/jersey/JerseyRestApplication.java
+++ b/micro-jersey/src/main/java/com/oath/micro/server/rest/jersey/JerseyRestApplication.java
@@ -1,5 +1,15 @@
package com.oath.micro.server.rest.jersey;
+import com.oath.micro.server.auto.discovery.Rest;
+import com.oath.micro.server.auto.discovery.RestResource;
+import com.oath.micro.server.module.JaxRsProvider;
+import com.oath.micro.server.servers.ServerThreadLocalVariables;
+import lombok.Getter;
+import org.glassfish.jersey.message.GZipEncoder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.server.ServerProperties;
+import org.glassfish.jersey.server.filter.EncodingFilter;
+
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -7,16 +17,6 @@
import java.util.concurrent.ConcurrentMap;
import java.util.function.Consumer;
-import lombok.Getter;
-
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.server.ServerProperties;
-
-import com.oath.micro.server.auto.discovery.Rest;
-import com.oath.micro.server.auto.discovery.RestResource;
-import com.oath.micro.server.module.JaxRsProvider;
-import com.oath.micro.server.servers.ServerThreadLocalVariables;
-
public class JerseyRestApplication extends ResourceConfig {
@Getter
@@ -52,6 +52,9 @@ public JerseyRestApplication(List