pnever 2005/02/25 09:06:03
Modified: proposals/wvcm/test/junit/src/org/apache/wvcm/test/common
Tag: WVCM_1_0_BRANCH AbstractTest.java
Log:
Added RetryHandler for CONFLICT responses from the server
Revision Changes Path
No revision
No revision
1.3.4.1 +497 -487
jakarta-slide/proposals/wvcm/test/junit/src/org/apache/wvcm/test/common/AbstractTest.java
Index: AbstractTest.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/test/junit/src/org/apache/wvcm/test/common/AbstractTest.java,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -r1.3 -r1.3.4.1
--- AbstractTest.java 30 Jul 2004 06:52:35 -0000 1.3
+++ AbstractTest.java 25 Feb 2005 17:06:03 -0000 1.3.4.1
@@ -101,17 +101,17 @@
* @version $Revision$
*/
public abstract class AbstractTest extends TestCase {
-
- private static Logger logger =
Logger.getLogger("org.apache.wvcm.test.common.AbstractTest");
-
+
+ private static Logger logger =
Logger.getLogger("org.apache.wvcm.test.common.AbstractTest");
+
// Read properties from the properties file. If no props file is given,
// default values will be used.
protected static Properties webdavprops = new Properties();
static {
- try {
- webdavprops.load(
AbstractTest.class.getResourceAsStream("/test.properties") );
- }
- catch (java.io.IOException e) {}
+ try {
+ webdavprops.load(
AbstractTest.class.getResourceAsStream("/test.properties") );
+ }
+ catch (java.io.IOException e) {}
}
protected PropertiesHelper propsHelper;
@@ -134,6 +134,10 @@
protected HttpClient client = null;
+ protected int retryMax = 0;
+ protected long retryTimeout = 0;
+ protected long retrySleep = 0;
+
// caches
private String contextPath = null;
private String rootFolderPath = null;
@@ -150,6 +154,7 @@
protected String rolesFolderPath = null;
protected ProviderFactory.Callback callback = null;
+ protected Hashtable h;
protected Provider provider = null;
protected Location location;
@@ -159,547 +164,552 @@
protected Workspace workspace;
protected String testResourcesRoot = "/org/apache/wvcm/test/resources/";
- protected String testResourcesAbsoluteRoot;
+ protected String testResourcesAbsoluteRoot;
/**
- * Default Constructor
- *
- * @param testName Name of the test to run.
- *
- * @throws Exception
- *
- */
+ * Default Constructor
+ *
+ * @param testName Name of the test to run.
+ *
+ * @throws Exception
+ *
+ */
public AbstractTest(String testName) throws Exception {
- super(testName);
- try {
- initProperties();
-
- client = new HttpClient();
- client.getHostConfiguration().setHost(host, port,
"http");
- HttpState state = new HttpState();
- state.setCredentials(
- realm, host, new
UsernamePasswordCredentials(username, password) );
- client.setState( state );
- }
- catch (NoClassDefFoundError ncdfe) {
- System.out.println("no class def found error
exception");
- System.out.println(ncdfe.getCause().getMessage());
- ncdfe.printStackTrace();
- }
- catch (ExceptionInInitializerError e) {
- System.out.println(e.getCause().getMessage());
- e.printStackTrace();
- }
-
- callback = new CallbackImpl();
- Hashtable h = new Hashtable();
- h.put( "host", host );
- h.put( "port", String.valueOf(port) );
- if( realm != null )
- h.put( "realm", realm );
- if( context != null )
- h.put( "context", context );
- provider = ProviderFactory.createProvider(
- "org.apache.wvcm.ProviderImpl", callback, h );
-
- propsHelper = new PropertiesHelper();
- xmlHelper = new XmlHelper();
- fileHelper = new FileHelper();
-
- // Initialize variables used by all tests.
- if (!usersFolderName.startsWith("/") )
- usersFolderName = "/"+usersFolderName;
- usersFolderPath = contextPath() + usersFolderName;
-
- if (!groupsFolderName.startsWith("/") )
- groupsFolderName = "/" + groupsFolderName;
- groupsFolderPath = contextPath() + groupsFolderName;
-
- if (!rolesFolderName.startsWith("/") )
- rolesFolderName = "/" + rolesFolderName;
- rolesFolderPath = contextPath() + rolesFolderName;
+ super(testName);
+ try {
+ initProperties();
+
+ client = new HttpClient();
+ client.getHostConfiguration().setHost(host, port, "http");
+ HttpState state = new HttpState();
+ state.setCredentials(
+ realm, host, new UsernamePasswordCredentials(username,
password) );
+ client.setState( state );
+ }
+ catch (NoClassDefFoundError ncdfe) {
+ System.out.println("no class def found error exception");
+ System.out.println(ncdfe.getCause().getMessage());
+ ncdfe.printStackTrace();
+ }
+ catch (ExceptionInInitializerError e) {
+ System.out.println(e.getCause().getMessage());
+ e.printStackTrace();
+ }
+
+ callback = new CallbackImpl();
+ h = new Hashtable();
+ h.put( "host", host );
+ h.put( "port", String.valueOf(port) );
+ if( realm != null )
+ h.put( "realm", realm );
+ if( context != null )
+ h.put( "context", context );
+ h.put("retryMax", String.valueOf(retryMax));
+ h.put("retrySleep", String.valueOf(retrySleep));
+ h.put("retryTimeout", String.valueOf(retryTimeout));
+
+ provider = ProviderFactory.createProvider(
+ "org.apache.wvcm.ProviderImpl", callback, h );
+
+ propsHelper = new PropertiesHelper();
+ xmlHelper = new XmlHelper();
+ fileHelper = new FileHelper();
+
+ // Initialize variables used by all tests.
+ if (!usersFolderName.startsWith("/") )
+ usersFolderName = "/"+usersFolderName;
+ usersFolderPath = contextPath() + usersFolderName;
+
+ if (!groupsFolderName.startsWith("/") )
+ groupsFolderName = "/" + groupsFolderName;
+ groupsFolderPath = contextPath() + groupsFolderName;
+
+ if (!rolesFolderName.startsWith("/") )
+ rolesFolderName = "/" + rolesFolderName;
+ rolesFolderPath = contextPath() + rolesFolderName;
}
/**
- * Initialises the properties needed for the test from a Properties
file. If
- * the properties file is not found, properties are initialised with
some
- * default value.
- *
- */
+ * Initialises the properties needed for the test from a Properties
file. If
+ * the properties file is not found, properties are initialised with some
+ * default value.
+ *
+ */
private void initProperties() {
- host = webdavprops.getProperty( "org.apache.webdav.test.host",
"localhost" );
- String portStr = webdavprops.getProperty(
"org.apache.webdav.test.port", "8080" );
- try {
- port = Integer.parseInt(portStr);
- }
- catch (NumberFormatException e) {
- port = 8080;
- }
- context = webdavprops.getProperty(
"org.apache.webdav.test.context", "slide" );
- rootfolderName = webdavprops.getProperty(
"org.apache.webdav.test.rootfolder", "files" );
- realm = webdavprops.getProperty(
"org.apache.webdav.test.realm", null );
- username = webdavprops.getProperty(
"org.apache.webdav.test.username", "root" );
- password = webdavprops.getProperty(
"org.apache.webdav.test.password", "root" );
-
- usersFolderName = webdavprops.getProperty(
"org.apache.webdav.test.usersfolder", "/users" );
- groupsFolderName = webdavprops.getProperty(
"org.apache.webdav.test.groupsfolder", "/groups" );
- rolesFolderName = webdavprops.getProperty(
"org.apache.webdav.test.rolesfolder", "" );
- privilegesFolderName = webdavprops.getProperty(
"org.apache.webdav.test.privilegesfolder", "actions" );
- workspaceFolderName = webdavprops.getProperty(
"org.apache.webdav.test.workspacefolder", "workspace" );
-
- // Resource related properties
- testResourcesRoot = webdavprops.getProperty(
"org.apache.webdav.test.resourcesRoot",
-
"/org/apache/wvcm/test/resources/");
- testResourcesAbsoluteRoot = webdavprops.getProperty(
"org.apache.webdav.test.resourcesAbsolutePath",
-
"E:\\");
+ host = webdavprops.getProperty( "org.apache.webdav.test.host",
"localhost" );
+ try { port =
Integer.parseInt(webdavprops.getProperty("org.apache.webdav.test.port",
"8080")); }
+ catch (NumberFormatException e) { port = 8080; }
+ context = webdavprops.getProperty( "org.apache.webdav.test.context",
"slide" );
+ rootfolderName = webdavprops.getProperty(
"org.apache.webdav.test.rootfolder", "files" );
+ realm = webdavprops.getProperty( "org.apache.webdav.test.realm",
null );
+ username = webdavprops.getProperty(
"org.apache.webdav.test.username", "root" );
+ password = webdavprops.getProperty(
"org.apache.webdav.test.password", "root" );
+
+ usersFolderName = webdavprops.getProperty(
"org.apache.webdav.test.usersfolder", "/users" );
+ groupsFolderName = webdavprops.getProperty(
"org.apache.webdav.test.groupsfolder", "/groups" );
+ rolesFolderName = webdavprops.getProperty(
"org.apache.webdav.test.rolesfolder", "" );
+ privilegesFolderName = webdavprops.getProperty(
"org.apache.webdav.test.privilegesfolder", "actions" );
+ workspaceFolderName = webdavprops.getProperty(
"org.apache.webdav.test.workspacefolder", "workspace" );
+
+ // Resource related properties
+ testResourcesRoot = webdavprops.getProperty(
"org.apache.webdav.test.resourcesRoot",
+
"/org/apache/wvcm/test/resources/");
+ testResourcesAbsoluteRoot = webdavprops.getProperty(
"org.apache.webdav.test.resourcesAbsolutePath",
+ "E:\\");
+ try { retryMax =
Integer.parseInt(webdavprops.getProperty("org.apache.webdav.test.retryMax",
"5")); }
+ catch (NumberFormatException e) { retryMax = 5; }
+ try { retrySleep =
Long.parseLong(webdavprops.getProperty("org.apache.webdav.test.retrySleep",
"500")); }
+ catch (NumberFormatException e) { retrySleep = 500; }
+ try { retryTimeout =
Long.parseLong(webdavprops.getProperty("org.apache.webdav.test.retryTimeout",
"5000")); }
+ catch (NumberFormatException e) { retryTimeout = 5000; }
}
/**
- * Tests common setup.
- *
- * @throws Exception
- */
+ * Tests common setup.
+ *
+ * @throws Exception
+ */
protected void setUp() throws Exception {
- super.setUp ();
+ super.setUp ();
}
/**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- *
- * @throws Exception
- */
+ * Tears down the fixture, for example, close a network connection.
+ * This method is called after a test is executed.
+ *
+ * @throws Exception
+ */
protected void tearDown() throws Exception {
}
/**
- * Removes a resource in the server specified by the given path.
- *
- * @param resourcePath Path to the resource to remove.
- *
- * @throws Exception
- *
- */
+ * Removes a resource in the server specified by the given path.
+ *
+ * @param resourcePath Path to the resource to remove.
+ *
+ * @throws Exception
+ *
+ */
protected void deleteResourceOnServer( String resourcePath ) throws
Exception {
- HttpMethod method = new DeleteMethod( resourcePath );
- try {
- client.executeMethod( method );
- }
- catch (ConnectException e) {
- if (logger.isLoggable(Level.INFO))
- logger.info("No connection with "
- +
client.getHostConfiguration().getHostURL()
- + " could be done.
Check configuration.");
-
-
- throw e;
- }
-
- assertTrue( method.getStatusCode() == 204 ||
method.getStatusCode() == 404 );
+ HttpMethod method = new DeleteMethod( resourcePath );
+ try {
+ client.executeMethod( method );
+ }
+ catch (ConnectException e) {
+ if (logger.isLoggable(Level.INFO))
+ logger.info("No connection with "
+ + client.getHostConfiguration().getHostURL()
+ + " could be done. Check configuration.");
+
+
+ throw e;
+ }
+
+ assertTrue( method.getStatusCode() == 204 || method.getStatusCode()
== 404 );
}
/**
- * Check if the location specified by the passed path exists in the
server.
- *
- * @param resourcePath Location to check.
- *
- * @return True if the resource is found.
- *
- * @throws Exception
- *
- */
+ * Check if the location specified by the passed path exists in the
server.
+ *
+ * @param resourcePath Location to check.
+ *
+ * @return True if the resource is found.
+ *
+ * @throws Exception
+ *
+ */
protected boolean resourceExistsOnServer( String resourcePath ) throws
Exception {
- HttpMethod method = new HeadMethod( resourcePath );
- try {
- client.executeMethod( method );
- }
- catch (ConnectException e) {
- if (logger.isLoggable(Level.INFO))
- logger.info("No connection with "
- +
client.getHostConfiguration().getHostURL()
- + " could be done.
Check configuration.");
-
-
- throw e;
- }
-
- return( method.getStatusCode() == 200 );
+ HttpMethod method = new HeadMethod( resourcePath );
+ try {
+ client.executeMethod( method );
+ }
+ catch (ConnectException e) {
+ if (logger.isLoggable(Level.INFO))
+ logger.info("No connection with "
+ + client.getHostConfiguration().getHostURL()
+ + " could be done. Check configuration.");
+
+
+ throw e;
+ }
+
+ return( method.getStatusCode() == 200 );
}
/**
- * Get context path
- *
- * @return a String
- */
+ * Get context path
+ *
+ * @return a String
+ */
protected synchronized String contextPath() {
- if( contextPath == null ) {
- if( context != null && context.length() > 0 )
- contextPath = "/" + context;
- else
- contextPath = "/";
- }
- return contextPath;
+ if( contextPath == null ) {
+ if( context != null && context.length() > 0 )
+ contextPath = "/" + context;
+ else
+ contextPath = "/";
+ }
+ return contextPath;
}
/**
- * Get rootfolder path
- *
- * @return a String
- */
+ * Get rootfolder path
+ *
+ * @return a String
+ */
protected synchronized String rootFolderPath() {
- if( rootFolderPath == null ) {
- if( rootfolderName != null && rootfolderName.length() >
0 )
- rootFolderPath =
contextPath()+"/"+rootfolderName;
- else
- rootFolderPath = contextPath();
- }
- return rootFolderPath;
+ if( rootFolderPath == null ) {
+ if( rootfolderName != null && rootfolderName.length() > 0 )
+ rootFolderPath = contextPath()+"/"+rootfolderName;
+ else
+ rootFolderPath = contextPath();
+ }
+ return rootFolderPath;
}
/**
- * Using the passed location, a ControllableResource is instantiated,
- * unbound and then created again. If the resource exists there before,
it
- * will be deleted. Result is not checked.
- *
- * @param loc Path to the resource for the test.
- *
- * @return A ControllableResource created with the passed path.
- *
- * @throws WvcmException
- *
- */
+ * Using the passed location, a ControllableResource is instantiated,
+ * unbound and then created again. If the resource exists there before,
it
+ * will be deleted. Result is not checked.
+ *
+ * @param loc Path to the resource for the test.
+ *
+ * @return A ControllableResource created with the passed path.
+ *
+ * @throws WvcmException
+ *
+ */
protected ControllableResource createControllableResource(Location loc)
throws WvcmException {
- ControllableResource resource = loc.controllableResource();
- try {
- resource.doUnbind();
- resource.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of resource "
- + loc.string()
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- resource = null;
- }
-
- return resource;
+ ControllableResource resource = loc.controllableResource();
+ try {
+ resource.doUnbind();
+ resource.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of resource "
+ + loc.string()
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ resource = null;
+ }
+
+ return resource;
}
/**
- * Using the passed location, a ControllableFolder is instantiated,
- * unbound and then created again. If the folder exists there before, it
- * will be deleted.
- *
- * @param loc Location to use when creating the
folder.
- *
- * @return A ControllableFolder created with the passed path or null
if
- * there were any problems while creating the folder.
- *
- * @throws WvcmException
- *
- */
+ * Using the passed location, a ControllableFolder is instantiated,
+ * unbound and then created again. If the folder exists there before, it
+ * will be deleted.
+ *
+ * @param loc Location to use when creating the folder.
+ *
+ * @return A ControllableFolder created with the passed path or null if
+ * there were any problems while creating the folder.
+ *
+ * @throws WvcmException
+ *
+ */
protected ControllableFolder createControllableFolder(Location loc)
throws WvcmException {
- ControllableFolder folder = (ControllableFolder)loc.folder();
- try {
- folder.doUnbind();
- folder.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of folder "
- + loc.string()
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- folder = null;
- }
-
- return folder;
+ ControllableFolder folder = (ControllableFolder)loc.folder();
+ try {
+ folder.doUnbind();
+ folder.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of folder "
+ + loc.string()
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ folder = null;
+ }
+
+ return folder;
}
/**
- * Using the passed location, a Workspace is instantiated,
- * unbound and then created again. If the workspace exists there
before, it
- * will be deleted.
- *
- * @param loc Path to the workspace to be created.
- *
- * @return A Workspace created with the passed path.
- *
- * @throws WvcmException
- *
- */
+ * Using the passed location, a Workspace is instantiated,
+ * unbound and then created again. If the workspace exists there before,
it
+ * will be deleted.
+ *
+ * @param loc Path to the workspace to be created.
+ *
+ * @return A Workspace created with the passed path.
+ *
+ * @throws WvcmException
+ *
+ */
protected Workspace createWorkspace(Location loc) throws WvcmException {
- Workspace workspace = loc.workspace();
-
- try {
- workspace.doUnbind();
- workspace.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of workspace "
- + loc.string()
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- workspace = null;
- }
- return workspace;
+ Workspace workspace = loc.workspace();
+
+ try {
+ workspace.doUnbind();
+ workspace.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of workspace "
+ + loc.string()
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ workspace = null;
+ }
+ return workspace;
}
/**
- * Using the passed location, a Privilege is instantiated, then unbound
and
- * created again.
- *
- * @param loc Location where the privilege will be
created.
- *
- * @return Mmmm, the created privilege.
- *
- * @throws WvcmException
- *
- */
+ * Using the passed location, a Privilege is instantiated, then unbound
and
+ * created again.
+ *
+ * @param loc Location where the privilege will be
created.
+ *
+ * @return Mmmm, the created privilege.
+ *
+ * @throws WvcmException
+ *
+ */
protected Privilege createPrivilege(Location loc) throws WvcmException {
- Privilege priv = loc.privilege();
-
- try {
- priv.doUnbind();
- priv.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of workspace "
- + loc.string()
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- priv = null;
- }
- return priv;
+ Privilege priv = loc.privilege();
+
+ try {
+ priv.doUnbind();
+ priv.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of workspace "
+ + loc.string()
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ priv = null;
+ }
+ return priv;
}
/**
- * Creates a Group. If the group already exists,
- * depending on the value of the overwrite parameter, the group will be
- * deleted and created again, losing in this way any properties and/or
- * child groups/users.
- *
- * @param groupName Name of the group to create.
- * @param overwrite If the group is to be deleted in case
it exists.
- *
- * @return The created Group.
- *
- * @throws WvcmException
- * @throws Exception
- *
- */
+ * Creates a Group. If the group already exists,
+ * depending on the value of the overwrite parameter, the group will be
+ * deleted and created again, losing in this way any properties and/or
+ * child groups/users.
+ *
+ * @param groupName Name of the group to create.
+ * @param overwrite If the group is to be deleted in case
it exists.
+ *
+ * @return The created Group.
+ *
+ * @throws WvcmException
+ * @throws Exception
+ *
+ */
protected Group createGroup(String groupName, boolean overwrite)
- throws WvcmException, Exception{
- String path = null;
- if (groupsFolderPath != null && groupsFolderPath.length() > 0) {
- path = groupsFolderPath + "/" + groupName;
- location = provider.location(path);
- }
- else
- throw new Exception("GROUPS FOLDER PATH NOT
INITIALIZED.");
- Group testGroup = location.group();
-
- try {
- if (overwrite && resourceExistsOnServer(path)) {
- testGroup.doUnbind();
- }
- testGroup.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of group "
- + groupName
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- testGroup = null;
- }
-
- assertTrue( resourceExistsOnServer(path) );
- return testGroup;
+ throws WvcmException, Exception{
+ String path = null;
+ if (groupsFolderPath != null && groupsFolderPath.length() > 0) {
+ path = groupsFolderPath + "/" + groupName;
+ location = provider.location(path);
+ }
+ else
+ throw new Exception("GROUPS FOLDER PATH NOT INITIALIZED.");
+ Group testGroup = location.group();
+
+ try {
+ if (overwrite && resourceExistsOnServer(path)) {
+ testGroup.doUnbind();
+ }
+ testGroup.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of group "
+ + groupName
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ testGroup = null;
+ }
+
+ assertTrue( resourceExistsOnServer(path) );
+ return testGroup;
}
/**
- * Creates a Principal in the userdb folder. If the Principal already
exists,
- * depending on the value of the overwrite parameter, it will be
- * deleted and created again, losing in this way any properties.
- *
- * @param userName Name of the Principal to create.
- * @param overwrite If the Principal is to be deleted in
case it exists.
- *
- * @return The created Principal.
- *
- * @throws WvcmException
- * @throws Exception
- *
- */
+ * Creates a Principal in the userdb folder. If the Principal already
exists,
+ * depending on the value of the overwrite parameter, it will be
+ * deleted and created again, losing in this way any properties.
+ *
+ * @param userName Name of the Principal to create.
+ * @param overwrite If the Principal is to be deleted in
case it exists.
+ *
+ * @return The created Principal.
+ *
+ * @throws WvcmException
+ * @throws Exception
+ *
+ */
protected Principal createUser(String userName, boolean overwrite)
- throws WvcmException, Exception {
- String path = null;
- if (usersFolderPath != null && usersFolderPath.length() > 0) {
- path = usersFolderPath + "/" + userName;
- location = provider.location(path);
- }
- else
- throw new Exception("USERS FOLDER PATH NOT
INITIALIZED.");
- Principal user = location.principal();
-
- try {
- if (overwrite && resourceExistsOnServer(path)) {
- user.doUnbind();
- }
-
- user.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of user "
- + userName
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- user = null;
- }
-
- assertTrue( resourceExistsOnServer(path) );
- return user;
+ throws WvcmException, Exception {
+ String path = null;
+ if (usersFolderPath != null && usersFolderPath.length() > 0) {
+ path = usersFolderPath + "/" + userName;
+ location = provider.location(path);
+ }
+ else
+ throw new Exception("USERS FOLDER PATH NOT INITIALIZED.");
+ Principal user = location.principal();
+
+ try {
+ if (overwrite && resourceExistsOnServer(path)) {
+ user.doUnbind();
+ }
+
+ user.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of user "
+ + userName
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ user = null;
+ }
+
+ assertTrue( resourceExistsOnServer(path) );
+ return user;
}
/**
- * Creates a Role. If the Role already exists,
- * depending on the value of the overwrite parameter, it will be
- * deleted and created again, losing in this way any properties and/or
- * child roles.
- *
- * @param roleName Name of the folder to create.
- * @param overwrite If the role is to be deleted in case
it exists.
- *
- * @return The created Role.
- *
- * @throws WvcmException
- * @throws Exception
- *
- */
+ * Creates a Role. If the Role already exists,
+ * depending on the value of the overwrite parameter, it will be
+ * deleted and created again, losing in this way any properties and/or
+ * child roles.
+ *
+ * @param roleName Name of the folder to create.
+ * @param overwrite If the role is to be deleted in case it
exists.
+ *
+ * @return The created Role.
+ *
+ * @throws WvcmException
+ * @throws Exception
+ *
+ */
protected Role createRole(String roleName, boolean overwrite)
- throws WvcmException, Exception{
- String path = null;
- if (rolesFolderPath != null && rolesFolderPath.length() > 0) {
- path = rolesFolderPath + "/" + roleName;
- location = provider.location(path);
- }
- else
- throw new Exception("ROLES FOLDER PATH NOT
INITIALIZED.");
- Role testRole = location.role();
-
- try {
- if (overwrite && resourceExistsOnServer(path)) {
- testRole.doUnbind();
- }
- testRole.doCreateResource();
- }
- catch (WvcmException unexpected) {
- if (unexpected.getReasonCode() ==
ReasonCode.WRITE_FAILED) {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Creation of role "
- + roleName
- + " failed.");
- }
- }
- else {
- if(logger.isLoggable(Level.INFO)) {
- logger.info("Unexpected exception while
creating resource.");
- }
- throw unexpected;
- }
- testRole = null;
- }
-
- assertTrue( resourceExistsOnServer(path) );
- return testRole;
+ throws WvcmException, Exception{
+ String path = null;
+ if (rolesFolderPath != null && rolesFolderPath.length() > 0) {
+ path = rolesFolderPath + "/" + roleName;
+ location = provider.location(path);
+ }
+ else
+ throw new Exception("ROLES FOLDER PATH NOT INITIALIZED.");
+ Role testRole = location.role();
+
+ try {
+ if (overwrite && resourceExistsOnServer(path)) {
+ testRole.doUnbind();
+ }
+ testRole.doCreateResource();
+ }
+ catch (WvcmException unexpected) {
+ if (unexpected.getReasonCode() == ReasonCode.WRITE_FAILED) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Creation of role "
+ + roleName
+ + " failed.");
+ }
+ }
+ else {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.info("Unexpected exception while creating
resource.");
+ }
+ throw unexpected;
+ }
+ testRole = null;
+ }
+
+ assertTrue( resourceExistsOnServer(path) );
+ return testRole;
}
/**
- * Callback implementation
- */
+ * Callback implementation
+ */
class CallbackImpl implements ProviderFactory.Callback {
-
- Authentication authentication = new AuthenticationImpl();
-
- /**
- * Return authentication information for the current user.
- * @param realm The authentication realm for the provider.
- */
- public ProviderFactory.Callback.Authentication
getAuthentication(String realm, Integer retryCount) {
- // System.out.println("@@@
getAuthentication("+realm+","+retryCount+")");
- return authentication;
- }
-
- /**
- * Callback Authentication implementation.
- */
- class AuthenticationImpl implements
ProviderFactory.Callback.Authentication {
-
- /** Return the password of the current user. */
- public String password() {
- return password;
- }
-
- /** Return the login name of the current user. */
- public String loginName() {
- return username;
- }
- }
+
+ Authentication authentication = new AuthenticationImpl();
+
+ /**
+ * Return authentication information for the current user.
+ * @param realm The authentication realm for the provider.
+ */
+ public ProviderFactory.Callback.Authentication
getAuthentication(String realm, Integer retryCount) {
+ // System.out.println("@@@
getAuthentication("+realm+","+retryCount+")");
+ return authentication;
+ }
+
+ /**
+ * Callback Authentication implementation.
+ */
+ class AuthenticationImpl implements
ProviderFactory.Callback.Authentication {
+
+ /** Return the password of the current user. */
+ public String password() {
+ return password;
+ }
+
+ /** Return the login name of the current user. */
+ public String loginName() {
+ return username;
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]