summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-22 05:26:06 (EST)
committerStefan Liebig2008-02-22 05:26:06 (EST)
commite4217b38123572999c19b8d310283e7c68b5de15 (patch)
tree78ed313ac9208436925725e599f87b4af7cab5ba
parent9d663dbeba47398e00b5d243dac6d93cd46bbbbc (diff)
downloadorg.eclipse.riena-e4217b38123572999c19b8d310283e7c68b5de15.zip
org.eclipse.riena-e4217b38123572999c19b8d310283e7c68b5de15.tar.gz
org.eclipse.riena-e4217b38123572999c19b8d310283e7c68b5de15.tar.bz2
not a real unit test!!
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java
new file mode 100644
index 0000000..1c6500a
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/logging/ConsoleLoggerTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 compeople AG and others.
+ * 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.core.logging;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.equinox.log.Logger;
+import org.eclipse.riena.internal.tests.Activator;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+
+/**
+ *
+ */
+public class ConsoleLoggerTest extends TestCase {
+
+ private Logger logger;
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ logger = new ConsoleLogger(ConsoleLoggerTest.class.getName());
+ }
+
+ public void testLevels() {
+ logger.log(LogService.LOG_DEBUG, "This is debug!");
+ logger.log(LogService.LOG_ERROR, "This is error!");
+ logger.log(LogService.LOG_INFO, "This is info!");
+ logger.log(LogService.LOG_WARNING, "This is warning!");
+ logger.log(-1, "This is unknown!");
+ }
+
+ public void testWithExceptions() {
+ IOException ioe = new IOException("Oops!");
+ logger.log(LogService.LOG_ERROR, "This is an error!", ioe);
+ }
+
+ public void testWithContext() {
+ logger.log(new String("CONTEXT"), LogService.LOG_INFO, "Message with context.");
+ }
+
+ public void testWithServiceReference() throws InvalidSyntaxException {
+ String stringService = "Very simple service";
+ ServiceRegistration sr = Activator.getContext().registerService(String.class.getName(), stringService, null);
+ Assert.assertTrue(sr.getReference() != null);
+ logger.log(sr.getReference(), LogService.LOG_INFO, "Message with context.");
+ sr.unregister();
+ }
+
+ public void testWithBadInput() throws InvalidSyntaxException {
+ logger.log((ServiceReference) null, 0, null, null);
+ logger.log(null, 0, null, null);
+ }
+}