ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1359744 - in /ace/sandbox/marrs/org.apache.ace.log.itest: ./ .settings/ src/ src/org/ src/org/apache/ src/org/apache/ace/ src/org/apache/ace/it/ src/org/apache/ace/it/log/ test/
Date Tue, 10 Jul 2012 16:06:07 GMT
Author: marrs
Date: Tue Jul 10 16:06:06 2012
New Revision: 1359744

URL: http://svn.apache.org/viewvc?rev=1359744&view=rev
Log:
Migrated the log itest.

Added:
    ace/sandbox/marrs/org.apache.ace.log.itest/
    ace/sandbox/marrs/org.apache.ace.log.itest/.classpath
    ace/sandbox/marrs/org.apache.ace.log.itest/.project
    ace/sandbox/marrs/org.apache.ace.log.itest/.settings/
    ace/sandbox/marrs/org.apache.ace.log.itest/.settings/org.eclipse.jdt.core.prefs
    ace/sandbox/marrs/org.apache.ace.log.itest/bnd.bnd
    ace/sandbox/marrs/org.apache.ace.log.itest/build.xml
    ace/sandbox/marrs/org.apache.ace.log.itest/src/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/
    ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/LogIntegrationTest.java
    ace/sandbox/marrs/org.apache.ace.log.itest/test/

Added: ace/sandbox/marrs/org.apache.ace.log.itest/.classpath
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/.classpath?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/.classpath (added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/.classpath Tue Jul 10 16:06:06 2012
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="bin_test" path="test"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: ace/sandbox/marrs/org.apache.ace.log.itest/.project
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/.project?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/.project (added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/.project Tue Jul 10 16:06:06 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.ace.log.itest</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>bndtools.core.bndbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>bndtools.core.bndnature</nature>
+	</natures>
+</projectDescription>

Added: ace/sandbox/marrs/org.apache.ace.log.itest/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/.settings/org.eclipse.jdt.core.prefs?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/.settings/org.eclipse.jdt.core.prefs (added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/.settings/org.eclipse.jdt.core.prefs Tue Jul
10 16:06:06 2012
@@ -0,0 +1,81 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6

Added: ace/sandbox/marrs/org.apache.ace.log.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/bnd.bnd?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/bnd.bnd (added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/bnd.bnd Tue Jul 10 16:06:06 2012
@@ -0,0 +1,50 @@
+Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase}
+-buildpath: junit.osgi,\
+	osgi.core,\
+	osgi.cmpn,\
+	org.apache.ace.util;version=latest,\
+	org.apache.felix.dependencymanager,\
+	org.apache.ace.itest;version=latest,\
+	org.apache.ace.log;version=latest,\
+	org.apache.ace.httplistener;version=latest,\
+	org.apache.ace.discovery.api;version=latest,\
+	org.apache.ace.discovery.property;version=latest,\
+	org.apache.ace.identification.api;version=latest,\
+	org.apache.ace.identification.property;version=latest,\
+	org.apache.ace.server.log.store;version=latest
+-runfw: org.apache.felix.framework;version='[4,5)'
+-runbundles: org.apache.ace.itest;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.itest/generated/org.apache.ace.itest.jar;version=latest,\
+	org.apache.felix.dependencymanager;resolution=file:/Users/marcel/dev/ace-bndtools/cnf/repo/org.apache.felix.dependencymanager/org.apache.felix.dependencymanager-3.1.0.jar;version='[3.1.0,3.1.1)',\
+	org.apache.ace.identification.property;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.identification.property/generated/org.apache.ace.identification.property.jar;version=latest,\
+	org.apache.felix.configadmin;resolution=http://bundles.bndtools.org.s3.amazonaws.com/org.apache.felix.configadmin/org.apache.felix.configadmin-1.2.8.jar;version='[1.2.8,1.2.9)',\
+	org.apache.ace.httplistener;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.httplistener/generated/org.apache.ace.httplistener.jar;version=latest,\
+	org.apache.ace.log.listener;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.log.listener/generated/org.apache.ace.log.listener.jar;version=latest,\
+	org.apache.ace.deployment.provider.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.deployment.provider.api/generated/org.apache.ace.deployment.provider.api.jar;version=latest,\
+	org.apache.ace.log.servlet;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.log.servlet/generated/org.apache.ace.log.servlet.jar;version=latest,\
+	org.apache.ace.gateway.log;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.gateway.log/generated/org.apache.ace.gateway.log.jar;version=latest,\
+	org.apache.ace.authentication.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.authentication.api/generated/org.apache.ace.authentication.api.jar;version=latest,\
+	org.apache.ace.discovery.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.discovery.api/generated/org.apache.ace.discovery.api.jar;version=latest,\
+	org.apache.ace.range.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.range.api/generated/org.apache.ace.range.api.jar;version=latest,\
+	org.apache.ace.discovery.property;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.discovery.property/generated/org.apache.ace.discovery.property.jar;version=latest,\
+	org.apache.ace.log.task;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.log.task/generated/org.apache.ace.log.task.jar;version=latest,\
+	org.apache.ace.log;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.log/generated/org.apache.ace.log.jar;version=latest,\
+	osgi.cmpn;resolution=http://bundles.bndtools.org.s3.amazonaws.com/osgi.cmpn/osgi.cmpn-4.2.1.jar;version='[4.2.1,4.2.2)',\
+	org.apache.ace.identification.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.identification.api/generated/org.apache.ace.identification.api.jar;version=latest,\
+	org.apache.ace.util;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.util/generated/org.apache.ace.util.jar;version=latest,\
+	org.apache.ace.resourceprocessor.useradmin;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.resourceprocessor.useradmin/generated/org.apache.ace.resourceprocessor.useradmin.jar;version=latest,\
+	org.apache.ace.gateway.log.store;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.gateway.log.store/generated/org.apache.ace.gateway.log.store.jar;version=latest,\
+	org.apache.felix.eventadmin;resolution=file:/Users/marcel/dev/ace-bndtools/cnf/repo/org.apache.felix.eventadmin/org.apache.felix.eventadmin-1.2.14.jar;version='[1.2.14,1.2.15)',\
+	org.apache.ace.authenticationprocessor.basicauth;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.authenticationprocessor.basicauth/generated/org.apache.ace.authenticationprocessor.basicauth.jar;version=latest,\
+	org.apache.ace.client.repository.helper.base;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.client.repository.helper.base/generated/org.apache.ace.client.repository.helper.base.jar;version=latest,\
+	org.apache.ace.repository.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.repository.api/generated/org.apache.ace.repository.api.jar;version=latest,\
+	org.apache.ace.client.repository.api;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.client.repository.api/generated/org.apache.ace.client.repository.api.jar;version=latest,\
+	org.apache.ace.server.log.store;resolution=file:/Users/marcel/dev/ace-bndtools/org.apache.ace.server.log.store/generated/org.apache.ace.server.log.store.jar;version=latest,\
+	org.apache.ace.connectionfactory;version=latest,\
+	javax.servlet,\
+	org.apache.felix.http.jetty,\
+	org.apache.ace.consolelogger;version=latest,\
+	org.apache.felix.shell,\
+	org.apache.felix.shell.tui,\
+	org.apache.felix.dependencymanager.shell
+Private-Package: org.apache.ace.it.log
+-runvm: -Dorg.osgi.service.http.port=9000 -ea
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.log.itest/build.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/build.xml?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/build.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/build.xml Tue Jul 10 16:06:06 2012
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build"> 
+	<import file="../cnf/build.xml"/>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/LogIntegrationTest.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/LogIntegrationTest.java?rev=1359744&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/LogIntegrationTest.java
(added)
+++ ace/sandbox/marrs/org.apache.ace.log.itest/src/org/apache/ace/it/log/LogIntegrationTest.java
Tue Jul 10 16:06:06 2012
@@ -0,0 +1,229 @@
+/*
+ * 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.log;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.ace.discovery.property.constants.DiscoveryConstants;
+import org.apache.ace.http.listener.constants.HttpConstants;
+import org.apache.ace.identification.property.constants.IdentificationConstants;
+import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.log.Log;
+import org.apache.ace.log.LogDescriptor;
+import org.apache.ace.log.LogEvent;
+import org.apache.ace.server.log.store.LogStore;
+import org.apache.ace.test.constants.TestConstants;
+import org.apache.felix.dm.Component;
+import org.osgi.framework.Constants;
+import org.osgi.service.http.HttpService;
+
+/**
+ * Integration tests for the audit log. Both a server and a target are setup
+ * on the same machine. The audit log is run and we check if it is indeed
+ * replicated to the server.
+ */
+public class LogIntegrationTest extends IntegrationTestBase {
+//    @Configuration
+//    public Option[] configuration() {
+//        return options(
+//            systemProperty("org.osgi.service.http.port").value("" + TestConstants.PORT),
+//            new VMOption("-ea"),
+//            junitBundles(),
+//            provision(
+//                Osgi.compendium(),
+//                Felix.dependencyManager(),
+//                Felix.configAdmin(),
+//                jetty(),
+//                Ace.util(),
+//                Ace.authenticationApi(),
+//                Ace.rangeApi(),
+//                Ace.discoveryApi(),
+//                Ace.discoveryProperty(),
+//                Ace.identificationApi(),
+//                Ace.identificationProperty(),
+//                Ace.httplistener(),
+//                Ace.connectionFactory(),
+//                Ace.log(),
+//                Ace.logListener(),
+//                Ace.logServlet(),
+//                Ace.serverLogStore(),
+//                Ace.logTask(),
+//                Ace.targetLog(),
+//                Ace.targetLogStore()
+//            )
+//        );
+//    }
+
+	@Override
+	protected void before() throws Exception {
+        configure(DiscoveryConstants.DISCOVERY_PID,
+                DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" + TestConstants.PORT);
+        configure(IdentificationConstants.IDENTIFICATION_PID,
+                IdentificationConstants.IDENTIFICATION_TARGETID_KEY, TARGET_ID);
+
+        configureFactory("org.apache.ace.target.log.store.factory",
+                "name", "auditlog");
+        configureFactory("org.apache.ace.target.log.factory",
+                "name", "auditlog");
+        configureFactory("org.apache.ace.target.log.sync.factory",
+            "name", "auditlog", "authentication.enabled", "false");
+
+        configure("org.apache.ace.deployment.servlet",
+                HttpConstants.ENDPOINT, DEPLOYMENT, "authentication.enabled", "false");
+
+        configureFactory("org.apache.ace.server.log.servlet.factory",
+                "name", "auditlog",
+                HttpConstants.ENDPOINT, AUDITLOG, "authentication.enabled", "false");
+        configureFactory("org.apache.ace.server.log.store.factory",
+                "name", "auditlog");
+    }
+
+    protected Component[] getDependencies() {
+        return new Component[] {
+            createComponent()
+                .setImplementation(this)
+                .add(createServiceDependency().setService(HttpService.class).setRequired(true))
+                .add(createServiceDependency().setService(Log.class, "(&("+ Constants.OBJECTCLASS+"="+Log.class.getName()+")(name=auditlog))").setRequired(true))
+                .add(createServiceDependency().setService(LogStore.class, "(&("+Constants.OBJECTCLASS+"="+LogStore.class.getName()+")(name=auditlog))").setRequired(true))
+                .add(createServiceDependency().setService(Runnable.class, "(&("+Constants.OBJECTCLASS+"="+Runnable.class.getName()+")(taskName=auditlog))").setRequired(true))
+        };
+    }
+
+    private static final String AUDITLOG = "/auditlog";
+    private static final String DEPLOYMENT = "/deployment";
+
+    public static final String HOST = "localhost";
+    public static final String TARGET_ID = "target-id";
+
+    private volatile Log m_auditLog;
+    private volatile LogStore m_serverStore;
+    private volatile Runnable m_auditLogSyncTask;
+
+    public void testLog() throws Exception {
+        doReplication();
+        doServlet();
+    }
+
+    public void doReplication() throws Exception {
+        // now log another event
+        Properties props = new Properties();
+        props.put("one", "value1");
+        props.put("two", "value2");
+        m_auditLog.log(12345, props);
+
+        boolean found = false;
+        long startTime = System.currentTimeMillis();
+        while ((!found) && (System.currentTimeMillis() - startTime < 5000)) {
+            // synchronize again
+            m_auditLogSyncTask.run();
+
+            // get and evaluate results (note that there is some concurrency that might interfere
with this test)
+            List<LogDescriptor> ranges2 = m_serverStore.getDescriptors();
+            if (ranges2.size() > 0) {
+//              assert ranges2.size() == 1 : "We should still have audit log events for one
target on the server, but found " + ranges2.size();
+                LogDescriptor range = ranges2.get(0);
+                List<LogEvent> events = m_serverStore.get(range);
+                if (events.size() > 1) {
+//                  assert events.size() > 1 : "We should have a couple of events, at
least more than the one we added ourselves.";
+                    for (LogEvent event : events) {
+                        if (event.getType() == 12345) {
+                            assert event.getProperties().get("two").equals("value2") : "We
could not retrieve a property of our audit log event.";
+                            found = true;
+                            break;
+                        }
+                    }
+                }
+            }
+
+            // wait if we have not found anything yet
+            if (!found) {
+                try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException ie)
{}
+            }
+        }
+        assert found : "We could not retrieve our audit log event (after 5 seconds).";
+    }
+
+    public void doServlet() throws Exception {
+        // prepare the store
+        List<LogEvent> events = new ArrayList<LogEvent>();
+        events.add(new LogEvent("42", 1, 1, 1, 1, new Properties()));
+        events.add(new LogEvent("47", 1, 1, 1, 1, new Properties()));
+        events.add(new LogEvent("47", 2, 1, 1, 1, new Properties()));
+        events.add(new LogEvent("47", 2, 2, 1, 1, new Properties()));
+        m_serverStore.put(events);
+
+        List<String> result = getResponse("http://localhost:" + TestConstants.PORT
+ "/auditlog/query");
+        assert result.size() > 1 : "We expect at least two logs on the server.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=42");
+        assert result.size() == 1 : "Target 42 has a single audit log event.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=47");
+        assert result.size() == 3 : "Target 47 has 3 audit log events.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=47&logid=1");
+        assert result.size() == 1 : "Target 47, logid 1 has 1 audit log event.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=47&logid=2");
+        assert result.size() == 2 : "Target 47, logid 2 has 2 audit log events.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=47&logid=2&range=1");
+        assert result.size() == 1 : "Target 47, logid 2, range 1 has 1 audit log event.";
+
+        result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/receive?tid=47&logid=2&range=3,5");
+        assert result.size() == 0 : "Target 47, logid 2, range 3,5 has 0 audit log event.";
+    }
+
+    private List<String> getResponse(String request) throws IOException {
+        List<String> result = new ArrayList<String>();
+        InputStream in = null;
+        try {
+            in = new URL(request).openConnection().getInputStream();
+            byte[] response = new byte[in.available()];
+            in.read(response);
+
+            StringBuilder element = new StringBuilder();
+            for (byte b : response) {
+                switch(b) {
+                    case '\n' :
+                        result.add(element.toString());
+                        element = new StringBuilder();
+                        break;
+                    default :
+                        element.append(b);
+                }
+            }
+        }
+        finally {
+            try {
+                in.close();
+            }
+            catch (Exception e) {
+                // no problem.
+            }
+        }
+        return result;
+    }
+}



Mime
View raw message