### Question:
AllPermissionCollection extends PermissionCollection { @Override public void add( final Permission permission ) { if ( !PermissionChecks.isJSPWikiPermission( permission ) ) { throw new IllegalArgumentException( "Permission must be of type org.apache.wiki.permissions.*Permission." ); } if ( m_readOnly ) { throw new SecurityException( "attempt to add a Permission to a readonly PermissionCollection" ); } m_notEmpty = true; m_permissions.put( permission, permission ); }  @Override void add( final Permission permission ); @Override Enumeration<Permission> elements(); boolean implies( final Permission permission ); boolean isReadOnly(); void setReadOnly();  }### Answer:
@Test public void testAddAllPermission() { AllPermission all1 = new AllPermission( "*" ); AllPermission all2 = new AllPermission( "JSPWiki" ); AllPermission all3 = new AllPermission( "myWiki" ); AllPermission all4 = new AllPermission( "*" ); c_all.add( all1 ); Assertions.assertEquals( 1, count( c_all ) ); c_all.add( all2 ); Assertions.assertEquals( 2, count( c_all ) ); c_all.add( all3 ); Assertions.assertEquals( 3, count( c_all ) ); c_all.add( all4 ); Assertions.assertEquals( 3, count( c_all ) ); }
@Test public void testAddPagePermission() { PagePermission p1 = new PagePermission( "JSPWiki:Main", "edit" ); PagePermission p2 = new PagePermission( "JSPWiki:GroupAdmin", "edit" ); PagePermission p3 = new PagePermission( "JSPWiki:Foobar", "delete" ); PagePermission p4 = new PagePermission( "JSPWiki:Main", "edit" ); c_all.add( p1 ); Assertions.assertEquals( 1, count( c_all ) ); c_all.add( p2 ); Assertions.assertEquals( 2, count( c_all ) ); c_all.add( p3 ); Assertions.assertEquals( 3, count( c_all ) ); c_all.add( p4 ); Assertions.assertEquals( 3, count( c_all ) ); }
@Test public void testAddWikiPermission() { WikiPermission p1 = new WikiPermission( "JSPWiki", "login" ); WikiPermission p2 = new WikiPermission( "JSPWiki", "createGroups" ); WikiPermission p3 = new WikiPermission( "JSPWiki", "editPreferences" ); WikiPermission p4 = new WikiPermission( "JSPWiki", "login" ); c_all.add( p1 ); Assertions.assertEquals( 1, count( c_all ) ); c_all.add( p2 ); Assertions.assertEquals( 2, count( c_all ) ); c_all.add( p3 ); Assertions.assertEquals( 3, count( c_all ) ); c_all.add( p4 ); Assertions.assertEquals( 3, count( c_all ) ); }