forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use lazy inited regex expression for template extraction (btraceio#363)
Fixes btraceio#345
- Loading branch information
Showing
2 changed files
with
71 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.sun.btrace; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class ArgsMapTest { | ||
private static final String KEY1 = "key1"; | ||
private static final String KEY2 = "key2"; | ||
private static final String VALUE1 = "value1"; | ||
private static final String VALUE2 = "value2"; | ||
|
||
private ArgsMap instance; | ||
|
||
@Before | ||
public void setUp() { | ||
instance = new ArgsMap(); | ||
instance.put(KEY1, VALUE1); | ||
instance.put(KEY2, VALUE2); | ||
} | ||
|
||
@Test | ||
public void templateExisting() { | ||
String value = instance.template(KEY1 + "=${" + KEY1 + "}"); | ||
assertEquals(KEY1 + "=" + VALUE1, value); | ||
} | ||
|
||
@Test | ||
public void templateNonExisting() { | ||
String orig = KEY1 + "=${key3}"; | ||
String value = instance.template(orig); | ||
assertEquals(orig, value); | ||
} | ||
|
||
@Test | ||
public void templateTrailing$() { | ||
String orig = KEY1 + "$"; | ||
String value = instance.template(orig); | ||
assertEquals(orig, value); | ||
} | ||
|
||
@Test | ||
public void templateUnclosedPlaceholder() { | ||
String orig = KEY1 + "${"; | ||
String value = instance.template(orig); | ||
assertEquals(orig, value); | ||
} | ||
|
||
@Test | ||
public void templateSingle$() { | ||
String orig = KEY1 + "$" + KEY2; | ||
String value = instance.template(orig); | ||
assertEquals(orig, value); | ||
} | ||
} |