org.jboss.arquillian.container.spi.client.container.LifecycleException Java Examples

The following examples show how to use org.jboss.arquillian.container.spi.client.container.LifecycleException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TomEEWebappContainer.java    From tomee with Apache License 2.0 6 votes vote down vote up
protected void downloadTomcat(final File catalinaDirectory, final String tomcatVersion, final String defaultTempDir) throws LifecycleException {
    String source = null;

    try {
        int v = Integer.parseInt(tomcatVersion.substring(0, tomcatVersion.indexOf('.')));
        source = "http://archive.apache.org/dist/tomcat/tomcat-" + v + "/v" + v + "/bin/apache-tomcat-" + tomcatVersion + ".zip";
    } catch (final Exception e) {
        // no-op
    }

    if (source == null) {
        throw new LifecycleException("Unable to find URL for Tomcat " + tomcatVersion);
    }

    final File zipFile = Setup.downloadFile("org.apache.tomcat:tomcat:" + tomcatVersion + ":zip", source, defaultTempDir);
    Zips.unzip(zipFile, catalinaDirectory);
}
 
Example #2
Source File: TomEEContainer.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    try {
        final Socket socket = new Socket(configuration.getStopHost(), configuration.getStopPort());
        final OutputStream out = socket.getOutputStream();
        out.write((configuration.getStopCommand() + Character.toString((char) 0)).getBytes());

        waitForShutdown(socket, 10);
    } catch (final Exception e) {
        throw new LifecycleException("Unable to stop TomEE", e);
    } finally {
        if (this.configuration.isUnsafeEjbd() && "-".equals(System.getProperty("tomee.serialization.class.blacklist"))) {
            System.clearProperty("tomee.serialization.class.blacklist");
        }
    }
}
 
Example #3
Source File: JettyAppServer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    try {
        server.stop();
    } catch (Exception e) {
        throw new LifecycleException("Unable to stop Jetty", e);
    }
    log.info("App Server stopped.");
}
 
Example #4
Source File: KeycloakOnUndertow.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    if (isRemoteMode()) {
        log.info("Skip stopping undertow. We are in remote mode");
        return;
    }

    log.info("Stopping auth server.");
    sessionFactory.close();
    undertow.stop();
}
 
Example #5
Source File: CustomFuseContainer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void destroyKarafProcess() throws LifecycleException {
    if (process != null) {
        process.destroy();
        try {
            process.waitFor();
        } catch (InterruptedException e) {
            throw new LifecycleException("Cannot start Karaf container", e);
        }
    }
}
 
Example #6
Source File: CustomFuseContainer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    try {
        super.stop();
    } catch (LifecycleException ex) {
        log.info("Couldn't uninstall arquillian bundle. This should be non-blocking issue, proceeding with destroying karaf process.");
    }

    destroyKarafProcess();
}
 
Example #7
Source File: KeycloakQuarkusServerDeployableContainer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    container.destroy();
    try {
        container.waitFor(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        container.destroyForcibly();
    }
}
 
Example #8
Source File: KeycloakQuarkusServerDeployableContainer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws LifecycleException {
    try {
        container = startContainer();
        waitForReadiness();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #9
Source File: AuthServerTestEnricher.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void startAuthContainer(@Observes(precedence = 0) StartSuiteContainers event) {
    //frontend-only (either load-balancer or auth-server)
    log.debug("Starting auth server before suite");

    try {
        startContainerEvent.fire(new StartContainer(suiteContext.getAuthServerInfo().getArquillianContainer()));
    } catch (Exception e) {
        // It is expected that server startup fails with migration-mode-manual
        if (e instanceof LifecycleException && handleManualMigration()) {
            log.info("Set log file checker to end of file.");
            try {
                // this will mitigate possible issues in manual server update tests
                // when the auth server started with not updated DB
                // e.g. Caused by: org.keycloak.ServerStartupError: Database not up-to-date, please migrate database with
                if (suiteContext.getServerLogChecker() == null) {
                    setServerLogChecker();
                }
                suiteContext.getServerLogChecker()
                    .updateLastCheckedPositionsOfAllFilesToEndOfFile();
            } catch (IOException ioe) {
                log.warn("Server log checker failed to update position:", ioe);
            }
            log.info("Starting server again after manual DB migration was finished");
            startContainerEvent.fire(new StartContainer(suiteContext.getAuthServerInfo().getArquillianContainer()));
            return;
        }

        // Just re-throw the exception
        throw e;
    }
}
 
Example #10
Source File: RemoteTomEEContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    ArquillianUtil.undeploy(this, containerArchives);

    // only stop the container if we started it
    if (shutdown) {
        try {
            Setup.removeArquillianBeanDiscoverer(tomeeHome);
            container.destroy();
        } finally {
            resetSerialization();
        }
    }
}
 
Example #11
Source File: EmbeddedTomEEContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    try {
        this.container.stop();
    } catch (final Exception e) {
        throw new LifecycleException("Unable to stop server", e);
    } finally {
        resetSerialization();
    }
}
 
Example #12
Source File: EmbeddedTomEEContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws LifecycleException {
    try {
        this.container.start();
        SystemInstance.get().setComponent(AdditionalBeanDiscoverer.class, new TestClassDiscoverer());
        // this property is not mandatory by default but depending the protocol it can be relevant so adding it by default
        SystemInstance.get().setProperty("org.apache.openejb.servlet.filters", ArquillianFilterRunner.class.getName() + "=/ArquillianServletRunner");
    } catch (final Exception e) {
        throw new LifecycleException("Something went wrong", e);
    }
}
 
Example #13
Source File: TomEEWebappContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    // only stop the container if we started it
    if (shutdown) {
        try {
            Setup.removeArquillianBeanDiscoverer(openejbHome);
            container.destroy();
        } finally {
            resetSerialization();
        }
    }
}
 
Example #14
Source File: FurnaceDeployableContainer.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private void cleanup()
{
   try
   {
      stop();
      start();
   }
   catch (LifecycleException e)
   {
      throw new RuntimeException("Failed to clean up after test case.", e);
   }
}
 
Example #15
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public void stop() throws LifecycleException {
    lifecycle(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            delegate.stop();
            return null;
        }
    });
}
 
Example #16
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public void start() throws LifecycleException {
    lifecycle(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            delegate.start();
            return null;
        }
    });
}
 
Example #17
Source File: WildFlySwarmContainer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    BootstrapUtil.convertSwarmSystemPropertiesToThorntail();

    StartupTimeout startupTimeout = this.testClass.getAnnotation(StartupTimeout.class);
    if (startupTimeout != null) {
        setTimeout(startupTimeout.value());
    }

    this.delegateContainer = new UberjarSimpleContainer(this.containerContext.get(), this.deploymentContext.get(), this.testClass);

    try {
        this.delegateContainer
                .setJavaVmArguments(this.getJavaVmArguments())
                .requestedMavenArtifacts(this.requestedMavenArtifacts)
                .start(archive);
        // start wants to connect to the remote container, which isn't up until now, so
        // we override start above and call it here instead
        super.start();

        ProtocolMetaData metaData = new ProtocolMetaData();
        metaData.addContext(createDeploymentContext(archive.getId()));

        return metaData;
    } catch (Throwable e) {
        if (e instanceof LifecycleException) {
            e = e.getCause();
        }
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
Example #18
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public void setup(final ContainerConfiguration configuration) throws LifecycleException {
    lifecycle(new Callable<Void>() {
        @SuppressWarnings("unchecked")
        @Override
        public Void call() throws Exception {
            delegate.setup(configuration);
            return null;
        }
    });
}
 
Example #19
Source File: DaemonDeployableContainerBase.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws LifecycleException {
    // Open up remote resources
    try {

        final long startTime = System.currentTimeMillis();
        final int secondsToWait = this.timeout;
        final long acceptableTime = startTime + 1000 * secondsToWait; // 10 seconds from now
        Socket socket = null;
        while (true) {
            try {
                // TODO Security Action
                socket = new Socket(remoteAddress.getHostString(), remoteAddress.getPort());
                if (log.isLoggable(Level.FINEST)) {
                    log.finest("Got connection to " + remoteAddress.toString());
                }
                break;
            } catch (final ConnectException ce) {
                if (log.isLoggable(Level.FINEST)) {
                    log.finest("No connection yet available to remote process");
                }
                final long currentTime = System.currentTimeMillis();
                // Time expired?
                if (currentTime > acceptableTime) {
                    throw new LifecycleException("Could not connect to the server at "
                                                         + remoteAddress.getHostString() + ":" + remoteAddress.getPort() + " in the allotted "
                                                         + secondsToWait + "s", ce);
                }
                // Sleep and try again
                try {
                    Thread.sleep(200);
                } catch (final InterruptedException e) {
                    Thread.interrupted();
                    throw new RuntimeException("No one should be interrupting us while we're waiting to connect", e);
                }
            }
        }
        assert socket != null : "Socket should have been connected";
        this.socket = socket;
        final OutputStream socketOutstream = socket.getOutputStream();
        this.socketOutstream = socketOutstream;
        final PrintWriter writer = new PrintWriter(new OutputStreamWriter(socketOutstream, WireProtocol.CHARSET),
                                                   true);
        this.writer = writer;
        final InputStream socketInstream = socket.getInputStream();
        this.socketInstream = socketInstream;
        final BufferedReader reader = new BufferedReader(new InputStreamReader(socketInstream));
        this.reader = reader;

        final StringBuilder builder = new StringBuilder();
        builder.append(WireProtocol.COMMAND_CHECK_DEPLOYMENT);
        builder.append(WireProtocol.COMMAND_EOF_DELIMITER);
        final String checkCommand = builder.toString();
        // Request
        writer.write(checkCommand);
        writer.flush();

        Throwable error = null;
        try {
            final ObjectInputStream response = new ObjectInputStream(socketInstream);
            error = (Throwable) response.readObject();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        if (error != null) {
            throw new LifecycleException(error.getMessage(), error);
        }
    } catch (final IOException ioe) {
        this.closeRemoteResources();
        throw new LifecycleException("Could not open connection to remote process", ioe);
    }

}
 
Example #20
Source File: ManagedSEDeployableContainer.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws LifecycleException {
}
 
Example #21
Source File: UndertowAppServer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    undertow.stop();
    log.info("App Server stopped.");
}
 
Example #22
Source File: SimpleUndertowLoadBalancerContainer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    log.info("Going to stop loadbalancer");
    this.container.stop();
}
 
Example #23
Source File: SimpleUndertowLoadBalancerContainer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws LifecycleException {
    this.container = new SimpleUndertowLoadBalancer(configuration.getBindAddress(), configuration.getBindHttpPort(), configuration.getBindHttpsPort(), configuration.getNodes());
    this.container.start();
}
 
Example #24
Source File: ManagedSEDeployableContainer.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws LifecycleException {
}
 
Example #25
Source File: QuarkusDeployableContainer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws LifecycleException {
    // No-op
}
 
Example #26
Source File: QuarkusDeployableContainer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    // No-op
}
 
Example #27
Source File: ExportImportTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private void testRealmExportImport() throws LifecycleException {
    testingClient.testing().exportImport().setAction(ExportImportConfig.ACTION_EXPORT);
    testingClient.testing().exportImport().setRealmName("test");

    testingClient.testing().exportImport().runExport();

    List<ComponentRepresentation> components = adminClient.realm("test").components().query();
    KeysMetadataRepresentation keyMetadata = adminClient.realm("test").keys().getKeyMetadata();
    String sampleRealmRoleId = adminClient.realm("test").roles().get("sample-realm-role").toRepresentation().getId();
    Map<String, List<String>> roleAttributes = adminClient.realm("test").roles().get("attribute-role").toRepresentation().getAttributes();
    String testAppId = adminClient.realm("test").clients().findByClientId("test-app").get(0).getId();
    String sampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
    String sampleClientRoleAttribute = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getAttributes().get("sample-client-role-attribute").get(0);

    // Delete some realm (and some data in admin realm)
    adminClient.realm("test").remove();

    Assert.assertNames(adminClient.realms().findAll(), "test-realm", "master");

    assertNotAuthenticated("test", "test-user@localhost", "password");
    assertNotAuthenticated("test", "user1", "password");
    assertNotAuthenticated("test", "user2", "password");
    assertNotAuthenticated("test", "user3", "password");
    assertNotAuthenticated("test", "user-requiredOTP", "password");
    assertNotAuthenticated("test", "user-requiredWebAuthn", "password");

    // Configure import
    testingClient.testing().exportImport().setAction(ExportImportConfig.ACTION_IMPORT);

    testingClient.testing().exportImport().runImport();

    // Ensure data are imported back, but just for "test" realm
    Assert.assertNames(adminClient.realms().findAll(), "master", "test", "test-realm");

    assertAuthenticated("test", "test-user@localhost", "password");
    assertAuthenticated("test", "user1", "password");
    assertAuthenticated("test", "user2", "password");
    assertAuthenticated("test", "user3", "password");
    assertAuthenticated("test", "user-requiredOTP", "password");
    assertAuthenticated("test", "user-requiredWebAuthn", "password");

    RealmResource testRealmRealm = adminClient.realm("test");
    assertTrue(testRealmRealm.users().search("user-requiredOTP").get(0)
            .getRequiredActions().get(0).equals(UserModel.RequiredAction.CONFIGURE_TOTP.name()));
    assertTrue(testRealmRealm.users().search("user-requiredWebAuthn").get(0)
            .getRequiredActions().get(0).equals(WebAuthnRegisterFactory.PROVIDER_ID));


    List<ComponentRepresentation> componentsImported = adminClient.realm("test").components().query();
    assertComponents(components, componentsImported);

    KeysMetadataRepresentation keyMetadataImported = adminClient.realm("test").keys().getKeyMetadata();
    assertEquals(keyMetadata.getActive(), keyMetadataImported.getActive());

    String importedSampleRealmRoleId = adminClient.realm("test").roles().get("sample-realm-role").toRepresentation().getId();
    assertEquals(sampleRealmRoleId, importedSampleRealmRoleId);

    Map<String, List<String>> importedRoleAttributes = adminClient.realm("test").roles().get("attribute-role").toRepresentation().getAttributes();
    Assert.assertRoleAttributes(roleAttributes, importedRoleAttributes);

    String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
    assertEquals(sampleClientRoleId, importedSampleClientRoleId);

    String importedSampleClientRoleAttribute = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getAttributes().get("sample-client-role-attribute").get(0);
    assertEquals(sampleClientRoleAttribute, importedSampleClientRoleAttribute);

    checkEventsConfig(adminClient.realm("test").getRealmEventsConfig());
}
 
Example #28
Source File: ExportImportTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private void testFullExportImport() throws LifecycleException {
    testingClient.testing().exportImport().setAction(ExportImportConfig.ACTION_EXPORT);
    testingClient.testing().exportImport().setRealmName("");

    testingClient.testing().exportImport().runExport();

    removeRealm("test");
    removeRealm("test-realm");
    Assert.assertNames(adminClient.realms().findAll(), "master");

    Map<String, RequiredActionProviderRepresentation> requiredActionsBeforeImport = new HashMap<>();
    adminClient.realm("master").flows().getRequiredActions().stream()
            .forEach(action -> {
                requiredActionsBeforeImport.put(action.getAlias(), action);
            });

    assertNotAuthenticated("test", "test-user@localhost", "password");
    assertNotAuthenticated("test", "user1", "password");
    assertNotAuthenticated("test", "user2", "password");
    assertNotAuthenticated("test", "user3", "password");
    assertNotAuthenticated("test", "user-requiredOTP", "password");
    assertNotAuthenticated("test", "user-requiredWebAuthn", "password");


    // Configure import
    testingClient.testing().exportImport().setAction(ExportImportConfig.ACTION_IMPORT);

    testingClient.testing().exportImport().runImport();

    // Ensure data are imported back
    Assert.assertNames(adminClient.realms().findAll(), "master", "test", "test-realm");

    assertAuthenticated("test", "test-user@localhost", "password");
    assertAuthenticated("test", "user1", "password");
    assertAuthenticated("test", "user2", "password");
    assertAuthenticated("test", "user3", "password");
    assertAuthenticated("test", "user-requiredOTP", "password");
    assertAuthenticated("test", "user-requiredWebAuthn", "password");

    RealmResource testRealmRealm = adminClient.realm("test");
    assertTrue(testRealmRealm.users().search("user-requiredOTP").get(0)
            .getRequiredActions().get(0).equals(UserModel.RequiredAction.CONFIGURE_TOTP.name()));
    assertTrue(testRealmRealm.users().search("user-requiredWebAuthn").get(0)
            .getRequiredActions().get(0).equals(WebAuthnRegisterFactory.PROVIDER_ID));

    // KEYCLOAK-6050 Check SMTP password is exported/imported
    assertEquals("secret", testingClient.server("test").fetch(RunHelpers.internalRealm()).getSmtpServer().get("password"));

    // KEYCLOAK-8176 Check required actions are exported/imported properly
    List<RequiredActionProviderRepresentation> requiredActionsAfterImport = adminClient.realm("master").flows().getRequiredActions();
    assertThat(requiredActionsAfterImport.size(), is(equalTo(requiredActionsBeforeImport.size())));
    requiredActionsAfterImport.stream()
            .forEach((action) -> {
                RequiredActionProviderRepresentation beforeImportAction = requiredActionsBeforeImport.get(action.getAlias());
                assertThat(action.getName(), is(equalTo(beforeImportAction.getName())));
                assertThat(action.getProviderId(), is(equalTo(beforeImportAction.getProviderId())));
                assertThat(action.getPriority(), is(equalTo(beforeImportAction.getPriority())));
            });
}
 
Example #29
Source File: ExportImportTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@After
public void clearExportImportProps() throws LifecycleException {
    clearExportImportProperties();
}
 
Example #30
Source File: PiranhaServerLoadableExtension.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void start() throws LifecycleException {
    // We don't start Piranha separately. Start and Deploy is one step.
}