* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@Mock
UserRoleDAO dao;
-
+
@Mock
CIDAO<AuthzTrans> info;
-
+
@Mock
AuthzTransImpl trans;
-
+
@Mock
RoleDAO.Data data;
-
+
@Mock
PermDAO.Data permData;
-
+
@Before
public void setUp() throws Exception {
initMocks(this);
when(trans.debug()).thenReturn(new LogTarget() {
-
+
@Override
public void printf(String fmt, Object... vars) {}
-
+
@Override
public void log(Throwable e, Object... msgs) {
e.getMessage();
e.printStackTrace();
msgs.toString();
-
+
}
-
+
@Override
public void log(Object... msgs) {
}
-
+
@Override
public boolean isLoggable() {
-
+
return true;
}
});
}
-
+
private class TaggedPrincipalStub extends TaggedPrincipal {
String name="TaggedPrincipalStub";
public TaggedPrincipalStub() { super(); }
@Override public String getName() { return name; }
@Override public String tag() { return null; }
}
-
+
@Test
public void testReadName() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10L);
//System.out.println(retVal.status);
//retVal.status = 0;
assertEquals("25", Integer.toString(retVal.status));
- }
-
+ }
+
@Test
public void testReadNameUser() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10L);
Object o=null;
return (T)o;
}
-
+
};
transTemp.setUser(new TaggedPrincipalStub());
Mockito.doReturn(retVal1).when(info).touch(trans, null,null);
// System.out.println(retVal.status);
assertEquals("1", Integer.toString(retVal.status));
}
-
+
@Test
public void testReadByRoleSuccess() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 0);//Mockito.mock(CachedRoleDAO.class);//
Result<List<Data>> retVal = roleDaoObj.readByRole(trans, "");
//System.out.println(retVal.status);
assertEquals("1", Integer.toString(retVal.status));
- }
+ }
@Test
public void testReadByRoleFailure() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 0);//Mockito.mock(CachedRoleDAO.class);//
//System.out.println(retVal.status);
assertEquals("25", Integer.toString(retVal.status));
}
-
+
@Test
public void testReadUserInRole() {
CachedUserRoleDAO roleDaoObj =new CachedUserRoleDAO(dao,info, 10);//Mockito.mock(CachedRoleDAO.class);//
Object o=null;
return (T)o;
}
-
+
};
transTemp.setUser(new TaggedPrincipalStub());
Mockito.doReturn(retVal1).when(info).touch(trans, null,null);
//System.out.println(retVal.status);
assertEquals("25", Integer.toString(retVal.status));
}
-
+
}
\ No newline at end of file