X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fconfig%2Ftest%2FJU_Get.java;h=b275790cedb871602fcb1ecff1c02693fe1a88a2;hb=a174f8ddbc5eb78a648fb68b33ef18cb64d81fda;hp=eaa3376df0df255830e6caa5c34c032df1b91e31;hpb=9af4623faed6fd0bda1567cbf28899b5b5363be0;p=aaf%2Fauthz.git diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java index eaa3376d..b275790c 100644 --- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java +++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java @@ -33,84 +33,75 @@ import org.onap.aaf.cadi.config.Get; public class JU_Get { - private String defaultVal = "some default value"; + private String defaultVal = "some default value"; - private ByteArrayOutputStream outStream; + private ByteArrayOutputStream outStream; - private TestBean tb; + private TestBean tb; - @Before - public void setup() { - outStream = new ByteArrayOutputStream(); - System.setOut(new PrintStream(outStream)); - } + @Before + public void setup() { + outStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outStream)); + } - @After - public void tearDown() { - System.setOut(System.out); - } + @After + public void tearDown() { + System.setOut(System.out); + } - @Test - public void beanTest() { - tb = new TestBean(); - tb.setProperty1("prop1"); + @Test + public void beanTest() { + tb = new TestBean(); + tb.setProperty1("prop1"); - Get.Bean testBean = new Get.Bean(tb); - assertThat(testBean.get("property1", defaultVal, true), is("prop1")); - assertThat(testBean.get("property2", defaultVal, true), is(defaultVal)); - assertThat(testBean.get("thrower", defaultVal, true), is(defaultVal)); - } + Get.Bean testBean = new Get.Bean(tb); + assertThat(testBean.get("property1", defaultVal, true), is("prop1")); + assertThat(testBean.get("property2", defaultVal, true), is(defaultVal)); + assertThat(testBean.get("thrower", defaultVal, true), is(defaultVal)); + } - @Test - public void nullTest() { - assertThat(Get.NULL.get("name", defaultVal, true), is(defaultVal)); - } + @Test + public void nullTest() { + assertThat(Get.NULL.get("name", defaultVal, true), is(defaultVal)); + } - @Test - public void accessTest() { - String output; + @Test + public void accessTest() { - PropAccess access = new PropAccess(); - access.setProperty("tag", "value"); - Get.AccessGet accessGet = new Get.AccessGet(access); + PropAccess access = new PropAccess(); + access.setProperty("tag", "value"); + Get.AccessGet accessGet = new Get.AccessGet(access); - assertThat(accessGet.get("tag", defaultVal, true), is("value")); - output = outStream.toString().split(" ", 2)[1]; - assertThat(output, is("INIT [cadi] tag is set to value" + System.lineSeparator())); + assertThat(accessGet.get("tag", defaultVal, true), is("value")); + outStream.reset(); - outStream.reset(); + assertThat(accessGet.get("not a real tag", defaultVal, true), is(defaultVal)); + outStream.reset(); - assertThat(accessGet.get("not a real tag", defaultVal, true), is(defaultVal)); - output = outStream.toString().split(" ", 2)[1]; - assertThat(output, is("INIT [cadi] not a real tag is set to " + defaultVal + System.lineSeparator())); + assertThat(accessGet.get("not a real tag", null, true), is(nullValue())); - outStream.reset(); + outStream.reset(); - assertThat(accessGet.get("not a real tag", null, true), is(nullValue())); - output = outStream.toString().split(" ", 2)[1]; - assertThat(output, is("INIT [cadi] not a real tag is not set" + System.lineSeparator())); + assertThat(accessGet.get("tag", defaultVal, false), is("value")); + assertThat(outStream.toString(), is("")); + } - outStream.reset(); + public class TestBean implements java.io.Serializable { - assertThat(accessGet.get("tag", defaultVal, false), is("value")); - assertThat(outStream.toString(), is("")); - } + private static final long serialVersionUID = 1L; + private String property1 = null; + private String property2 = null; + @SuppressWarnings("unused") + private String thrower = null; - public class TestBean implements java.io.Serializable { + public TestBean() { } + public String getProperty1() { return property1; } + public void setProperty1(final String value) { this.property1 = value; } + public String getProperty2() { return property2; } + public void setProperty2(final String value) { this.property2 = value; } + public String getThrower() throws Exception { throw new Exception(); } + public void setThrower(final String value) { this.thrower = value; } - private static final long serialVersionUID = 1L; - private String property1 = null; - private String property2 = null; - @SuppressWarnings("unused") - private String thrower = null; - - public TestBean() { } - public String getProperty1() { return property1; } - public void setProperty1(final String value) { this.property1 = value; } - public String getProperty2() { return property2; } - public void setProperty2(final String value) { this.property2 = value; } - public String getThrower() throws Exception { throw new Exception(); } - public void setThrower(final String value) { this.thrower = value; } - - } + } }