How to use getLauncher method of com.paypal.selion.internal.platform.grid.AbstractBaseLocalServerComponent class

Best SeLion code snippet using com.paypal.selion.internal.platform.grid.AbstractBaseLocalServerComponent.getLauncher

Source:AbstractBaseLocalServerComponent.java Github

copy

Full Screen

...42 AbstractBaseLocalServerComponent.class.getSimpleName()));43 }44 public synchronized void boot(AbstractTestSession testSession) {45 LOGGER.entering();46 if (getLauncher().isRunning()) {47 LOGGER.exiting();48 return;49 }50 checkPort(getPort(), String.format("for the %s", this.getClass().getSimpleName()));51 setExecutor(Executors.newSingleThreadExecutor());52 Runnable worker = getLauncher();53 try {54 getExecutor().execute(worker);55 waitForInitialization(Long.parseLong(Config.getConfigProperty(ConfigProperty.DOWNLOAD_TIMEOUT)));56 waitForComponentToComeUp();57 LOGGER.info(String.format("%s spawned", this.getClass().getSimpleName()));58 } catch (IllegalStateException e) {59 throw new GridException(String.format("Failed to start a %s", this.getClass().getSimpleName()), e);60 }61 LOGGER.exiting();62 }63 public synchronized void shutdown() {64 LOGGER.entering();65 if (!getLauncher().isRunning()) {66 LOGGER.exiting();67 return;68 }69 try {70 getLauncher().shutdown();71 getExecutor().shutdownNow();72 while (!getExecutor().isTerminated() || getLauncher().isRunning()) {73 getExecutor().awaitTermination(30, TimeUnit.SECONDS);74 }75 LOGGER.info(String.format("%s has been stopped", this.getClass().getSimpleName()));76 } catch (InterruptedException e) {77 String errorMsg = "An error occurred while attempting to shut down the %s.";78 LOGGER.log(Level.SEVERE, String.format(errorMsg, this.getClass().getSimpleName()));79 }80 LOGGER.exiting();81 }82 /**83 * Check the port availability84 * 85 * @param port86 * the port to check87 * @param msg88 * the text to append to the end of the error message displayed when the port is not available.89 * @throws IllegalArgumentException90 * when the port is not available.91 */92 void checkPort(int port, String msg) {93 StringBuilder message = new StringBuilder().append(" ").append(msg);94 String portInUseError = String.format("Port %d is already in use. Please shutdown the service "95 + "listening on this port or configure a different port%s.", port, message);96 boolean free = false;97 try {98 free = PortProber.pollPort(port);99 } catch (RuntimeException e) {100 throw new IllegalArgumentException(portInUseError, e);101 } finally {102 if (!free) {103 throw new IllegalArgumentException(portInUseError);104 }105 }106 }107 /*108 * Waits for the launcher to initialize. This code exists purely to give the launcher more time to download109 * dependencies. Otherwise, it is not needed since RunnableLauncher#isRunning() _should_ check for isInitialized()110 * at method entry.111 */112 private void waitForInitialization(long timeout) {113 LOGGER.entering();114 long time = 0;115 while (!getLauncher().isInitialized() && (time < timeout)) {116 try {117 // SeLion Grid could still be downloading dependencies.. Wait for it.118 Thread.sleep(1000);119 time += 1000;120 } catch (InterruptedException e) {121 throw new IllegalStateException(e.getMessage(), e);122 }123 }124 if (time == timeout) {125 throw new IllegalStateException(String.format("Timed out waiting for %s to initialize.",126 getLocalServerComponent().getClass().getSimpleName()));127 }128 LOGGER.exiting();129 }130 /**131 * Checks component has come up every 3 seconds. Waits for the component for a maximum of 60 seconds. Throws an132 * {@link IllegalStateException} if the component can not be contacted133 */134 private void waitForComponentToComeUp() {135 LOGGER.entering();136 for (int i = 0; i < 60; i++) {137 try {138 // Sleep for 3 seconds.139 Thread.sleep(1000);140 } catch (InterruptedException e) {141 throw new IllegalStateException(e.getMessage(), e);142 }143 if (getLauncher().isRunning()) {144 LOGGER.exiting();145 return;146 }147 }148 throw new IllegalStateException(String.format("%s can not be contacted.", getLocalServerComponent().getClass()149 .getSimpleName()));150 }151 /**152 * Set the host for the local server component153 * 154 * @param host155 * the host156 */157 void setHost(String host) {158 getLocalServerComponent().host = host;159 }160 /**161 * Set the port for the local server component162 * 163 * @param port164 * the port165 */166 void setPort(int port) {167 getLocalServerComponent().port = port;168 }169 /**170 * Set the launcher for the local server component171 * 172 * @param launcher173 * the {@link RunnableLauncher}174 */175 void setLauncher(RunnableLauncher launcher) {176 getLocalServerComponent().launcher = launcher;177 }178 /**179 * Set the {@link ExecutorService} for the local server component180 * 181 * @param executor182 * the {@link ExecutorService}183 */184 void setExecutor(ExecutorService executor) {185 getLocalServerComponent().executor = executor;186 }187 /**188 * @return the {@link ExecutorService} for the local server component189 */190 ExecutorService getExecutor() {191 return getLocalServerComponent().executor;192 }193 /**194 * @return the port used for the {@link LocalServerComponent}195 */196 public int getPort() {197 return getLocalServerComponent().port;198 }199 /**200 * @return the host used for the {@link LocalServerComponent}201 */202 public String getHost() {203 return getLocalServerComponent().host;204 }205 /**206 * @return the {@link RunnableLauncher} used for the {@link LocalServerComponent}o207 */208 public RunnableLauncher getLauncher() {209 return getLocalServerComponent().launcher;210 }211}...

Full Screen

Full Screen

getLauncher

Using AI Code Generation

copy

Full Screen

1Launcher launcher = getLauncher();2Launcher launcher = getLauncher();3Launcher launcher = getLauncher();4Launcher launcher = getLauncher();5Launcher launcher = getLauncher();6Launcher launcher = getLauncher();7Launcher launcher = getLauncher();8Launcher launcher = getLauncher();9Launcher launcher = getLauncher();10Launcher launcher = getLauncher();11Launcher launcher = getLauncher();12Launcher launcher = getLauncher();13Launcher launcher = getLauncher();

Full Screen

Full Screen

getLauncher

Using AI Code Generation

copy

Full Screen

1Launcher launcher = server.getLauncher();2launcher.start();3launcher.stop();4public AbstractBaseLocalServerComponent()5public void start()6public void stop()7public boolean isRunning()8public Launcher getLauncher()

Full Screen

Full Screen

getLauncher

Using AI Code Generation

copy

Full Screen

1LocalServerComponent server = LocalServerComponent.getLauncher( AppiumIOSDriver.class);2server.start();3server.stop();4server.restart();5server.getStatus();6server.getLocation();7LocalServerComponent server = LocalServerComponent.getLauncher( AppiumAndroidDriver.class);8server.start();9server.stop();10server.restart();11server.getStatus();12server.getLocation();13LocalServerComponent server = LocalServerComponent.getLauncher( AppiumIOSDriver.class);14server.start();15server.stop();16server.restart();17server.getStatus();18server.getLocation();19LocalServerComponent server = LocalServerComponent.getLauncher( AppiumAndroidDriver.class);20server.start();21server.stop();22server.restart();23server.getStatus();24server.getLocation();25LocalServerComponent server = LocalServerComponent.getLauncher( AppiumIOSDriver.class);26server.start();27server.stop();28server.restart();29server.getStatus();30server.getLocation();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in AbstractBaseLocalServerComponent

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful