[jboss-svn-commits] JBL Code SVN: r20089 - in labs/jbossrules/trunk/drools-jbrms/src: test/java/org/drools/brms/server/files and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 21 01:16:39 EDT 2008
Author: michael.neale at jboss.com
Date: 2008-05-21 01:16:37 -0400 (Wed, 21 May 2008)
New Revision: 20089
Modified:
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/files/WebDAVImpl.java
labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/files/WebDAVImplTest.java
Log:
JBRULES-1612 WebDAV
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/files/WebDAVImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/files/WebDAVImpl.java 2008-05-21 05:07:55 UTC (rev 20088)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/server/files/WebDAVImpl.java 2008-05-21 05:16:37 UTC (rev 20089)
@@ -16,280 +16,356 @@
import org.drools.repository.AssetItem;
import org.drools.repository.PackageItem;
import org.drools.repository.RulesRepository;
-import org.drools.rule.TimeMachine;
public class WebDAVImpl implements IWebdavStorage {
- final RulesRepository repository;
- TimeMachine time = new TimeMachine();
+ final ThreadLocal<RulesRepository> tlRepo = new ThreadLocal<RulesRepository>();;
- public WebDAVImpl() {
- repository = RestAPIServlet.getRepository();
- }
- public WebDAVImpl(RulesRepository testRepo) {
- repository = testRepo;
- }
+ public WebDAVImpl() {
+ }
- public void begin(Principal pr, Hashtable params) throws Exception {
- //do nothing.
- }
+ public WebDAVImpl(RulesRepository testRepo) {
+ tlRepo.set(testRepo);
+ }
- public void checkAuthentication() throws SecurityException {
- //already done
- }
+ RulesRepository getRepo() {
+ return tlRepo.get();
+ }
- public void commit() throws IOException {
- repository.save();
- }
+ public void begin(Principal pr, Hashtable params) throws Exception {
+ tlRepo.set(RestAPIServlet.getRepository());
+ }
- public void createFolder(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- if (path.length > 2) {
- throw new UnsupportedOperationException("Can't nest packages.");
- }
- if (repository.containsPackage(path[1])) {
- PackageItem pkg = repository.loadPackage(path[1]);
- pkg.archiveItem(false);
- pkg.checkin("<restored by webdav>");
- } else {
- repository.createPackage(path[1], "<from webdav>");
- }
- } else {
- throw new UnsupportedOperationException("Not able to create folders here...");
- }
- }
+ public void checkAuthentication() throws SecurityException {
+ //already done
+ }
- public void createResource(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- if (path.length > 3) {
- throw new UnsupportedOperationException("Can't do nested packages.");
- }
- String packageName = path[1];
- String[] resource = path[2].split("\\.");
+ public void commit() throws IOException {
+ System.out.println("COMMIT");
- PackageItem pkg = repository.loadPackage(packageName);
- if (pkg.containsAsset(resource[0])) {
- AssetItem lazarus = pkg.loadAsset(resource[0]);
- lazarus.archiveItem(false);
- lazarus.checkin("<from webdav>");
- } else {
- AssetItem asset = pkg.addAsset(resource[0], "");
- asset.updateFormat(resource[1]);
- asset.checkin("<from webdav>");
- }
+ getRepo().save();
+ tlRepo.set(null);
+ }
- } else {
- throw new UnsupportedOperationException("Can't add assets here.");
- }
- }
+ public void createFolder(String uri) throws IOException {
+ System.out.println("creating folder:" + uri);
+ String[] path = getPath(uri);
+ if (path[0].equals("packages")) {
+ if (path.length > 2) {
+ throw new UnsupportedOperationException("Can't nest packages.");
+ }
+ RulesRepository repository = getRepo();
+ if (repository.containsPackage(path[1])) {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ pkg.archiveItem(false);
+ pkg.checkin("<restored by webdav>");
+ } else {
+ repository.createPackage(path[1], "<from webdav>");
+ }
+ } else {
+ throw new UnsupportedOperationException("Not able to create folders here...");
+ }
+ }
+ public void createResource(String uri) throws IOException {
+ System.out.println("creating resource:" + uri);
+ //for mac OSX, ignore these annoying things
+ if (uri.endsWith(".DS_Store")) return;
+ String[] path = getPath(uri);
+ if (path[0].equals("packages")) {
+ if (path.length > 3) {
+ throw new UnsupportedOperationException("Can't do nested packages.");
+ }
+ String packageName = path[1];
+ String[] resource = AssetItem.getAssetNameFromFileName(path[2]);
+ RulesRepository repository = getRepo();
+ PackageItem pkg = repository.loadPackage(packageName);
- public String[] getChildrenNames(String uri) throws IOException {
- String[] path = getPath(uri);
- List<String> result = new ArrayList<String>();
- if (path.length == 0) {
- return new String[] {"packages"};
- }
- if (path[0].equals("packages")) {
- if (path.length > 2) {
- throw new UnsupportedOperationException("No nested package support");
- }
- if (path.length == 1) {
- Iterator<PackageItem> it = repository.listPackages();
- while(it.hasNext()) {
- PackageItem pkg = it.next();
- if (!pkg.isArchived()) {
- result.add(pkg.getName());
- }
- }
- } else {
- PackageItem pkg = repository.loadPackage(path[1]);
- Iterator<AssetItem> it = pkg.getAssets();
- while(it.hasNext()) {
- AssetItem asset = it.next();
- if (!asset.isArchived()) {
- result.add(asset.getName() + "." + asset.getFormat());
- }
- }
- }
- return result.toArray(new String[result.size()]);
- } else {
- throw new UnsupportedOperationException("Not implemented yet");
- }
- }
+ //for mac OSX, ignore these resource fork files
+ if (path[2].startsWith("._")) {
+ return;
+ }
+ if (pkg.containsAsset(resource[0])) {
- public Date getCreationDate(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- PackageItem pkg = repository.loadPackage(path[1]);
- if (path.length == 2) {
- //dealing with package
- return pkg.getCreatedDate().getTime();
- } else {
- String fileName = path[2];
- String assetName = fileName.split("\\.")[0];
- AssetItem asset = pkg.loadAsset(assetName);
- return asset.getCreatedDate().getTime();
- }
- } else {
- throw new UnsupportedOperationException();
- }
- }
+ AssetItem lazarus = pkg.loadAsset(resource[0]);
+ lazarus.archiveItem(false);
+ lazarus.checkin("<from webdav>");
+ } else {
+ AssetItem asset = pkg.addAsset(resource[0], "");
+ asset.updateFormat(resource[1]);
+ asset.checkin("<from webdav>");
+ }
- public Date getLastModified(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- PackageItem pkg = repository.loadPackage(path[1]);
- if (path.length == 2) {
- //dealing with package
- return pkg.getLastModified().getTime();
- } else {
- String fileName = path[2];
- String assetName = fileName.split("\\.")[0];
- AssetItem asset = pkg.loadAsset(assetName);
- return asset.getLastModified().getTime();
- }
- } else {
- throw new UnsupportedOperationException();
- }
- }
+ } else {
+ throw new UnsupportedOperationException("Can't add assets here.");
+ }
+ }
+ public String[] getChildrenNames(String uri) throws IOException {
+ System.out.println("getChildrenNames :" + uri);
- public InputStream getResourceContent(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- String pkg = path[1];
- String asset = path[2].split("\\.")[0];
- AssetItem assetItem = repository.loadPackage(pkg).loadAsset(asset);
- if (assetItem.isBinary()) {
- return assetItem.getBinaryContentAttachment();
- } else {
- return new ByteArrayInputStream(assetItem.getContent().getBytes());
- }
- } else {
- throw new UnsupportedOperationException();
- }
- }
+ RulesRepository repository = getRepo();
+ String[] path = getPath(uri);
+ List<String> result = new ArrayList<String>();
+ if (path.length == 0) {
+ return new String[] {"packages"};
+ }
+ if (path[0].equals("packages")) {
+ if (path.length > 2) {
+ return null;
+ }
+ if (path.length == 1) {
+ Iterator<PackageItem> it = repository.listPackages();
+ while(it.hasNext()) {
+ PackageItem pkg = it.next();
+ if (!pkg.isArchived()) {
+ result.add(pkg.getName());
+ }
+ }
+ } else {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ Iterator<AssetItem> it = pkg.getAssets();
+ while(it.hasNext()) {
+ AssetItem asset = it.next();
+ if (!asset.isArchived()) {
+ result.add(asset.getName() + "." + asset.getFormat());
+ }
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ } else {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+ }
- public long getResourceLength(String uri) throws IOException {
- //leave this as zero as we don't always know it.
- return 0;
- }
+ public Date getCreationDate(String uri) throws IOException {
+ System.out.println("getCreationDate :" + uri);
- public boolean isFolder(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path.length == 0) return true;
- if (path.length == 1 && path[0].equals("packages")) {
- return true;
- } else {
- return false;
- }
- }
+ RulesRepository repository = getRepo();
+ String[] path = getPath(uri);
+ if (path.length < 2) return new Date();
+ if (path[0].equals("packages")) {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ if (path.length == 2) {
+ //dealing with package
+ return pkg.getCreatedDate().getTime();
+ } else {
+ String fileName = path[2];
+ String assetName = fileName.split("\\.")[0];
+ AssetItem asset = pkg.loadAsset(assetName);
+ return asset.getCreatedDate().getTime();
+ }
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
- public boolean isResource(String uri) throws IOException {
- return !isFolder(uri);
- }
+ public Date getLastModified(String uri) throws IOException {
+ System.out.println("getLastModified :" + uri);
- public boolean objectExists(String uri) throws IOException {
- String[] path = getPath(uri);
- if (path.length == 0) return true;
- if (path.length == 1 && path[0].equals("packages")) {
- return true;
- } else {
- if (path.length == 1) return false;
- if (!repository.containsPackage(path[1])) {
- return false;
- }
+ RulesRepository repository = getRepo();
+ String[] path = getPath(uri);
+ if (path.length < 2) return new Date();
+ if (path[0].equals("packages")) {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ if (path.length == 2) {
+ //dealing with package
+ return pkg.getLastModified().getTime();
+ } else {
+ String fileName = path[2];
+ String assetName = AssetItem.getAssetNameFromFileName(fileName)[0];
+ AssetItem asset = pkg.loadAsset(assetName);
+ return asset.getLastModified().getTime();
+ }
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
- if (path.length == 2) {
- PackageItem pkg = repository.loadPackage(path[1]);
- return !pkg.isArchived();
- } else {
- PackageItem pkg = repository.loadPackage(path[1]);
- String assetName = path[2].split("\\.")[0];
- return pkg.containsAsset(assetName) && !pkg.loadAsset(assetName).isArchived();
- }
- }
- }
- public void removeObject(String uri) throws IOException {
+ public InputStream getResourceContent(String uri) throws IOException {
+ System.out.println("get resource content:" + uri);
+ return getContent(uri);
+ }
+
+ private InputStream getContent(String uri) {
+ RulesRepository repository = getRepo();
String[] path = getPath(uri);
- if (path.length == 0 || path.length == 1) {
- throw new IllegalArgumentException();
- }
- if (path[0].equals("packages")) {
- String packName = path[1];
- PackageItem pkg = repository.loadPackage(packName);
- if (path.length == 3) {
- //delete asset
- String asset = path[2].split("\\.")[0];
- AssetItem item = pkg.loadAsset(asset);
- item.archiveItem(true);
- item.checkin("");
- } else {
- //delete package
- pkg.archiveItem(true);
- pkg.checkin("");
- }
- } else {
- throw new IllegalArgumentException();
- }
-
+ if (path[0].equals("packages")) {
+ String pkg = path[1];
+ String asset = AssetItem.getAssetNameFromFileName(path[2])[0];
+ AssetItem assetItem = repository.loadPackage(pkg).loadAsset(asset);
+ if (assetItem.isBinary()) {
+ return assetItem.getBinaryContentAttachment();
+ } else {
+ return new ByteArrayInputStream(assetItem.getContent().getBytes());
+ }
+ } else {
+ throw new UnsupportedOperationException();
+ }
}
- public void rollback() throws IOException {
- repository.getSession().logout();
- }
+ public long getResourceLength(String uri) throws IOException {
+ System.out.println("get resource length :" + uri);
- public void setResourceContent(String uri, InputStream content, String contentType, String characterEncoding) throws IOException {
+ return 0;
+ }
+
+ public boolean isFolder(String uri) throws IOException {
+ System.out.println("is folder :" + uri);
+ RulesRepository repository = getRepo();
+ String[] path = getPath(uri);
+ if (path.length == 0) return true;
+ if (path.length == 1 && path[0].equals("packages")) {
+ return true;
+ } else if (path.length == 2) {
+ return repository.containsPackage(path[1]);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isResource(String uri) throws IOException {
+ RulesRepository repository = getRepo();
+ System.out.println("is resource :" + uri);
String[] path = getPath(uri);
- if (path[0].equals("packages")) {
- if (path.length != 3) {
- throw new IllegalArgumentException("Not a valid resource path " + uri);
- }
- String packageName = path[1];
- String[] assetName = path[2].split("\\.");
- PackageItem pkg = repository.loadPackage(packageName);
- AssetItem asset = pkg.loadAsset(assetName[0]);
- asset.updateBinaryContentAttachment(content);
- if (shouldCreateNewVersion(asset.getLastModified())) {
- asset.checkin("");
- }
+ if (path.length < 3) return false;
+ if (!path[0].equals("packages")) return false;
+ if (repository.containsPackage(path[1])) {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ return pkg.containsAsset(AssetItem.getAssetNameFromFileName(path[2])[0]);
+ } else {
+ return false;
+ }
- } else {
- throw new UnsupportedOperationException("Unable to save content to this location.");
+ }
+
+ public boolean objectExists(String uri) throws IOException {
+ boolean result = internalObjectExists(uri);
+ if (uri.contains("Premium_Colour_Combinations.brl copy")) {
+ System.out.println("Object exists:" + result);
+ throw new IllegalStateException("URI : " + uri);
}
+ return result;
- //here we could save, or check in, depending on if enough time has passed to justify
- //a new version. Otherwise we will pollute the version history with lots of trivial versions.
- }
+ }
+ public boolean internalObjectExists(String uri) throws IOException {
+ if (uri.contains("Premium_Colour_Combinations.brl copy")) {
+ System.out.println("");
+ }
+ RulesRepository repository = getRepo();
+ System.out.println("object exist check :" + uri);
+ if (uri.endsWith(".DS_Store")) return false;
+ String[] path = getPath(uri);
+ if (path.length == 0) return true;
+ if (path.length == 1 && path[0].equals("packages")) {
+ return true;
+ } else {
+ if (path.length == 1) return false;
+ if (!repository.containsPackage(path[1])) {
+ return false;
+ }
+
+ if (path.length == 2) {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ return !pkg.isArchived();
+ } else {
+ PackageItem pkg = repository.loadPackage(path[1]);
+ String assetName = AssetItem.getAssetNameFromFileName(path[2])[0];
+
+ return pkg.containsAsset(assetName) && !pkg.loadAsset(assetName).isArchived();
+ }
+ }
+ }
+
+ public void removeObject(String uri) throws IOException {
+ RulesRepository repository = getRepo();
+ System.out.println("remove object:" + uri);
+ String[] path = getPath(uri);
+ if (path.length == 0 || path.length == 1) {
+ throw new IllegalArgumentException();
+ }
+ if (path[0].equals("packages")) {
+ String packName = path[1];
+ PackageItem pkg = repository.loadPackage(packName);
+ if (path.length == 3) {
+ //delete asset
+ String asset = path[2].split("\\.")[0];
+ AssetItem item = pkg.loadAsset(asset);
+ item.archiveItem(true);
+ item.checkin("");
+ } else {
+ //delete package
+ pkg.archiveItem(true);
+ pkg.checkin("");
+ }
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ public void rollback() throws IOException {
+ System.out.println("ROLLBACK");
+
+ RulesRepository repository = getRepo();
+ repository.getSession().logout();
+ }
+
+ public void setResourceContent(String uri, InputStream content, String contentType, String characterEncoding) throws IOException {
+ RulesRepository repository = getRepo();
+ System.out.println("set resource content:" + uri);
+ if (uri.endsWith(".DS_Store")) return;
+ String[] path = getPath(uri);
+ if (path[0].equals("packages")) {
+ if (path.length != 3) {
+ throw new IllegalArgumentException("Not a valid resource path " + uri);
+ }
+
+ String packageName = path[1];
+ String[] assetName = AssetItem.getAssetNameFromFileName(path[2]);
+ PackageItem pkg = repository.loadPackage(packageName);
+ AssetItem asset = pkg.loadAsset(assetName[0]);
+ asset.updateBinaryContentAttachment(content);
+ if (shouldCreateNewVersion(asset.getLastModified())) {
+ asset.checkin("");
+ }
+
+
+ } else {
+ throw new UnsupportedOperationException("Unable to save content to this location.");
+ }
+
+ //here we could save, or check in, depending on if enough time has passed to justify
+ //a new version. Otherwise we will pollute the version history with lots of trivial versions.
+ }
+
+
/**
* If enough time has passed, we should create a new version.
*/
- boolean shouldCreateNewVersion(Calendar lastModified) {
- Calendar now = Calendar.getInstance();
- int diff = 86400000; //1 day
- if (now.getTimeInMillis() - lastModified.getTimeInMillis() > diff) {
- return true;
- } else {
- return false;
- }
- }
+ boolean shouldCreateNewVersion(Calendar lastModified) {
+ Calendar now = Calendar.getInstance();
+ int diff = 3600000; //1 hour
+ if (now.getTimeInMillis() - lastModified.getTimeInMillis() > diff) {
+ return true;
+ } else {
+ return false;
+ }
+ }
- String[] getPath(String uri) {
- if (uri.endsWith("webdav") || uri.endsWith("webdav/")) {
- return new String[0];
- }
- return uri.split("webdav/")[1].split("/");
- }
+ String[] getPath(String uri) {
+ if (uri.endsWith("webdav") || uri.endsWith("webdav/")) {
+ return new String[0];
+ }
+ return uri.split("webdav/")[1].split("/");
+ }
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/files/WebDAVImplTest.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/files/WebDAVImplTest.java 2008-05-21 05:07:55 UTC (rev 20088)
+++ labs/jbossrules/trunk/drools-jbrms/src/test/java/org/drools/brms/server/files/WebDAVImplTest.java 2008-05-21 05:16:37 UTC (rev 20089)
@@ -38,7 +38,7 @@
public void testChildrenNames() throws Exception {
WebDAVImpl imp = getImpl();
- RulesRepository repo = imp.repository;
+ RulesRepository repo = imp.getRepo();
String[] children = imp.getChildrenNames("http://goo/webdav/packages");
assertTrue(children.length > 0);
int packageCount = children.length;
@@ -63,6 +63,8 @@
assertEquals("asset1.drl", children[0]);
assertEquals("asset2.dsl", children[1]);
+ children = imp.getChildrenNames("foo/webdav/packages/testWebDavChildNames1/asset1.drl");
+ assertNull(children);
}
@@ -73,7 +75,7 @@
public void testCreateFolder() throws Exception {
WebDAVImpl imp = getImpl();
- RulesRepository repo = imp.repository;
+ RulesRepository repo = imp.getRepo();
String[] children = imp.getChildrenNames("http://goo/webdav/packages");
int packageCount = children.length;
@@ -98,9 +100,21 @@
}
+ public void testDates() throws Exception {
+ String uri = "/foo/webdav";
+ WebDAVImpl imp = getImpl();
+ assertNotNull(imp.getCreationDate(uri));
+ assertNotNull(imp.getLastModified(uri));
+
+ uri = "/foo/webdav/packages";
+ assertNotNull(imp.getCreationDate(uri));
+ assertNotNull(imp.getLastModified(uri));
+
+ }
+
public void testCreateResourceAndCreatedDate() throws Exception {
WebDAVImpl imp = getImpl();
- RulesRepository repo = imp.repository;
+ RulesRepository repo = imp.getRepo();
imp.createFolder("foo/bar/webdav/packages/testCreateResourceDAVFolder");
Thread.sleep(100);
@@ -111,7 +125,15 @@
assertEquals(1, resources.length);
assertEquals("asset.drl", resources[0]);
+ //should be ignored
+ imp.createResource("fpp/bar/webdav/packages/testCreateResourceDAVFolder/._asset.drl");
+ imp.createResource("fpp/bar/webdav/packages/.DS_Store");
+
+
PackageItem pkg = repo.loadPackage("testCreateResourceDAVFolder");
+ assertFalse(pkg.containsAsset("._asset"));
+ assertTrue(pkg.containsAsset("asset"));
+
Iterator<AssetItem> it = pkg.getAssets();
AssetItem ass = it.next();
assertEquals("asset", ass.getName());
@@ -147,7 +169,7 @@
public void testResourceContent() throws Exception {
WebDAVImpl imp = getImpl();
- RulesRepository repo = imp.repository;
+ RulesRepository repo = imp.getRepo();
PackageItem pkg = repo.createPackage("testWebDAVContent", "");
AssetItem asset = pkg.addAsset("asset", "something");
@@ -166,9 +188,17 @@
assertEquals("This is binary", IOUtils.toString(data));
+ AssetItem asset_ = pkg.addAsset("somethingelse", "");
+ asset_.updateFormat("drl");
+ asset_.checkin("");
+ data = imp.getResourceContent("foo/webdav/packages/testWebDAVContent/somethingelse.drl");
+ assertEquals("", IOUtils.toString(data));
+
+
+
}
public void testIsFolder() throws Exception {
@@ -177,13 +207,24 @@
assertTrue(imp.isFolder("/com/foo/webdav/"));
assertTrue(imp.isFolder("/com/foo/webdav/packages"));
assertTrue(imp.isFolder("/com/foo/webdav/packages/"));
- assertFalse(imp.isFolder("/com/foo/webdav/packages/something.drl"));
+ assertFalse(imp.isFolder("/com/foo/webdav/packages/somePackage"));
+
+ imp.createFolder("/com/foo/webdav/packages/testDAVIsFolder");
+ assertTrue(imp.isFolder("/com/foo/webdav/packages/testDAVIsFolder"));
+ assertFalse(imp.isFolder("/com/foo/webdav/packages/somePackage/SomeFile.drl"));
}
public void testIsResource() throws Exception {
WebDAVImpl imp = getImpl();
assertFalse(imp.isResource("/com/foo/webdav/packages"));
- assertTrue(imp.isResource("/com/foo/webdav/packages/Something.drl"));
+ assertFalse(imp.isResource("/com/foo/webdav/packages/somePackage"));
+ assertFalse(imp.isResource("/com/foo/webdav/packages/somePackage/SomeFile.drl"));
+
+ imp.createFolder("/com/foo/webdav/packages/testDAVIsResource");
+ imp.createResource("/com/foo/webdav/packages/testDAVIsResource/SomeFile.drl");
+
+ assertTrue(imp.isResource("/com/foo/webdav/packages/testDAVIsResource/SomeFile.drl"));
+
}
@@ -245,7 +286,7 @@
String result = IOUtils.toString(imp.getResourceContent("/foo/webdav/packages/testSetDavContent/Something.drl"));
assertEquals("some input", result);
- PackageItem pkg = imp.repository.loadPackage("testSetDavContent");
+ PackageItem pkg = imp.getRepo().loadPackage("testSetDavContent");
AssetItem asset = pkg.loadAsset("Something");
assertEquals("drl", asset.getFormat());
assertEquals("some input", asset.getContent());
@@ -258,7 +299,24 @@
}
+ public void testThreadLocal() throws Exception {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ WebDAVImpl i = new WebDAVImpl();
+ assertNull(i.getRepo());
+ try {
+ i.begin(null, null);
+ } catch (Exception e) {
+ fail("should not happen");
+ }
+ assertNotNull(i.getRepo());
+ }
+ });
+ t.start();
+ t.join();
+ }
+
private void assertContains(String string, String[] children) {
for (int i = 0; i < children.length; i++) {
if (children[i].equals(string)) {
More information about the jboss-svn-commits
mailing list