Search in sources :

Example 1 with MavenArtifactUrlReference

use of org.ops4j.pax.exam.options.MavenArtifactUrlReference in project aries by apache.

the class QuiesceBlogSampleWithEbaTest method test.

@Test
public void test() throws Exception {
    resolveBundles();
    MavenArtifactUrlReference eba = CoreOptions.maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jpa.eba").versionAsInProject().type("eba");
    AriesApplicationContext ctx = installEba(eba);
    /* Find and check all the blog sample bundles */
    Bundle bapi = assertBundleStarted("org.apache.aries.samples.blog.api");
    Bundle bweb = assertBundleStarted("org.apache.aries.samples.blog.web");
    Bundle bbiz = assertBundleStarted("org.apache.aries.samples.blog.biz");
    Bundle bper = assertBundleStarted("org.apache.aries.samples.blog.persistence.jpa");
    Bundle bds = assertBundleStarted("org.apache.aries.samples.blog.datasource");
    Bundle txs = assertBundleStarted("org.apache.aries.transaction.manager");
    assertBlogServicesStarted();
    checkBlogWebAccess();
    //So Blog is working properly, let's quiesce it, we would expect to get a JPA and a Blueprint 
    //participant
    quiesceMgr.quiesce(500, Collections.singletonList(bapi));
    Thread.sleep(1000);
    // Blog api bundle should now be stopped, but others should still be running
    assertResolved(bapi);
    assertActive(bweb);
    assertActive(bbiz);
    assertActive(bper);
    quiesceMgr.quiesce(500, Arrays.asList(bapi, bweb, bbiz, bper));
    Thread.sleep(1000);
    // All blog bundles should now be stopped
    assertResolved(bapi);
    assertResolved(bweb);
    assertResolved(bbiz);
    assertResolved(bper);
    // Check we can start them again after quiesce and everything works as before
    bapi.start();
    bweb.start();
    bbiz.start();
    bper.start();
    assertBlogServicesStarted();
    assertBlogServicesStarted();
    System.out.println("Checking if blog works again after restart");
    checkBlogWebAccess();
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) Bundle(org.osgi.framework.Bundle) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Test(org.junit.Test)

Example 2 with MavenArtifactUrlReference

use of org.ops4j.pax.exam.options.MavenArtifactUrlReference in project karaf by apache.

the class KarafTestSupport method config.

@Configuration
public Option[] config() {
    MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").versionAsInProject().type("tar.gz");
    String httpPort = Integer.toString(getAvailablePort(Integer.parseInt(MIN_HTTP_PORT), Integer.parseInt(MAX_HTTP_PORT)));
    String rmiRegistryPort = Integer.toString(getAvailablePort(Integer.parseInt(MIN_RMI_REG_PORT), Integer.parseInt(MAX_RMI_REG_PORT)));
    String rmiServerPort = Integer.toString(getAvailablePort(Integer.parseInt(MIN_RMI_SERVER_PORT), Integer.parseInt(MAX_RMI_SERVER_PORT)));
    String sshPort = Integer.toString(getAvailablePort(Integer.parseInt(MIN_SSH_PORT), Integer.parseInt(MAX_SSH_PORT)));
    return new Option[] { //KarafDistributionOption.debugConfiguration("8889", true),
    karafDistributionConfiguration().frameworkUrl(karafUrl).name("Apache Karaf").unpackDirectory(new File("target/exam")), // enable JMX RBAC security, thanks to the KarafMBeanServerBuilder
    configureSecurity().disableKarafMBeanServerBuilder(), configureConsole().ignoreLocalConsole(), keepRuntimeFolder(), logLevel(LogLevel.INFO), mavenBundle().groupId("org.awaitility").artifactId("awaitility").versionAsInProject(), mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(), replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", getConfigFile("/etc/org.ops4j.pax.logging.cfg")), editConfigurationFilePut("etc/org.apache.karaf.features.cfg", "updateSnapshots", "none"), editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", httpPort), editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort), editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort), editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort), editConfigurationFilePut("etc/system.properties", "spring31.version", System.getProperty("spring31.version")), editConfigurationFilePut("etc/system.properties", "spring32.version", System.getProperty("spring32.version")), editConfigurationFilePut("etc/system.properties", "spring40.version", System.getProperty("spring40.version")), editConfigurationFilePut("etc/system.properties", "spring41.version", System.getProperty("spring41.version")), editConfigurationFilePut("etc/system.properties", "spring42.version", System.getProperty("spring42.version")), editConfigurationFilePut("etc/system.properties", "spring43.version", System.getProperty("spring43.version")) };
}
Also used : Option(org.ops4j.pax.exam.Option) KarafDistributionOption.replaceConfigurationFile(org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile) File(java.io.File) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Configuration(org.ops4j.pax.exam.Configuration) KarafDistributionOption.karafDistributionConfiguration(org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration)

Example 3 with MavenArtifactUrlReference

use of org.ops4j.pax.exam.options.MavenArtifactUrlReference in project aries by apache.

the class TwitterTest method testTwitter.

/**
	 * Test for ARIES-461
	 * Application that bring in dependency bundles from a bundle repository doesn't deploy
	 * 
	 * @throws Exception
	 */
@Test
public void testTwitter() throws Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    deleteRepos();
    MavenArtifactUrlReference twitterEbaUrl = maven("org.apache.aries.samples.twitter", "org.apache.aries.samples.twitter.eba").versionAsInProject().type("eba");
    MavenArtifactUrlReference twitterCommonLangJar = maven("commons-lang", "commons-lang").versionAsInProject();
    MavenArtifactUrlReference twitterJar = maven("org.apache.aries.samples.twitter", "org.apache.aries.samples.twitter.twitter4j").versionAsInProject();
    // add the repository xml to the repository admin
    String repositoryXML = getRepoContent("/obr/twitter/TwitterRepository.xml");
    // replace the jar file url with the real url related to the environment
    String repo = repositoryXML.replaceAll("commons.lang.location", twitterCommonLangJar.getURL()).replaceAll("twitter4j.location", twitterJar.getURL());
    URL url = getRepoUrl(repo);
    repositoryAdmin.addRepository(url);
    AriesApplication app = manager.createApplication(new URL(twitterEbaUrl.getURL()));
    app = manager.resolve(app);
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
    Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
    Collection<DeploymentContent> appContent = depMeta.getApplicationDeploymentContents();
    // We cannot be sure whether there are two or three provision bundles pulled in by Felix OBR as there is an outstanding defect
    // https://issues.apache.org/jira/browse/FELIX-2672
    // The workaround is to check we get the two bundles we are looking for, instead of insisting on just having two bundles.
    List<String> provisionBundleSymbolicNames = new ArrayList<String>();
    for (DeploymentContent dep : provision) {
        provisionBundleSymbolicNames.add(dep.getContentName());
    }
    String provision_bundle1 = "org.apache.commons.lang";
    String provision_bundle2 = "twitter4j";
    assertTrue("Bundle " + provision_bundle1 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle1));
    assertTrue("Bundle " + provision_bundle2 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle2));
    assertEquals(useBundles.toString(), 0, useBundles.size());
    assertEquals(appContent.toString(), 1, appContent.size());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplication(org.apache.aries.application.management.AriesApplication) ArrayList(java.util.ArrayList) URL(java.net.URL) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) DeploymentContent(org.apache.aries.application.DeploymentContent) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 4 with MavenArtifactUrlReference

use of org.ops4j.pax.exam.options.MavenArtifactUrlReference in project aries by apache.

the class JdbcBlogSampleWithEbaTest method test.

@Test
public void test() throws Exception {
    MavenArtifactUrlReference eba = maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jdbc.eba").versionAsInProject().type("eba");
    AriesApplicationContext ctx = installEba(eba);
    /* Check that the Blog Sample bundles are present an started */
    assertBundleStarted("org.apache.aries.samples.blog.api");
    assertBundleStarted("org.apache.aries.samples.blog.web");
    assertBundleStarted("org.apache.aries.samples.blog.biz");
    assertBundleStarted("org.apache.aries.samples.blog.persistence.jdbc");
    assertBlogServicesStarted();
    checkBlogWebAccess();
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Test(org.junit.Test)

Example 5 with MavenArtifactUrlReference

use of org.ops4j.pax.exam.options.MavenArtifactUrlReference in project aries by apache.

the class JpaBlogSampleWithEbaTest method test.

@Test
public void test() throws Exception {
    MavenArtifactUrlReference eba = maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jpa.eba").versionAsInProject().type("eba");
    AriesApplicationContext ctx = installEba(eba);
    /* Find and check all the blog sample bundles */
    assertBundleStarted("org.apache.aries.samples.blog.api");
    assertBundleStarted("org.apache.aries.samples.blog.web");
    assertBundleStarted("org.apache.aries.samples.blog.biz");
    assertBundleStarted("org.apache.aries.samples.blog.persistence.jpa");
    assertBundleStarted("org.apache.aries.samples.blog.datasource");
    assertBundleStarted("org.apache.aries.transaction.manager");
    assertBlogServicesStarted();
    checkBlogWebAccess();
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Test(org.junit.Test)

Aggregations

MavenArtifactUrlReference (org.ops4j.pax.exam.options.MavenArtifactUrlReference)6 AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)4 Test (org.junit.Test)4 File (java.io.File)2 URL (java.net.URL)2 Option (org.ops4j.pax.exam.Option)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 DeploymentContent (org.apache.aries.application.DeploymentContent)1 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)1 AriesApplication (org.apache.aries.application.management.AriesApplication)1 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)1 Configuration (org.ops4j.pax.exam.Configuration)1 KarafDistributionOption.karafDistributionConfiguration (org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration)1 KarafDistributionOption.replaceConfigurationFile (org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile)1 LogLevelOption (org.ops4j.pax.exam.karaf.options.LogLevelOption)1 Handle (org.ops4j.store.Handle)1 TemporaryStore (org.ops4j.store.intern.TemporaryStore)1 Bundle (org.osgi.framework.Bundle)1