public static void after(Object test) { Msc.logSection("END TEST"); for (RapidoidModule mod : RapidoidModules.getAllAvailable()) { mod.afterTest(test); } Msc.logSection("FINISHED"); }
private static void bootstrapJPA(String[] packages, DataSource dataSource, Class<?>[] providedEntities) { Msc.logSection("Bootstrapping JPA (Hibernate)..."); List<String> entityTypes = EMFUtil.getEntityTypes(packages, providedEntities); if (entityTypes.isEmpty()) { Log.info("Didn't find JPA entities, canceling JPA/Hibernate setup!"); return; } Properties props = EMFUtil.hibernateProperties(); Msc.logSection("Hibernate properties:"); Msc.logProperties(props); Msc.logSection("Starting Hibernate:"); CustomHibernatePersistenceProvider provider = new CustomHibernatePersistenceProvider(dataSource, entityTypes); EntityManagerFactory emf = createEMF(props, provider); emf(emf); Msc.logSection("JPA (Hibernate) is ready."); }
private static void runMainClass(Object test) { IntegrationTest testInfo = Metadata.getAnnotationRecursive(test.getClass(), IntegrationTest.class); if (testInfo != null) { Msc.logSection("RUN MAIN"); Class<?> main = testInfo.main(); String[] args = testInfo.args(); Msc.invokeMain(main, args); } }
public static void filterAndInvokeMainClasses(Object[] beans, Set<Class<?>> invoked) { List<Class<?>> toInvoke = U.list(); for (Object bean : beans) { U.notNull(bean, "bean"); if (bean instanceof Class<?>) { Class<?> clazz = (Class<?>) bean; if (Cls.isAnnotated(clazz, Run.class) && !invoked.contains(clazz)) { toInvoke.add(clazz); } } } invoked.addAll(toInvoke); for (Class<?> clazz : toInvoke) { Msc.logSection("Invoking @Run component: " + clazz.getName()); String[] args = U.arrayOf(String.class, Env.args()); Msc.invokeMain(clazz, args); } }
public static void before(Object test) { Msc.logSection("INITIALIZE"); for (RapidoidModule mod : RapidoidModules.getAllAvailable()) { Log.debug("Initializing module before the test", "module", mod.name(), "order", mod.order()); mod.beforeTest(test); } Log.debug("All modules are initialized"); }
public static void start(Object test) { runMainClass(test); for (RapidoidModule mod : RapidoidModules.getAllAvailable()) { Log.debug("Initializing the test", "module", mod.name(), "order", mod.order()); mod.initTest(test); } Msc.logSection("START TEST"); }
public static synchronized void bootstrapAdminCredentials() { Config admin = Conf.USERS.sub("admin"); if (!admin.has("password") && !admin.has("hash")) { String pass = randomAdminPassword(); admin.set("password", pass); String maybePass = "" + Msc.maybeMasked(pass); Msc.logSection(AnsiColor.lightBlue("ADMIN CREDENTIALS:") + " username = admin, password = " + maybePass); } }
public Booter adminCenter() { Msc.logSection("Registering Admin Center:"); overview(); entities(); application(); lifecycle(); jmx(); metrics(); auth(); return this; }
private static synchronized void restartApp() { if (!MscOpts.hasRapidoidWatch()) { Log.warn("Cannot reload/restart the application, module rapidoid-watch is missing!"); } if (mainClassName == null) { Log.warn("Cannot reload/restart the application, the main app class couldn't be detected!"); } Msc.logSection("!Restarting the web application..."); restarted = true; notifyListenersBeforeRestart(); resetAppStateBeforeRestart(); if (MscOpts.hasRapidoidJPA()) { loader = ReloadUtil.reloader(); ClasspathUtil.setDefaultClassLoader(loader); } reloadAndRunMainClass(); restarted = true; notifyListenersAfterRestart(); Log.info("!Successfully restarted the application!"); }
public static void bootstrapAppGoodies(Setup setup) { Msc.logSection("Registering App services:"); auth(setup); }
public static synchronized void bootstrapAdminCredentials() { Config admin = Conf.USERS.sub("admin"); if (!admin.has("password") && !admin.has("hash")) { String pass = randomAdminPassword(); admin.set("password", pass); String maybePass = "" + Msc.maybeMasked(pass); Msc.logSection(AnsiColor.lightBlue("ADMIN CREDENTIALS:") + " username = admin, password = " + maybePass); } }
public static void adminCenter(Setup setup) { Msc.logSection("Registering Admin Center:"); Metrics.bootstrap(); overview(setup); entities(setup); application(setup); lifecycle(setup); manageables(setup); jmx(setup); metrics(setup); auth(setup); status(setup); }
private static synchronized void restartApp() { if (!MscOpts.hasRapidoidWatch()) { Log.warn("Cannot reload/restart the application, module rapidoid-watch is missing!"); } if (mainClassName == null) { Log.warn("Cannot reload/restart the application, the main app class couldn't be detected!"); } Msc.logSection("!Restarting the web application..."); restarted = true; notifyListenersBeforeRestart(); resetAppStateBeforeRestart(); if (MscOpts.hasRapidoidJPA()) { loader = ReloadUtil.reloader(); ClasspathUtil.setDefaultClassLoader(loader); } reloadAndRunMainClass(); restarted = true; notifyListenersAfterRestart(); Log.info("!Successfully restarted the application!"); }