summaryrefslogtreecommitdiffstats
path: root/logging/src/test
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:57 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:57 -0800
commitb7926325a1c1a370c84c81db80372f59af240a53 (patch)
treeb1d0214be443ea674d0ded8c502a8e074e50bdd2 /logging/src/test
parent687f18b91f4a0a728a027579110953ee729adcb8 (diff)
downloadlibcore-b7926325a1c1a370c84c81db80372f59af240a53.zip
libcore-b7926325a1c1a370c84c81db80372f59af240a53.tar.gz
libcore-b7926325a1c1a370c84c81db80372f59af240a53.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'logging/src/test')
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java2
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java5
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java16
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java51
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java16
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java3
6 files changed, 47 insertions, 46 deletions
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
index 4334317..3ff1fc9 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.harmony.logging.tests.java.util.logging;
+import dalvik.annotation.AndroidOnly;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
@@ -885,6 +886,7 @@ public class FileHandlerTest extends TestCase {
args = {java.util.logging.LogRecord.class}
)
})
+ @AndroidOnly("This test fails on RI. Doesn't parse special pattern \"%t/%h.")
public void testInvalidParams() throws IOException {
// %t and %p parsing can add file separator automatically
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java
index c1afeca..ba2345d 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FormatterTest.java
@@ -17,6 +17,7 @@
package org.apache.harmony.logging.tests.java.util.logging;
+import dalvik.annotation.AndroidOnly;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestTargetNew;
@@ -160,6 +161,10 @@ public class FormatterTest extends TestCase {
method = "formatMessage",
args = {LogRecord.class}
)
+ @AndroidOnly("The RI fails in this test because it uses a MessageFormat " +
+ "to format the message even though it doesn't contain \"{0\". " +
+ "The spec says that this would indicate that a MessageFormat " +
+ "should be used and else no formatting should be done.")
public void testFormatMessage() {
assertEquals(MSG, f.formatMessage(r));
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
index 0b882f0..5868b1f 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/HandlerTest.java
@@ -51,13 +51,6 @@ public class HandlerTest extends TestCase {
private static String className = HandlerTest.class.getName();
/*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
* @see TestCase#tearDown()
*/
protected void tearDown() throws Exception {
@@ -65,15 +58,6 @@ public class HandlerTest extends TestCase {
CallVerificationStack.getInstance().clear();
}
- /**
- * Constructor for HandlerTest.
- *
- * @param arg0
- */
- public HandlerTest(String arg0) {
- super(arg0);
- }
-
/*
* Test the constructor.
*/
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
index 8be31e9..4e8e034 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java
@@ -17,11 +17,19 @@
package org.apache.harmony.logging.tests.java.util.logging;
-//import android.access.IPropertyChangeEvent;
-//import android.access.;
-import dalvik.annotation.*;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
+import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
@@ -36,12 +44,6 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.LoggingPermission;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import org.apache.harmony.logging.tests.java.util.logging.HandlerTest.NullOutputStream;
-import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
-
/**
*
* add/get logger(dot)
@@ -426,7 +428,12 @@ public class LogManagerTest extends TestCase {
public void test_addLoggerLLogger_Security() throws Exception {
// regression test for Harmony-1286
SecurityManager originalSecurityManager = System.getSecurityManager();
- System.setSecurityManager(new SecurityManager());
+ System.setSecurityManager(new SecurityManager() {
+ @Override
+ public void checkPermission(Permission perm) {
+
+ }
+ });
try {
LogManager manager = LogManager.getLogManager();
manager.addLogger(new MockLogger("mock", null));
@@ -461,6 +468,7 @@ public class LogManagerTest extends TestCase {
assertEquals(Level.FINE, root.getLevel());
assertEquals("", root.getName());
assertSame(root.getParent(), null);
+ // This test sometimes fails if other tests are run before this one.
assertNull(root.getResourceBundle());
assertNull(root.getResourceBundleName());
assertTrue(root.getUseParentHandlers());
@@ -777,6 +785,7 @@ public class LogManagerTest extends TestCase {
assertEquals(0, root.getHandlers().length);
assertEquals(Level.INFO, root.getLevel());
manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
+ manager.reset();
}
@TestTargetNew(
@@ -858,33 +867,32 @@ public class LogManagerTest extends TestCase {
args = {java.io.InputStream.class}
)
public void testReadConfigurationInputStream() throws IOException {
- // mock LogManager
- InputStream stream = EnvironmentHelper.PropertiesToInputStream(props);
-
+
Logger foo = new MockLogger(FOO, null);
assertNull(foo.getLevel());
assertTrue(mockManager.addLogger(foo));
- Logger fo = new MockLogger("LogManagerTestFoo2", null);
+ Logger fo = new MockLogger(FOO + "2", null);
fo.setLevel(Level.ALL);
assertTrue(mockManager.addLogger(fo));
Handler h = new ConsoleHandler();
Level l = h.getLevel();
- assertSame(Level.OFF, h.getLevel());
+ assertSame(Level.INFO, h.getLevel());
// read configuration from stream
+ InputStream stream = EnvironmentHelper.PropertiesToInputStream(props);
mockManager.readConfiguration(stream);
stream.close();
- // level DO has effect
+ // level DOES have an effect on LogManagerTestFoo
assertEquals(Level.WARNING, foo.getLevel());
// for non specified logger, level is reset to null
assertNull(fo.getLevel());
// read properties don't affect handler
- assertSame(Level.OFF, h.getLevel());
+ assertSame(Level.INFO, h.getLevel());
assertSame(l, h.getLevel());
}
@@ -925,7 +933,6 @@ public class LogManagerTest extends TestCase {
args = {java.io.InputStream.class}
)
public void testReadConfigurationInputStream_root() throws IOException {
- InputStream stream = EnvironmentHelper.PropertiesToInputStream(props);
manager.readConfiguration(EnvironmentHelper.PropertiesToInputStream(props));
Logger logger = new MockLogger("testReadConfigurationInputStream_root.foo", null);
@@ -946,12 +953,14 @@ public class LogManagerTest extends TestCase {
// }
// after read stream
+ InputStream stream = EnvironmentHelper.PropertiesToInputStream(props);
manager.readConfiguration(stream);
+ stream.close();
assertEquals(Level.FINE, root.getLevel());
assertEquals(2, root.getHandlers().length);
assertNull(logger.getLevel());
assertEquals(0, logger.getHandlers().length);
- stream.close();
+ manager.reset();
}
// public void testAddRemovePropertyChangeListener() throws Exception {
@@ -1126,6 +1135,7 @@ public class LogManagerTest extends TestCase {
assertEquals(Level.FINE, manager.getLogger("").getLevel());
} finally {
System.setErr(err);
+ manager.reset();
}
}
@@ -1219,6 +1229,7 @@ public class LogManagerTest extends TestCase {
} catch (Exception e) {
e.printStackTrace();
}
+ manager.reset();
}
}
@@ -1250,6 +1261,7 @@ public class LogManagerTest extends TestCase {
} catch (Exception e) {
e.printStackTrace();
}
+ manager.reset();
}
}
@@ -1295,6 +1307,7 @@ public class LogManagerTest extends TestCase {
} catch (Exception e) {
e.printStackTrace();
}
+ manager.reset();
}
}
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
index 046a7a8..4ec01ed 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
@@ -18,6 +18,7 @@
package org.apache.harmony.logging.tests.java.util.logging;
import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.BrokenTest;
import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
@@ -91,15 +92,6 @@ public class LoggerTest extends TestCase {
super.tearDown();
}
- /**
- * Constructor for LoggerTest.
- *
- * @param arg0
- */
- public LoggerTest(String arg0) {
- super(arg0);
- }
-
/*
* Test the global logger
*/
@@ -442,8 +434,10 @@ public class LoggerTest extends TestCase {
method = "getLogger",
args = {java.lang.String.class}
)
- @AndroidOnly("getResourceBundle and getResourceBundleName methods return " +
- "null on RI for Logger with empty string name.")
+ @BrokenTest("This fails on RI and Android." +
+ "getResourceBundle and getResourceBundleName methods return " +
+ "null on RI for Logger with empty string name. On the RI " +
+ "getHandlers() returns a non empty array.")
public void testGetLogger_Empty() {
assertNotNull(LogManager.getLogManager().getLogger(""));
Logger log = Logger.getLogger("");
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java
index d8ee15f..917a898 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/XMLFormatterTest.java
@@ -17,6 +17,7 @@
package org.apache.harmony.logging.tests.java.util.logging;
+import dalvik.annotation.AndroidOnly;
import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
@@ -263,6 +264,8 @@ public class XMLFormatterTest extends TestCase {
args = {}
)
})
+ @AndroidOnly("This test fails on RI. Output doesn't contain " +
+ "<message/>.")
public void testInvalidParameter() {
formatter.getTail(null);
try {