diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-12-28 13:54:23 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-12-28 13:54:23 +0100 |
commit | 47990a4a02bb738eedd7dce6a2f2dd10d5f28cc4 (patch) | |
tree | 6413669212ce5c34c5c8068038e50b1481df6743 /org.jacoco.agent.rt.test | |
parent | 9c1b63dafd9be7316d3661aaa18aa3815160d19c (diff) | |
download | jacoco-47990a4a02bb738eedd7dce6a2f2dd10d5f28cc4.tar.gz |
Additional way to provide configuration options via classpath resource.
Diffstat (limited to 'org.jacoco.agent.rt.test')
-rw-r--r-- | org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ConfigLoaderTest.java | 57 | ||||
-rw-r--r-- | org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/agent-test.properties | 1 |
2 files changed, 58 insertions, 0 deletions
diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ConfigLoaderTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ConfigLoaderTest.java new file mode 100644 index 00000000..4ca8afa6 --- /dev/null +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ConfigLoaderTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors + * 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: + * Marc R. Hoffmann - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.agent.rt; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Properties; + +import org.junit.Test; + +/** + * Unit tests for {@link ConfigLoader}. + */ +public class ConfigLoaderTest { + + @Test + public void testResource() { + Properties system = new Properties(); + Properties config = ConfigLoader.load( + "/org/jacoco/agent/rt/agent-test.properties", system); + + assertEquals("tcpclient", config.get("output")); + } + + @Test + public void testNoResource() { + Properties system = new Properties(); + Properties config = ConfigLoader.load("does-not-exist.properties", + system); + + assertTrue(config.isEmpty()); + } + + @Test + public void testSystemProperties() { + Properties system = new Properties(); + system.setProperty("jacoco-agent.output", "mbean"); + system.setProperty("output", "tcpserver"); // no prefix + system.setProperty("jacoco-agent.sessionid", "testid"); + Properties config = ConfigLoader.load( + "/org/jacoco/agent/rt/agent-test.properties", system); + + assertEquals("mbean", config.get("output")); + assertEquals("testid", config.get("sessionid")); + } + +} diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/agent-test.properties b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/agent-test.properties new file mode 100644 index 00000000..d13081c8 --- /dev/null +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/agent-test.properties @@ -0,0 +1 @@ +output=tcpclient
\ No newline at end of file |