diff options
author | Glyn Normington | 2010-04-20 14:38:13 +0000 |
---|---|---|
committer | Glyn Normington | 2010-04-20 14:38:13 +0000 |
commit | 1fe315346425dcdea73feebd431aba7ae2a75f61 (patch) | |
tree | 617c48f3ec41fb2cde58e215bc42bc2b3a5d8678 /org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse | |
download | org.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.tar.gz org.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.tar.xz org.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.zip |
[bug 307650] initial check-in from dm Server Virgo medic 0a647883a0176f60d8572f51c7eff591b7e408b6
Diffstat (limited to 'org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse')
6 files changed, 600 insertions, 0 deletions
diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java new file mode 100644 index 0000000..3ddddc8 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java @@ -0,0 +1,180 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.dump.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.slf4j.LoggerFactory; + +import org.eclipse.virgo.medic.dump.DumpGenerator; +import org.eclipse.virgo.test.framework.OsgiTestRunner; +import org.eclipse.virgo.test.framework.TestFrameworkUtils; + +@RunWith(OsgiTestRunner.class) +public class DumpIntegrationTests { + + private final BundleContext bundleContext = TestFrameworkUtils.getBundleContextForTestClass(getClass()); + + @Before + public void deleteDumps() { + File dumpsDir = new File("target", "dumps"); + if (dumpsDir.exists()) { + deleteRecursively(dumpsDir); + } + } + + private static void deleteRecursively(File file) { + if (file.isDirectory()) { + File[] files = file.listFiles(); + if (files != null) { + for (File fileInDir : files) { + deleteRecursively(fileInDir); + } + } + } + assertTrue(file.delete()); + } + + @Test + public void dumpGeneratorAvailableFromServiceRegistry() { + ServiceReference serviceReference = this.bundleContext.getServiceReference(DumpGenerator.class.getName()); + assertNotNull(serviceReference); + } + + @Test + @SuppressWarnings("unchecked") + public void dumpDirectoryConfiguration() throws IOException, InterruptedException { + Configuration configuration = getConfiguration("org.eclipse.virgo.medic"); + assertNotNull(configuration); + + Dictionary properties = new Hashtable<String, String>(); + properties.put("dump.root.directory", "target/dumps/1"); + + configuration.update(properties); + + Thread.sleep(2000); + + ServiceReference serviceReference = this.bundleContext.getServiceReference(DumpGenerator.class.getName()); + DumpGenerator dumpGenerator = (DumpGenerator)this.bundleContext.getService(serviceReference); + dumpGenerator.generateDump("bleurgh"); + + File file = new File("target/dumps/1"); + assertTrue(file.exists()); + assertNotNull(file.list()); + assertEquals(1, file.list().length); + assertDumpContributionsMade(file.listFiles()[0], "heap.out", "summary.txt", "thread.txt"); + + properties.put("dump.root.directory", "target/dumps/2"); + configuration.update(properties); + + Thread.sleep(2000); + + dumpGenerator.generateDump("bleurgh"); + + file = new File("target/dumps/2"); + assertTrue(file.exists()); + assertNotNull(file.list()); + assertEquals(1, file.list().length); + assertDumpContributionsMade(file.listFiles()[0], "heap.out", "summary.txt", "thread.txt"); + } + + @Test + @SuppressWarnings("unchecked") + public void exclusionConfiguration() throws IOException, InterruptedException { + Configuration configuration = getConfiguration("org.eclipse.virgo.medic"); + assertNotNull(configuration); + + Dictionary properties = new Hashtable<String, String>(); + properties.put("dump.root.directory", "target/dumps/1"); + properties.put("dump.exclusions.bleurgh", "heap"); + + configuration.update(properties); + + Thread.sleep(2000); + + ServiceReference serviceReference = this.bundleContext.getServiceReference(DumpGenerator.class.getName()); + DumpGenerator dumpGenerator = (DumpGenerator)this.bundleContext.getService(serviceReference); + dumpGenerator.generateDump("bleurgh"); + + File file = new File("target/dumps/1"); + assertTrue(file.exists()); + assertNotNull(file.list()); + assertEquals(1, file.list().length); + assertDumpContributionsMade(file.listFiles()[0], "summary.txt", "thread.txt"); + } + + @Test + public void logDumpEnabled() throws IOException, InterruptedException { + Configuration configuration = getConfiguration("org.eclipse.virgo.medic"); + assertNotNull(configuration); + + Dictionary<String, String> properties = new Hashtable<String, String>(); + properties.put("dump.root.directory", "target/dumps/1"); + properties.put("log.dump.level", "ERROR"); + + configuration.update(properties); + + Thread.sleep(2000); + + LoggerFactory.getLogger(getClass()).info("Test"); + + ServiceReference serviceReference = this.bundleContext.getServiceReference(DumpGenerator.class.getName()); + DumpGenerator dumpGenerator = (DumpGenerator)this.bundleContext.getService(serviceReference); + dumpGenerator.generateDump("bleurgh"); + + File file = new File("target/dumps/1"); + assertTrue(file.exists()); + assertNotNull(file.list()); + assertEquals(1, file.list().length); + assertDumpContributionsMade(file.listFiles()[0], "heap.out", "summary.txt", "thread.txt", "log.log"); + } + + private Configuration getConfiguration(String pid) throws IOException { + ConfigurationAdmin configurationAdmin = getConfigurationAdmin(); + assertNotNull(configurationAdmin); + + return configurationAdmin.getConfiguration(pid); + } + + private ConfigurationAdmin getConfigurationAdmin() { + ServiceReference serviceReference = this.bundleContext.getServiceReference(ConfigurationAdmin.class.getName()); + assertNotNull(serviceReference); + + return (ConfigurationAdmin) this.bundleContext.getService(serviceReference); + } + + private static void assertDumpContributionsMade(File dumpDirectory, String... contributions) { + assertTrue(dumpDirectory.exists()); + File[] files = dumpDirectory.listFiles(); + assertEquals("Found '" + Arrays.toString(files) + "' but expected '" + Arrays.toString(contributions) + "'", contributions.length, files.length); + List<String> contributionsList = Arrays.asList(contributions); + for (File file : files) { + assertTrue("The file " + file.getName() + " was not expected", contributionsList.contains(file.getName())); + } + } +} diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/eventlog/test/EventLogIntegrationTests.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/eventlog/test/EventLogIntegrationTests.java new file mode 100644 index 0000000..4987221 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/eventlog/test/EventLogIntegrationTests.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.eventlog.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.List; +import java.util.Locale; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.ServiceReference; + +import ch.qos.logback.classic.spi.LoggingEvent; + + +import org.eclipse.virgo.medic.eventlog.EventLogger; +import org.eclipse.virgo.medic.eventlog.EventLoggerFactory; +import org.eclipse.virgo.medic.eventlog.Level; +import org.eclipse.virgo.medic.log.appender.StubAppender; +import org.eclipse.virgo.test.framework.OsgiTestRunner; +import org.eclipse.virgo.test.framework.TestFrameworkUtils; + +@RunWith(OsgiTestRunner.class) +public class EventLogIntegrationTests { + + private BundleContext bundleContext; + + private Bundle messageBundle; + + @Before + public void before() throws BundleException { + Locale.setDefault(Locale.ITALIAN); + this.bundleContext = TestFrameworkUtils.getBundleContextForTestClass(getClass()); + messageBundle = this.bundleContext.installBundle("file:src/test/resources/message-bundle"); + this.bundleContext.installBundle("file:src/test/resources/message-fragment"); + } + + @Test + public void availabilityOfEventLoggerFactory() { + ServiceReference serviceReference = this.bundleContext.getServiceReference(EventLoggerFactory.class.getName()); + assertNotNull(serviceReference); + } + + @Test + public void availabilityOfEventLogger() { + ServiceReference serviceReference = this.bundleContext.getServiceReference(EventLogger.class.getName()); + assertNotNull(serviceReference); + } + + @Test + public void eventLoggingWithMessageFromCurrentBundle() { + ServiceReference serviceReference = this.bundleContext.getServiceReference(EventLogger.class.getName()); + assertNotNull(serviceReference); + EventLogger eventLogger = (EventLogger)this.bundleContext.getService(serviceReference); + eventLogger.log("1234", Level.WARNING, "orange", "lemon"); + + List<LoggingEvent> loggingEvent = StubAppender.getAndResetLoggingEvents("default-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("English orange and lemon", loggingEvent.get(0).getMessage()); + + loggingEvent = StubAppender.getAndResetLoggingEvents("localized-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("Italian orange and lemon", loggingEvent.get(0).getMessage()); + + } + + @Test + public void eventLoggingWithMessageFromFragment() throws Exception { + ServiceReference serviceReference = this.bundleContext.getServiceReference(EventLoggerFactory.class.getName()); + assertNotNull(serviceReference); + EventLoggerFactory eventLoggerFactory = (EventLoggerFactory)this.bundleContext.getService(serviceReference); + EventLogger eventLogger = eventLoggerFactory.createEventLogger(this.messageBundle); + eventLogger.log("3456", Level.WARNING, "oak", "sycamore"); + + List<LoggingEvent> loggingEvent = StubAppender.getAndResetLoggingEvents("default-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("Shared oak and sycamore", loggingEvent.get(0).getMessage()); + + loggingEvent = StubAppender.getAndResetLoggingEvents("localized-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("Shared oak and sycamore", loggingEvent.get(0).getMessage()); + } + + @Test + public void eventLoggingWithMessageFromSpecificBundle() throws Exception { + ServiceReference serviceReference = this.bundleContext.getServiceReference(EventLoggerFactory.class.getName()); + assertNotNull(serviceReference); + EventLoggerFactory eventLoggerFactory = (EventLoggerFactory)this.bundleContext.getService(serviceReference); + EventLogger eventLogger = eventLoggerFactory.createEventLogger(this.messageBundle); + eventLogger.log("2345", Level.WARNING, "potato", "cauliflower"); + + List<LoggingEvent> loggingEvent = StubAppender.getAndResetLoggingEvents("default-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("English potato and cauliflower", loggingEvent.get(0).getMessage()); + + loggingEvent = StubAppender.getAndResetLoggingEvents("localized-stub"); + assertEquals(1, loggingEvent.size()); + assertEquals("Italian potato and cauliflower", loggingEvent.get(0).getMessage()); + } +} diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/appender/StubAppender.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/appender/StubAppender.java new file mode 100644 index 0000000..68e2974 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/appender/StubAppender.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.log.appender; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import ch.qos.logback.classic.spi.LoggingEvent; +import ch.qos.logback.core.AppenderBase; + +public class StubAppender extends AppenderBase<LoggingEvent> { + + private static Map<String, List<LoggingEvent>> loggingEvents = new HashMap<String, List<LoggingEvent>>(); + + @Override + protected void append(LoggingEvent eventObject) { + getLoggingEventsByName(name).add(eventObject); + } + + public static List<LoggingEvent> getAndResetLoggingEvents(String name) { + List<LoggingEvent> loggingEvents = getLoggingEventsByName(name); + List<LoggingEvent> response = new ArrayList<LoggingEvent>(loggingEvents); + loggingEvents.clear(); + return response; + } + + private static List<LoggingEvent> getLoggingEventsByName(String name) { + List<LoggingEvent> loggingEventsForName = loggingEvents.get(name); + if (loggingEventsForName == null) { + loggingEventsForName = new ArrayList<LoggingEvent>(); + loggingEvents.put(name, loggingEventsForName); + } + return loggingEventsForName; + } +} diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/EntryExitTraceTests.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/EntryExitTraceTests.java new file mode 100644 index 0000000..b476e80 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/EntryExitTraceTests.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.log.test; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.List; + +import org.eclipse.virgo.medic.log.appender.StubAppender; +import org.junit.BeforeClass; +import org.junit.Test; + +import test.TestClass; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.LoggingEvent; + + +public class EntryExitTraceTests { + + private final TestClass testClass = new TestClass(); + + @BeforeClass + public static void ensureConfiguredContextSelectorIsDefaultContextSelector() { + System.setProperty("logback.ContextSelector", "ch.qos.logback.classic.selector.DefaultContextSelector"); + } + + @Test + public void testPublicBefore() { + testClass.publicTest(false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(0); + assertEquals(Level.INFO, event.getLevel()); + assertEquals("> public void test.TestClass.publicTest(boolean)", event.getFormattedMessage()); + assertEquals("public void test.TestClass.publicTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPublicAfterReturn() { + testClass.publicTest(false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.INFO, event.getLevel()); + assertEquals("< public void test.TestClass.publicTest(boolean)", event.getFormattedMessage()); + assertEquals("public void test.TestClass.publicTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPublicAfterThrowing() { + try { + testClass.publicTest(true); + } catch (Exception e) { + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.INFO, event.getLevel()); + assertEquals("< public void test.TestClass.publicTest(boolean)", event.getFormattedMessage()); + assertEquals(RuntimeException.class.getName(), event.getThrowableProxy().getClassName()); + } + } + + @Test + public void testPackagePrivateBefore() throws Exception { + Method method = testClass.getClass().getDeclaredMethod("packagePrivateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(0); + assertEquals(Level.DEBUG, event.getLevel()); + assertEquals("> void test.TestClass.packagePrivateTest(boolean)", event.getFormattedMessage()); + assertEquals("void test.TestClass.packagePrivateTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPackagePrivateAfterReturn() throws Exception { + Method method = testClass.getClass().getDeclaredMethod("packagePrivateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.DEBUG, event.getLevel()); + assertEquals("< void test.TestClass.packagePrivateTest(boolean)", event.getFormattedMessage()); + assertEquals("void test.TestClass.packagePrivateTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPackagePrivateAfterThrowing() { + try { + Method method = testClass.getClass().getDeclaredMethod("packagePrivateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, true); + } catch (Exception e) { + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.DEBUG, event.getLevel()); + assertEquals("< void test.TestClass.packagePrivateTest(boolean)", event.getFormattedMessage()); + assertEquals(RuntimeException.class.getName(), event.getThrowableProxy().getClassName()); + } + } + + @Test + public void testPrivateBefore() throws Exception { + Method method = testClass.getClass().getDeclaredMethod("privateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(0); + assertEquals(Level.TRACE, event.getLevel()); + assertEquals("> private void test.TestClass.privateTest(boolean)", event.getFormattedMessage()); + assertEquals("private void test.TestClass.privateTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPrivateAfterReturn() throws Exception { + Method method = testClass.getClass().getDeclaredMethod("privateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, false); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.TRACE, event.getLevel()); + assertEquals("< private void test.TestClass.privateTest(boolean)", event.getFormattedMessage()); + assertEquals("private void test.TestClass.privateTest(boolean)", event.getArgumentArray()[1]); + } + + @Test + public void testPrivateAfterThrowing() { + try { + Method method = testClass.getClass().getDeclaredMethod("privateTest", boolean.class); + method.setAccessible(true); + method.invoke(testClass, true); + } catch (Exception e) { + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents(null); + assertEquals(2, loggingEvents.size()); + LoggingEvent event = loggingEvents.get(1); + assertEquals(Level.TRACE, event.getLevel()); + assertEquals("< private void test.TestClass.privateTest(boolean)", event.getFormattedMessage()); + assertEquals(RuntimeException.class.getName(), event.getThrowableProxy().getClassName()); + } + } +} diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/MedicLoggingIntegrationTests.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/MedicLoggingIntegrationTests.java new file mode 100644 index 0000000..2b8b5e8 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/MedicLoggingIntegrationTests.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.log.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; + + +import org.eclipse.virgo.medic.log.LoggingConfigurationPublisher; +import org.eclipse.virgo.medic.log.appender.StubAppender; +import org.eclipse.virgo.test.framework.OsgiTestRunner; +import org.eclipse.virgo.test.framework.TestFrameworkUtils; + +@RunWith(OsgiTestRunner.class) +public class MedicLoggingIntegrationTests { + + private BundleContext bundleContext; + + @Before + public void before() { + this.bundleContext = TestFrameworkUtils.getBundleContextForTestClass(getClass()); + } + + @Test + public void test() throws BundleException { + bundleContext.installBundle("file:src/test/resources/test-bundle_1").start(); + assertEquals(1, StubAppender.getAndResetLoggingEvents("bundle1-stub").size()); + + bundleContext.installBundle("file:src/test/resources/test-bundle_2").start(); + assertEquals(1, StubAppender.getAndResetLoggingEvents("bundle2-stub").size()); + + bundleContext.installBundle("file:src/test/resources/test-bundle_3").start(); + assertEquals(1, StubAppender.getAndResetLoggingEvents("root-stub").size()); + } + + @Test + public void availabilityOfConfigurationPublisher() { + assertNotNull(bundleContext.getServiceReference(LoggingConfigurationPublisher.class.getName())); + } +} diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/PrintStreamWrappingTests.java b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/PrintStreamWrappingTests.java new file mode 100644 index 0000000..6b22ed8 --- /dev/null +++ b/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/log/test/PrintStreamWrappingTests.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 VMware Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VMware Inc. - initial contribution + *******************************************************************************/ + +package org.eclipse.virgo.medic.log.test; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import ch.qos.logback.classic.spi.LoggingEvent; + +import org.eclipse.virgo.medic.log.appender.StubAppender; +import org.eclipse.virgo.test.framework.OsgiTestRunner; + + +@RunWith(OsgiTestRunner.class) +public class PrintStreamWrappingTests { + + @Test + @Ignore("Test fails on the CI server as it wraps System.out") + public void sysOutWrapping() { + System.out.println("Hello world!"); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents("root-stub"); + assertEquals(1, loggingEvents.size()); + assertEquals("Hello world!", loggingEvents.get(0).getMessage()); + } + + @Test + @Ignore("Test fails on the CI server as it wraps System.err") + public void sysErrWrapping() { + System.err.println("Hello world!"); + List<LoggingEvent> loggingEvents = StubAppender.getAndResetLoggingEvents("root-stub"); + assertEquals(1, loggingEvents.size()); + assertEquals("Hello world!", loggingEvents.get(0).getMessage()); + } +} |