You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ja...@apache.org on 2012/07/12 18:10:39 UTC
svn commit: r1360745 [2/2] - in /ace/sandbox/marrs: build/
org.apache.ace.authentication.itest/ org.apache.ace.authentication/
org.apache.ace.authenticationprocessor.basicauth/
org.apache.ace.authenticationprocessor.clientcert/
org.apache.ace.authentic...
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/Options.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/Options.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/Options.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/Options.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,277 @@
+/*
+ * 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.ace.it;
+
+
+/**
+ * This class contains a set of Pax Exam options, intended for typo-free provisioning of bundles.
+ */
+public class Options {
+// public static class Osgi {
+// public static MavenArtifactProvisionOption compendium() {
+// return maven("org.osgi.compendium");
+// }
+//
+// private static MavenArtifactProvisionOption maven(String artifactId) {
+// return Options.maven("org.osgi", artifactId);
+// }
+// }
+//
+// public static class Felix {
+// public static MavenArtifactProvisionOption preferences() {
+// return maven("org.apache.felix.prefs");
+// }
+//
+// public static MavenArtifactProvisionOption dependencyManager() {
+// return maven("org.apache.felix.dependencymanager");
+// }
+//
+// public static MavenArtifactProvisionOption configAdmin() {
+// return maven("org.apache.felix.configadmin");
+// }
+//
+// public static MavenArtifactProvisionOption eventAdmin() {
+// return maven("org.apache.felix.eventadmin");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentAdmin() {
+// return maven("org.apache.felix.deploymentadmin");
+// }
+//
+// private static MavenArtifactProvisionOption maven(String artifactId) {
+// return Options.maven("org.apache.felix", artifactId);
+// }
+// }
+//
+// public static class Ace {
+// public static WrappedUrlProvisionOption util() {
+// // we do this because we need access to some test classes that aren't exported
+// return wrappedBundle(mavenBundle("org.apache.ace", "org.apache.ace.util")).overwriteManifest(WrappedUrlProvisionOption.OverwriteMode.FULL);
+// }
+//
+// public static Option enableDebugger() {
+// return enableDebugger(true, 8787);
+// }
+//
+// public static Option enableDebugger(boolean suspend, int port) {
+// return new VMOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=" + (suspend ? "y" : "n") + ",address=" + port);
+// }
+//
+// public static MavenArtifactProvisionOption authenticationApi() {
+// return maven("org.apache.ace.authentication.api");
+// }
+//
+// public static MavenArtifactProvisionOption authentication() {
+// return maven("org.apache.ace.authentication");
+// }
+//
+// public static MavenArtifactProvisionOption authenticationProcessorBasicAuth() {
+// return maven("org.apache.ace.authenticationprocessor.basicauth");
+// }
+//
+// public static MavenArtifactProvisionOption authenticationProcessorClientCert() {
+// return maven("org.apache.ace.authenticationprocessor.clientcert");
+// }
+//
+// public static MavenArtifactProvisionOption authenticationProcessorPassword() {
+// return maven("org.apache.ace.authenticationprocessor.password");
+// }
+//
+// public static MavenArtifactProvisionOption connectionFactory() {
+// return maven("org.apache.ace.connectionfactory");
+// }
+//
+// public static MavenArtifactProvisionOption rangeApi() {
+// return maven("org.apache.ace.range.api");
+// }
+//
+// public static MavenArtifactProvisionOption discoveryApi() {
+// return maven("org.apache.ace.discovery.api");
+// }
+//
+// public static MavenArtifactProvisionOption discoveryProperty() {
+// return maven("org.apache.ace.discovery.property");
+// }
+//
+// public static MavenArtifactProvisionOption identificationApi() {
+// return maven("org.apache.ace.identification.api");
+// }
+//
+// public static MavenArtifactProvisionOption identificationProperty() {
+// return maven("org.apache.ace.identification.property");
+// }
+//
+// public static MavenArtifactProvisionOption scheduler() {
+// return maven("org.apache.ace.scheduler");
+// }
+//
+// public static MavenArtifactProvisionOption httplistener() {
+// return maven("org.apache.ace.httplistener");
+// }
+//
+// public static MavenArtifactProvisionOption repositoryApi() {
+// return maven("org.apache.ace.repository.api");
+// }
+//
+// public static MavenArtifactProvisionOption repositoryExt() {
+// return maven("org.apache.ace.repository.ext");
+// }
+//
+// public static MavenArtifactProvisionOption repositoryImpl() {
+// return maven("org.apache.ace.repository.impl");
+// }
+//
+// public static MavenArtifactProvisionOption repositoryServlet() {
+// return maven("org.apache.ace.repository.servlet");
+// }
+//
+// public static MavenArtifactProvisionOption repositoryTask() {
+// return maven("org.apache.ace.repository.task");
+// }
+//
+// public static MavenArtifactProvisionOption resourceprocessorUseradmin() {
+// return maven("org.apache.ace.resourceprocessor.useradmin");
+// }
+//
+// public static MavenArtifactProvisionOption configuratorServeruseradmin() {
+// return maven("org.apache.ace.configurator.serveruseradmin");
+// }
+//
+// public static MavenArtifactProvisionOption configuratorUseradminTask() {
+// return maven("org.apache.ace.configurator.useradmin.task");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentApi() {
+// return maven("org.apache.ace.deployment.api");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentDeploymentAdmin() {
+// return maven("org.apache.ace.deployment.deploymentadmin");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentServlet() {
+// return maven("org.apache.ace.deployment.servlet");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentTaskBase() {
+// return maven("org.apache.ace.deployment.task.base");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentTask() {
+// return maven("org.apache.ace.deployment.task");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentStreamgenerator() {
+// return maven("org.apache.ace.deployment.streamgenerator");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentProviderApi() {
+// return maven("org.apache.ace.deployment.provider.api");
+// }
+//
+// public static MavenArtifactProvisionOption deploymentProviderFilebased() {
+// return maven("org.apache.ace.deployment.provider.filebased");
+// }
+//
+// public static MavenArtifactProvisionOption log() {
+// return maven("org.apache.ace.log");
+// }
+//
+// public static MavenArtifactProvisionOption logListener() {
+// return maven("org.apache.ace.log.listener");
+// }
+//
+// public static MavenArtifactProvisionOption logServlet() {
+// return maven("org.apache.ace.log.servlet");
+// }
+//
+// public static MavenArtifactProvisionOption serverLogStore() {
+// return maven("org.apache.ace.server.log.store");
+// }
+//
+// public static MavenArtifactProvisionOption logTask() {
+// return maven("org.apache.ace.log.task");
+// }
+//
+// public static MavenArtifactProvisionOption targetLog() {
+// return maven("org.apache.ace.gateway.log"); // TODO rename!
+// }
+//
+// public static MavenArtifactProvisionOption targetLogStore() {
+// return maven("org.apache.ace.gateway.log.store"); // TODO rename!
+// }
+//
+// public static MavenArtifactProvisionOption obrMetadata() {
+// return maven("org.apache.ace.obr.metadata");
+// }
+//
+// public static MavenArtifactProvisionOption obrServlet() {
+// return maven("org.apache.ace.obr.servlet");
+// }
+//
+// public static MavenArtifactProvisionOption obrStorage() {
+// return maven("org.apache.ace.obr.storage");
+// }
+//
+// public static MavenArtifactProvisionOption clientRepositoryApi() {
+// return maven("org.apache.ace.client.repository.api");
+// }
+//
+// public static MavenArtifactProvisionOption clientRepositoryImpl() {
+// return maven("org.apache.ace.client.repository.impl");
+// }
+//
+// public static MavenArtifactProvisionOption clientRepositoryHelperBase() {
+// return maven("org.apache.ace.client.repository.helper.base");
+// }
+//
+// public static MavenArtifactProvisionOption clientRepositoryHelperBundle() {
+// return maven("org.apache.ace.client.repository.helper.bundle");
+// }
+//
+// public static MavenArtifactProvisionOption clientRepositoryHelperConfiguration() {
+// return maven("org.apache.ace.client.repository.helper.configuration");
+// }
+//
+// public static MavenArtifactProvisionOption clientAutomation() {
+// return maven("org.apache.ace.client.automation");
+// }
+//
+// public static MavenArtifactProvisionOption maven(String artifactId) {
+// return Options.maven("org.apache.ace", artifactId);
+// }
+// }
+//
+// public static class Knopflerfish {
+// public static MavenArtifactProvisionOption useradmin() {
+// return maven("org.knopflerfish.bundle", "useradmin");
+// }
+// public static MavenArtifactProvisionOption log() {
+// return maven("org.knopflerfish", "log");
+// }
+// }
+//
+// public static MavenArtifactProvisionOption jetty() {
+// return maven("org.ops4j.pax.web", "pax-web-jetty-bundle");
+// }
+//
+// private static MavenArtifactProvisionOption maven(String groupId, String artifactId) {
+// return mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+// }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/Options.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/packageinfo?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/it/packageinfo Thu Jul 12 16:10:37 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/TestConstants.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/TestConstants.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/TestConstants.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/TestConstants.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,29 @@
+/*
+ * 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.ace.test.constants;
+
+/**
+ * Constants for global test parameters. Use these throughout the test
+ * codebase. Make sure to only use public static finals here, which
+ * can be inlined by the compiler.
+ */
+public interface TestConstants {
+ /** The port the webserver is running on for testing. */
+ public static final int PORT = 9000;
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/TestConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/packageinfo?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/constants/packageinfo Thu Jul 12 16:10:37 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/FileUtils.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/FileUtils.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/FileUtils.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/FileUtils.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.ace.test.utils;
+
+import java.io.File;
+import java.io.IOException;
+
+public class FileUtils {
+
+ /**
+ * Convenience method for creating temp files.
+ * It creates a temp file, and then deletes it. This is done so the same (unique) filename can be used to create a directory.
+ *
+ * If you use null as the baseDirectoryName, a tempfile is created in the platform specific temp directory.
+ * @throws IOException
+ */
+ public static File createTempFile(File baseDirectory) throws IOException {
+ return createTempFile(baseDirectory, "");
+ }
+
+ public static File createTempFile(File baseDirectory, String extension) throws IOException {
+ File tempFile = File.createTempFile("test", extension, baseDirectory);
+ tempFile.delete();
+ return tempFile;
+ }
+
+ /**
+ * Remove the given directory and all it's files and subdirectories
+ * @param directory the name of the directory to remove
+ */
+ public static void removeDirectoryWithContent(File directory) {
+ if ((directory == null) || !directory.exists()) {
+ return;
+ }
+ File[] filesAndSubDirs = directory.listFiles();
+ for (int i=0; i < filesAndSubDirs.length; i++) {
+ File file = filesAndSubDirs[i];
+ if (file.isDirectory()) {
+ removeDirectoryWithContent(file);
+ }
+ // else just remove the file
+ file.delete();
+ }
+ directory.delete();
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/FileUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/NetUtils.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/NetUtils.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/NetUtils.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/NetUtils.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,64 @@
+/*
+ * 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.ace.test.utils;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * Class containing utility methods concerning network related stuff.
+ */
+public class NetUtils {
+
+ /**
+ * Waits for a HTTP URL to become 'available', will retry every 100 milliseconds until it is available or timeout
+ * has been exceeded. Available in this context means the specified status code is returned when accessing the URL.
+ *
+ * @param url HTTP URL that should be tested for availability.
+ * @param responseCode The response code to be expected on the specified URL when it is available.
+ * @param timeout Amount of milliseconds to keep trying to access the URL.
+ * @return True if the response of the URL has the specified status code within the specified timeout delay, false otherwise.
+ * @throws IllegalArgumentException If the specified URL does not use the HTTP protocol.
+ */
+ public static boolean waitForURL(URL url, int responseCode, int timeout) {
+ long deadline = System.currentTimeMillis() + timeout;
+ while (System.currentTimeMillis() < deadline) {
+ try {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.connect();
+ if (connection.getResponseCode() == responseCode) {
+ return true;
+ }
+ } catch (ClassCastException cce) {
+ throw new IllegalArgumentException("Expected url to be an HTTP url, not: " + url.toString(), cce);
+ }
+ catch (IOException ioe) {
+ // retry
+ }
+ try {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException ie) {
+ return false;
+ }
+ }
+ return false;
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/NetUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/TestUtils.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/TestUtils.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/TestUtils.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/TestUtils.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,166 @@
+/*
+ * 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.ace.test.utils;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * Utility class that injects dependencies. Can be used to unit test service implementations.
+ */
+public class TestUtils {
+ public static final String UNIT = "unit";
+ public static final String INTEGRATION = "integration";
+ public static final String SMOKE = "smoke";
+ public static final String PERFORMANCE = "performance";
+ public static final String UI = "ui";
+ public static final String BROKEN = "broken";
+ /**
+ * Configures an object to use a null object for the specified service interface.
+ *
+ * @param object the object
+ * @param iface the service interface
+ */
+ public static <T> void configureObject(Object object, Class<T> iface) {
+ configureObject(object, iface, createNullObject(iface));
+ }
+
+ /**
+ * Creates a null object for a service interface.
+ *
+ * @param iface the service interface
+ * @return a null object
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T createNullObject(Class<T> iface) {
+ return (T) Proxy.newProxyInstance(iface.getClassLoader(), new Class[] { iface }, new NullObject());
+ }
+
+ /**
+ * Wraps the given handler in an adapter that will try to pass on received invocations to the hander if that has
+ * an applicable methods else it defaults to a NullObject.
+ *
+ * @param iface the service interface
+ * @param handler the handler to pass invocations to.
+ * @return an adapter that will try to pass on received invocations to the given handler
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T createMockObjectAdapter(Class<T> iface, final Object handler) {
+ return (T) Proxy.newProxyInstance(iface.getClassLoader(), new Class[] { iface }, new NullObject() {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ Method bridge = handler.getClass().getMethod(method.getName(), method.getParameterTypes());
+ bridge.setAccessible(true);
+ return bridge.invoke(handler, args);
+ }
+ catch (NoSuchMethodException ex) {
+ return super.invoke(proxy, method, args);
+ }
+ catch (InvocationTargetException ex) {
+ throw ex.getCause();
+ }
+ }
+ });
+ }
+
+ /**
+ * Configures an object to use a specific implementation for the specified service interface.
+ *
+ * @param object the object
+ * @param iface the service interface
+ * @param instance the implementation
+ */
+ @SuppressWarnings("unchecked")
+ public static void configureObject(Object object, Class iface, Object instance) {
+ Class serviceClazz = object.getClass();
+
+ while (serviceClazz != null) {
+ Field[] fields = serviceClazz.getDeclaredFields();
+ AccessibleObject.setAccessible(fields, true);
+ for (int j = 0; j < fields.length; j++) {
+ if (fields[j].getType().equals(iface)) {
+ try {
+ // synchronized makes sure the field is actually written to immediately
+ synchronized (new Object()) {
+ fields[j].set(object, instance);
+ }
+ }
+ catch (Exception e) {
+ throw new IllegalStateException("Could not set field " + fields[j].getName() + " on " + object);
+ }
+ }
+ }
+ serviceClazz = serviceClazz.getSuperclass();
+ }
+ }
+
+ static class NullObject implements InvocationHandler {
+ private static final Boolean DEFAULT_BOOLEAN = Boolean.FALSE;
+
+ private static final Byte DEFAULT_BYTE = new Byte((byte) 0);
+
+ private static final Short DEFAULT_SHORT = new Short((short) 0);
+
+ private static final Integer DEFAULT_INT = new Integer(0);
+
+ private static final Long DEFAULT_LONG = new Long(0);
+
+ private static final Float DEFAULT_FLOAT = new Float(0.0f);
+
+ private static final Double DEFAULT_DOUBLE = new Double(0.0);
+
+ /**
+ * Invokes a method on this null object. The method will return a default value without doing anything.
+ */
+ @SuppressWarnings("unchecked")
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Class returnType = method.getReturnType();
+ if (returnType.equals(Boolean.class) || returnType.equals(Boolean.TYPE)) {
+ return DEFAULT_BOOLEAN;
+ }
+ else if (returnType.equals(Byte.class) || returnType.equals(Byte.TYPE)) {
+ return DEFAULT_BYTE;
+ }
+ else if (returnType.equals(Short.class) || returnType.equals(Short.TYPE)) {
+ return DEFAULT_SHORT;
+ }
+ else if (returnType.equals(Integer.class) || returnType.equals(Integer.TYPE)) {
+ return DEFAULT_INT;
+ }
+ else if (returnType.equals(Long.class) || returnType.equals(Long.TYPE)) {
+ return DEFAULT_LONG;
+ }
+ else if (returnType.equals(Float.class) || returnType.equals(Float.TYPE)) {
+ return DEFAULT_FLOAT;
+ }
+ else if (returnType.equals(Double.class) || returnType.equals(Double.TYPE)) {
+ return DEFAULT_DOUBLE;
+ }
+ else {
+ return null;
+ }
+ }
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/TestUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/Util.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/Util.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/Util.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/Util.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,38 @@
+/*
+ * 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.ace.test.utils;
+
+import java.util.Properties;
+
+public class Util {
+
+ /**
+ * Creates a Properties object from a list of key-value pairs, e.g.
+ * <pre>
+ * properties("key", "value", "key2", "value2");
+ * </pre>
+ */
+ public static Properties properties(String... values) {
+ Properties props = new Properties();
+ for (int i = 0; i < values.length; i += 2) {
+ props.put(values[i], values[i+1]);
+ }
+ return props;
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/BundleStreamGenerator.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/BundleStreamGenerator.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/BundleStreamGenerator.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/BundleStreamGenerator.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,67 @@
+/*
+ * 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.ace.test.utils.deployment;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.osgi.framework.Constants;
+
+public class BundleStreamGenerator {
+
+ public static Manifest getBundleManifest(String symbolicname, String version, Map<String, String> additionalHeaders) {
+ Manifest manifest = new Manifest();
+ manifest.getMainAttributes().putValue("Manifest-Version", "1");
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, symbolicname);
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version.toString());
+ for (Map.Entry<String, String> entry : additionalHeaders.entrySet()) {
+ manifest.getMainAttributes().putValue(entry.getKey(), entry.getValue());
+ }
+ return manifest;
+ }
+
+ public static void generateBundle(ArtifactData data, Map<String, String> additionalHeaders) throws IOException {
+ OutputStream bundleStream = null;
+ try {
+ File dataFile = new File(data.getUrl().toURI());
+ OutputStream fileStream = new FileOutputStream(dataFile);
+ bundleStream = new JarOutputStream(fileStream, getBundleManifest(data.getSymbolicName(), data.getVersion(), additionalHeaders));
+ bundleStream.flush();
+ } catch (URISyntaxException e) {
+ throw new IOException();
+ } finally {
+ if (bundleStream != null) {
+ bundleStream.close();
+ }
+ }
+ }
+
+ public static void generateBundle(ArtifactData data) throws IOException {
+ generateBundle(data, new HashMap<String, String>());
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/BundleStreamGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestData.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestData.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestData.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestData.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,85 @@
+/*
+ * 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.ace.test.utils.deployment;
+
+import java.net.URL;
+import java.util.jar.Attributes;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+
+public class TestData implements ArtifactData {
+ private final String m_fileName;
+ private final String m_symbolicName;
+ private final URL m_url;
+ private final String m_version;
+ private final boolean m_changed;
+
+ public TestData(String fileName, String symbolicName, URL url, String version, boolean changed) {
+ m_fileName = fileName;
+ m_symbolicName = symbolicName;
+ m_url = url;
+ m_version = version;
+ m_changed = changed;
+ }
+
+ public boolean hasChanged() {
+ return m_changed;
+ }
+
+ public String getFilename() {
+ return m_fileName;
+ }
+
+ public String getSymbolicName() {
+ return m_symbolicName;
+ }
+
+ public URL getUrl() {
+ return m_url;
+ }
+
+ public String getVersion() {
+ return m_version;
+ }
+
+ public String getDirective() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Attributes getManifestAttributes(boolean fixPackage) {
+ Attributes a = new Attributes();
+ a.putValue("Bundle-SymbolicName", getSymbolicName());
+ a.putValue("Bundle-Version", getVersion());
+ return a;
+ }
+
+ public String getProcessorPid() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isBundle() {
+ return true;
+ }
+
+ public boolean isCustomizer() {
+ return false;
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestData.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestProvider.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestProvider.java?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestProvider.java (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestProvider.java Thu Jul 12 16:10:37 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.ace.test.utils.deployment;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.DeploymentProvider;
+
+public class TestProvider implements DeploymentProvider {
+ private List<ArtifactData> m_collection;
+ private List<String> m_versions;
+
+ public TestProvider() throws Exception {
+ m_collection = new ArrayList<ArtifactData>();
+ m_versions = new ArrayList<String>();
+ }
+
+ public void addData(String fileName, String symbolicName, URL url, String version) {
+ addData(fileName, symbolicName, url, version, true);
+ }
+
+ public void addData(String fileName, String symbolicName, URL url, String version, boolean changed) {
+ m_collection.add(new TestData(fileName, symbolicName, url, version, changed));
+ m_versions.add(version);
+ }
+
+ public List<ArtifactData> getBundleData(String id, String version) {
+ return m_collection;
+ }
+
+ public List<ArtifactData> getBundleData(String id, String versionFrom, String versionTo) {
+ return m_collection;
+ }
+
+ public List<String> getVersions(String id) throws IllegalArgumentException {
+ Collections.sort(m_versions);
+ return m_versions;
+ }
+}
Propchange: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/TestProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/packageinfo?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/deployment/packageinfo Thu Jul 12 16:10:37 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Added: ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/packageinfo?rev=1360745&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.test/src/org/apache/ace/test/utils/packageinfo Thu Jul 12 16:10:37 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Modified: ace/sandbox/marrs/org.apache.ace.webui.vaadin/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.webui.vaadin/bnd.bnd?rev=1360745&r1=1360744&r2=1360745&view=diff
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.webui.vaadin/bnd.bnd (original)
+++ ace/sandbox/marrs/org.apache.ace.webui.vaadin/bnd.bnd Thu Jul 12 16:10:37 2012
@@ -2,7 +2,6 @@
osgi.cmpn,\
org.apache.felix.dependencymanager,\
com.vaadin,\
- org.apache.ace.util;version=latest,\
org.apache.ace.client.repository.api;version=latest,\
org.apache.ace.connectionfactory;version=latest,\
org.apache.ace.authentication.api;version=latest,\