List of usage examples for junit.framework Assert assertNull
static public void assertNull(String message, Object object)
From source file:org.eclipse.hudson.security.team.TeamGlobalACLTest.java
@Test public void testGlobalSysAdminPermission() throws IOException { //Paul should not get global configure permission before adding as Sysadmin Sid sid = new PrincipalSid("Paul"); TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.GLOBAL); Assert.assertNull("Paul should not have global CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); //Now Paul should get global configure permission since added as Sysadmin teamManager.addSysAdmin("Paul"); Assert.assertTrue("Paul should have global CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamGlobalACLTest.java
@Test public void testGlobalNonSysAdminPermission() { //Chris, a non SysAdmin, should not get global create permission Sid sid = new PrincipalSid("Chris"); TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.GLOBAL); Assert.assertNull("Chris should not have global CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); //But Chris should get READ permission Assert.assertTrue("Chris should have global READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamGlobalACLTest.java
@Test public void testGlobalAnonymousPermission() { //Anonymous, should not get global create permission Sid sid = ACL.ANONYMOUS;/*from ww w .j a v a 2s.c o m*/ TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.GLOBAL); Assert.assertNull("Anonymous should not have global CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); //Anonymous should get READ permission Assert.assertTrue("Anonymous should have global READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamGlobalACLTest.java
@Test public void testGlobalEveryonePermission() { //Evru one, should not get global create permission Sid sid = ACL.EVERYONE;/*w w w . ja va 2s .c om*/ TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.GLOBAL); Assert.assertNull("Every one should not have global CREATE permission", teamBasedACL.hasPermission(sid, configurePermission)); //Every one should get READ permission Assert.assertTrue("Every one should have global READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamJobACLTest.java
@Test public void testJobPermission() throws IOException, TeamManager.TeamAlreadyExistsException, TeamNotFoundException { String teamName = "team1"; Team team = teamManager.createTeam(teamName); FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob"); TeamMember newMember = new TeamMember(); newMember.setName("Paul"); newMember.addPermission(Item.CONFIGURE); team.addMember(newMember);/*w ww . j a va 2 s . c o m*/ teamManager.addJobToUserTeam("Paul", freeStyleJob.getName()); Sid sid = new PrincipalSid("Paul"); TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob); Assert.assertTrue("Paul is a team member with Job CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission).booleanValue()); Sid sid2 = new PrincipalSid("Chris"); Assert.assertNull("Chris is not a team member and should not have Job CONFIGURE permission", teamBasedACL.hasPermission(sid2, configurePermission)); Assert.assertNull("Chris is not a team member and should not have Job READ permission", teamBasedACL.hasPermission(sid2, readPermission)); }
From source file:org.eclipse.hudson.security.team.TeamJobACLTest.java
@Test public void testPublicJobPermission() throws IOException { FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob"); teamManager.getPublicTeam().addJob(new TeamJob(freeStyleJob.getName())); Sid sid = new PrincipalSid("Paul"); TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob); Assert.assertNull("Paul is not a SysAdmin and should not have public Job CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); Assert.assertTrue("Paul should have pubic Job READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); teamManager.addSysAdmin("Paul"); Assert.assertTrue("Paul is a SysAdmin and should have public Job CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamJobACLTest.java
@Test public void testAnonymousPublicJobPermission() throws IOException { FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob"); teamManager.getPublicTeam().addJob(new TeamJob(freeStyleJob.getName())); Sid sid = ACL.ANONYMOUS;//from w w w. j av a 2 s . c o m TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob); Assert.assertNull("Anonymous should not have public Job CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); Assert.assertTrue("Anonymous should have public Job READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamJobACLTest.java
@Test public void testEveryonePublicJobPermission() throws IOException { FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob"); teamManager.getPublicTeam().addJob(new TeamJob(freeStyleJob.getName())); Sid sid = ACL.EVERYONE;/*from w ww. ja v a2 s . co m*/ TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob); Assert.assertNull("Every one should not have public Job CONFIGURE permission", teamBasedACL.hasPermission(sid, configurePermission)); Assert.assertTrue("Every one should have piublic Job READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); }
From source file:org.eclipse.hudson.security.team.TeamJobACLTest.java
@Test public void testJobVisibility() throws IOException, TeamManager.TeamAlreadyExistsException { String teamName = "team1"; Team team = teamManager.createTeam(teamName); FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob"); TeamJob teamJob = new TeamJob(freeStyleJob.getName()); teamJob.addVisibility("public"); team.addJob(teamJob);//ww w . j a v a 2 s . c o m Sid sid = ACL.ANONYMOUS; TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob); Assert.assertTrue("Anonymous should have testJob READ permission", teamBasedACL.hasPermission(sid, readPermission).booleanValue()); teamJob.removeVisibility("public"); Assert.assertNull("Anonymous should not have testJob READ permission", teamBasedACL.hasPermission(sid, readPermission)); String teamName2 = "team2"; Team team2 = teamManager.createTeam(teamName2); TeamMember newMember = new TeamMember(); newMember.setName("Chris"); newMember.addPermission(Item.CONFIGURE); team2.addMember(newMember); teamJob.addVisibility(team2.getName()); Sid sid2 = new PrincipalSid("Chris"); Assert.assertNull("Chris should not have Job CONFIGURE permission", teamBasedACL.hasPermission(sid2, configurePermission)); Assert.assertTrue("Chris should have testJob READ permission", teamBasedACL.hasPermission(sid2, readPermission).booleanValue()); }
From source file:org.eclipselabs.garbagecat.TestMain.java
public void testInvalidOption() { try {/*from ww w .j av a 2 s . c o m*/ Class<?> c = Class.forName("org.eclipselabs.garbagecat.Main"); Class<?>[] argTypes = new Class[] { String[].class }; Method parseOptions = c.getDeclaredMethod("parseOptions", argTypes); // Make private method accessible parseOptions.setAccessible(true); // Method arguments String[] args = new String[3]; // Test typo (extra 'h') args[0] = "--threshhold"; args[1] = "80"; // Instead of a file, use a location sure to exist. args[2] = System.getProperty("user.dir"); // Pass null object since parseOptions is static Object o = parseOptions.invoke(null, (Object) args); CommandLine cmd = (CommandLine) o; // An unrecognized option throws an <code>UnrecognizedOptionException</code>, which is // caught and the usage line output. Assert.assertNull("An invalid option was accepted.", cmd); } catch (ClassNotFoundException e) { Assert.fail(e.getMessage()); } catch (SecurityException e) { Assert.fail("SecurityException: " + e.getMessage()); } catch (NoSuchMethodException e) { Assert.fail("NoSuchMethodException: " + e.getMessage()); } catch (IllegalArgumentException e) { Assert.fail("IllegalArgumentException: " + e.getMessage()); } catch (IllegalAccessException e) { Assert.fail("IllegalAccessException: " + e.getMessage()); } catch (InvocationTargetException e) { // Anything the invoked method throws is wrapped by InvocationTargetException. Assert.assertTrue("Epected ParseException not thrown.", e.getTargetException() instanceof ParseException); } }