[jboss-cvs] JBossAS SVN: r58795 - branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 1 04:50:11 EST 2006
Author: dimitris at jboss.org
Date: 2006-12-01 04:50:08 -0500 (Fri, 01 Dec 2006)
New Revision: 58795
Added:
branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861/JBAS3861UnitTestCase.java
Log:
JBAS3861, rename the test case so it's picked up automatically
Copied: branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861/JBAS3861UnitTestCase.java (from rev 58726, branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861/JBAS3861TestCase.java)
===================================================================
--- branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861/JBAS3861TestCase.java 2006-11-29 11:20:10 UTC (rev 58726)
+++ branches/Branch_3_2/testsuite/src/main/org/jboss/test/console/jbas3861/JBAS3861UnitTestCase.java 2006-12-01 09:50:08 UTC (rev 58795)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.console.jbas3861;
+
+import javax.management.Attribute;
+import javax.management.ObjectName;
+import javax.management.RuntimeMBeanException;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test JBAS-3861 (DeploymentFileRepository service)
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 57211 $
+ */
+public class JBAS3861UnitTestCase extends JBossTestCase
+{
+ ObjectName target= ObjectNameFactory.create("jboss.admin:service=DeploymentFileRepository");
+
+ public JBAS3861UnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Check if BaseDir can be set outside the server home directory
+ */
+ public void testSetBaseDirOutsideServerHomeDir() throws Exception
+ {
+ // remember original BaseDir
+ String basedir = (String)getServer().getAttribute(target, "BaseDir");
+ try
+ {
+ // Should throw an IllegalArgumentException
+ getServer().setAttribute(target, new Attribute("BaseDir", ".."));
+ // Should throw an IllegalArgumentException
+ getServer().setAttribute(target, new Attribute("BaseDir", "/"));
+
+ // Restore the original dir and fail the test
+ getServer().setAttribute(target, new Attribute("BaseDir", basedir));
+ fail("Managed to set BaseDir outside ServerHomeDir for service: " + target);
+ }
+ catch (RuntimeMBeanException e)
+ {
+ // expected
+ }
+ }
+
+ /**
+ * Check if we can write a file outside the server home directory
+ */
+ public void testStoreFileOutsideServerHomeDir() throws Exception
+ {
+ try
+ {
+ // Should throw an exception
+ getServer().invoke(
+ target,
+ "store",
+ new Object[] { "..", "jbas3861", ".tmp", "file content", Boolean.TRUE },
+ new String[] { "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", Boolean.TYPE.toString() });
+
+ // Should throw an exception
+ getServer().invoke(
+ target,
+ "store",
+ new Object[] { ".", "../jbas3861", ".tmp", "file content", Boolean.TRUE },
+ new String[] { "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", Boolean.TYPE.toString() });
+
+ // Remove the stored file and fail the test - normally it should throw an exception, too
+ getServer().invoke(
+ target,
+ "remove",
+ new Object[] { ".", "../jbas3861", ".tmp" },
+ new String[] { "java.lang.String", "java.lang.String", "java.lang.String" });
+
+ fail("Managed to create/remove a file outside ServerHomeDir for service: " + target);
+ }
+ catch (RuntimeMBeanException e)
+ {
+ // expected
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list