Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions karaf/apache-brooklyn/src/main/resources/etc/org.ops4j.pax.web.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# TODO use the PortService - ${port:8081,8200}
org.osgi.service.http.port=8081

4 changes: 3 additions & 1 deletion karaf/features/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@

<feature>brooklyn-camp-base</feature>
<feature>brooklyn-utils-rest-swagger</feature>
<feature>jetty</feature> <!-- TODO: pax-jetty??? -->
<feature>pax-jetty</feature>
</feature>

<feature name="brooklyn-rest-resources" version="${project.version}" description="Brooklyn REST Resources">
Expand All @@ -188,6 +188,8 @@
</feature>

<feature name="brooklyn-jsgui" version="${project.version}" description="Brooklyn REST JavaScript Web GUI">
<feature>pax-jetty</feature> <!-- jaas bundle -->
<bundle>mvn:org.apache.brooklyn/brooklyn-karaf-jetty-config/${project.version}</bundle>
<bundle>mvn:org.apache.brooklyn/brooklyn-jsgui/${project.version}/war</bundle>
<feature>war</feature>
</feature>
Expand Down
47 changes: 42 additions & 5 deletions karaf/itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<relativePath>../pom.xml</relativePath>
</parent>

<properties>
<includedTestGroups />
<excludedTestGroups>org.apache.brooklyn.test.IntegrationTest</excludedTestGroups>
</properties>

<dependencies>
<!-- Pax Exam Dependencies -->
<dependency>
Expand Down Expand Up @@ -154,6 +159,15 @@
</dependency>

<!-- project deps -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>brooklyn-features</artifactId>
<version>${project.version}</version>
<type>xml</type>
<classifier>features</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apache-brooklyn</artifactId>
Expand All @@ -167,6 +181,12 @@
<version>${geronimo-jta_1.1_spec.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>brooklyn-rest-resources</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>brooklyn-rest-resources</artifactId>
Expand All @@ -180,14 +200,20 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.tinybundles</groupId>
<artifactId>tinybundles</artifactId>
<version>${tinybundles.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
Expand All @@ -211,12 +237,23 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
</systemPropertyVariables>
<groups>${includedTestGroups}</groups>
<excludedGroups>${excludedTestGroups}</excludedGroups>
<systemPropertyVariables>
<org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
</systemPropertyVariables>
</configuration>
</plugin>

</plugins>
</build>

<profiles>
<profile>
<id>Integration</id>
<properties>
<includedTestGroups>org.apache.brooklyn.test.IntegrationTest</includedTestGroups>
<excludedTestGroups />
</properties>
</profile>
</profiles>
</project>
59 changes: 7 additions & 52 deletions karaf/itest/src/test/java/org/apache/brooklyn/AssemblyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,9 @@
*/
package org.apache.brooklyn;

import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.inject.Inject;

Expand All @@ -42,16 +31,15 @@
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.framework.BundleContext;

/**
* Tests the apache-brooklyn karaf runtime assembly.
*
* Keeping it a non-integration test so we have at least a basic OSGi sanity check. (takes 14 sec)
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
Expand All @@ -73,43 +61,10 @@ public class AssemblyTest {

@Configuration
public static Option[] configuration() throws Exception {
return new Option[]{
karafDistributionConfiguration()
.frameworkUrl(brooklynKarafDist())
.unpackDirectory(new File("target/paxexam/unpack/"))
.useDeployFolder(false),
configureConsole().ignoreLocalConsole(),
logLevel(LogLevel.INFO),
keepRuntimeFolder(),
features(karafStandardFeaturesRepository(), "eventadmin"),
junitBundles()
};
}

public static MavenArtifactUrlReference brooklynKarafDist() {
return maven()
.groupId("org.apache.brooklyn")
.artifactId("apache-brooklyn")
.type("zip")
.versionAsInProject();
}

public static MavenUrlReference karafStandardFeaturesRepository() {
return maven()
.groupId("org.apache.karaf.features")
.artifactId("standard")
.type("xml")
.classifier("features")
.versionAsInProject();
}

public static MavenUrlReference brooklynFeaturesRepository() {
return maven()
.groupId("org.apache.brooklyn")
.artifactId("brooklyn-features")
.type("xml")
.classifier("features")
.versionAsInProject();
return defaultOptionsWith(
// Uncomment this for remote debugging the tests on port 5005
// KarafDistributionOption.debugConfiguration()
);
}

@Test
Expand Down
80 changes: 80 additions & 0 deletions karaf/itest/src/test/java/org/apache/brooklyn/KarafTestUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.brooklyn;

import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;

import java.io.File;

import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.options.MavenUrlReference;

import com.google.common.collect.ObjectArrays;

public class KarafTestUtils {
public static final Option[] DEFAULT_OPTIONS = {
karafDistributionConfiguration()
.frameworkUrl(brooklynKarafDist())
.unpackDirectory(new File("target/paxexam/unpack/"))
.useDeployFolder(false),
configureConsole().ignoreLocalConsole(),
logLevel(LogLevel.INFO),
features(karafStandardFeaturesRepository(), "eventadmin"),
junitBundles()
};

public static MavenUrlReference karafStandardFeaturesRepository() {
return maven()
.groupId("org.apache.karaf.features")
.artifactId("standard")
.type("xml")
.classifier("features")
.version(asInProject());
}


public static MavenArtifactUrlReference brooklynKarafDist() {
return maven()
.groupId("org.apache.brooklyn")
.artifactId("apache-brooklyn")
.type("zip")
.version(asInProject());
}

public static Option[] defaultOptionsWith(Option... options) {
return ObjectArrays.concat(DEFAULT_OPTIONS, options, Option.class);
}

public static MavenUrlReference brooklynFeaturesRepository() {
return maven()
.groupId("org.apache.brooklyn")
.artifactId("brooklyn-features")
.type("xml")
.classifier("features")
.versionAsInProject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
*/
package org.apache.brooklyn.rest;

import java.io.File;
import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;

import java.util.concurrent.Callable;
import org.apache.brooklyn.AssemblyTest;
import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;

import org.apache.brooklyn.KarafTestUtils;
import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.http.HttpAsserts;
import org.apache.brooklyn.util.http.HttpTool;
Expand All @@ -31,15 +34,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;

Expand All @@ -53,22 +49,12 @@ public class BrooklynRestApiLauncherTest {

@Configuration
public static Option[] configuration() throws Exception {
return new Option[]{
karafDistributionConfiguration()
.frameworkUrl(AssemblyTest.brooklynKarafDist())
.unpackDirectory(new File("target/paxexam/unpack/"))
.useDeployFolder(false),
return defaultOptionsWith(
editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", HTTP_PORT),
configureConsole().ignoreLocalConsole(),
logLevel(LogLevelOption.LogLevel.INFO),
// features(AssemblyTest.karafStandardFeaturesRepository(), "eventadmin"),
features(AssemblyTest.brooklynFeaturesRepository(), "brooklyn-software-base"),
junitBundles()

// for debugging
// , keepRuntimeFolder()
// , debugConfiguration()
};
features(KarafTestUtils.brooklynFeaturesRepository(), "brooklyn-software-base")
// Uncomment this for remote debugging the tests on port 5005
// ,KarafDistributionOption.debugConfiguration()
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.brooklyn.security;

import javax.servlet.http.HttpSession;

import org.apache.brooklyn.rest.security.provider.AbstractSecurityProvider;
import org.apache.brooklyn.rest.security.provider.SecurityProvider;

public class CustomSecurityProvider extends AbstractSecurityProvider implements SecurityProvider {

@Override
public boolean authenticate(HttpSession session, String user, String password) {
return "custom".equals(user);
}

}
Loading