@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "toString", args = {}) public void testToString() { UnresolvedPermission up1 = new UnresolvedPermission("type1", "name1", "action1", null); UnresolvedPermission up2 = new UnresolvedPermission("type1", "name1", "action1", null); UnresolvedPermission up3 = null; assertTrue(up1.toString().contains("")); assertTrue(up2.toString().contains("")); try { up3.toString(); fail("NullPointerException expected"); } catch (NullPointerException e) { // expected } }
/** * Creates an Object with given name, type, action, certificates. Empty or null type is not * allowed - exception should be thrown. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "UnresolvedPermission", args = { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.security.cert.Certificate[].class }) public void testCtor() { String type = "laskjhlsdk 2345346"; String name = "^%#UHVKU^%V 887y"; String action = "JHB ^%(*&T klj3h4"; UnresolvedPermission up = new UnresolvedPermission(type, name, action, null); assertEquals(type, up.getName()); assertEquals("", up.getActions()); assertEquals("(unresolved " + type + " " + name + " " + action + ")", up.toString()); up = new UnresolvedPermission(type, null, null, null); assertEquals(type, up.getName()); assertEquals("", up.getActions()); assertEquals("(unresolved " + type + " null null)", up.toString()); up = new UnresolvedPermission(type, "", "", new java.security.cert.Certificate[0]); assertEquals(type, up.getName()); assertEquals("", up.getActions()); assertEquals("(unresolved " + type + " )", up.toString()); try { new UnresolvedPermission(null, name, action, null); fail("No expected NullPointerException"); } catch (NullPointerException ok) { } // Regression for HARMONY-733 up = new UnresolvedPermission("", "name", "action", null); assertEquals("", up.getName()); }