@Microserver static class Instance{} }
@Microserver(basePackages = { "app.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(); } }
@Microserver(basePackages = { "app.embedded.com.oath.micro.server" }) public class EmbeddedAppLocalMain { public static void main(String[] args) throws InterruptedException { new MicroserverApp( EmbeddedModule.tagInterfaceModule(LinkedListX.of(TestAppRestResource.class),"test-app"), EmbeddedModule.tagInterfaceModule(LinkedListX.of(AltAppRestResource.class),"alternative-app")).start(); } }
/** * Any new classes shoud be added into blackListedClasses for test to pass until proper solution with * matching varargs will be found */ @Microserver(blacklistedClasses = {Integer.class, SpringContextFactoryTest.class}) public class SpringContextFactoryTest { @Test public void blacklisting() { SpringBuilder springBuilder = mock(SpringBuilder.class); Set<Class<?>> classes = new HashSet<>(); classes.add(Integer.class); classes.add(String.class); Config config = Config.instance().withBasePackages(new String[] {"com.aol.micro.server.spring"}).set(); new SpringContextFactory(config ,this.getClass(), classes).withSpringBuilder(springBuilder).createSpringContext(); ArgumentCaptor<Class> varArgs = ArgumentCaptor.forClass(Class.class); verify(springBuilder).createSpringApp(anyObject(), varArgs.capture()); Assert.assertTrue(varArgs.getAllValues().contains(String.class)); Assert.assertFalse(varArgs.getAllValues().contains(Integer.class)); } }
@Microserver public class DistLockRunnerTest { RestAgent rest = new RestAgent(); MicroserverApp server; @Before public void startServer() { server = new MicroserverApp( () -> "test-app"); server.start(); } @After public void stopServer() { server.stop(); } @Test public void testOwnLock() { assertThat(rest.getJson("http://localhost:8080/test-app/lock-owner/dummy-key"), is("true")); assertThat(rest.getJson("http://localhost:8080/test-app/lock-owner/dummyKeyProvider2"), is("false")); } }
@Microserver public class ListenerRunnerTest {
@Microserver(properties={"access.log.output", "${user.home}"}) public class AccessLogConfigTest {
@Microserver public class CustomRunnerTest {
@Microserver public class PrototypeLockCuratorRunnerTest {
@Microserver public class CustomRunnerTest {
@Microserver(properties={"jackson.serialization","ALWAYS"}) public class IncludesRunnerTest {
@Microserver public class SimpleRunnerTest {
@Microserver public class KeepLockCuratorRunnerTest {
@Microserver(properties = { "db.connection.driver", "org.hsqldb.jdbcDriver", "db.connection.url", "jdbc:hsqldb:mem:aname", "db.connection.username", "sa", "db.connection.dialect", "org.hibernate.dialect.HSQLDialect" }) public class JdbcRunnerTest {
@Microserver @Rest @Path("/test") public class SimpleApp { public static void main(String[] args){ new MicroserverApp(()->"hello-world").run(); } @GET public String test(){ return "ok!"; } }
@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(); } }
@Microserver @Microboot public class SimpleRunnerTest {
@Microserver @Microboot public class AsyncAppRunner {
@Microserver @Microboot public class ListenerRunnerTest {
@Rest @Path("/status") @Microserver public class StatusGroovy { public static void main(String[] args) { /** List<Thread> app = new MicroserverApp(StatusGroovy.class, DefaultGroovyMethods.asType(new Closure<String>(null, null) { public String doCall() { return "status-app"; } }, Module.class)).start(); **/ } @GET @Produces("text/plain") @Path("/ping") public String respondToPing() { return "pong!"; } }