You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2006/03/04 16:47:42 UTC
svn commit: r383144 - in
/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src:
main/java/org/apache/cocoon/deployer/filemanager/
test/java/org/apache/cocoon/deployer/filemanager/
Author: reinhard
Date: Sat Mar 4 07:47:41 2006
New Revision: 383144
URL: http://svn.apache.org/viewcvs?rev=383144&view=rev
Log:
svn:eol-style
Modified:
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java (contents, props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java (contents, props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java (contents, props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java (contents, props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java (contents, props changed)
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java?rev=383144&r1=383143&r2=383144&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java Sat Mar 4 07:47:41 2006
@@ -1,35 +1,35 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.deployer.filemanager;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * A simple interface that makes it possible to implement different ways of doing filesystem operations,
- * may it be transaction or non-transaction.
- */
-public interface FileManager {
-
- public InputStream readResource(String resource) throws FileManagerException;
-
- public OutputStream writeResource(String string) throws FileManagerException;
-
- public void rollbackTransaction(Exception ex) throws FileManagerException;
-
- public void commitTransaction() throws FileManagerException;
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.deployer.filemanager;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * A simple interface that makes it possible to implement different ways of doing filesystem operations,
+ * may it be transaction or non-transaction.
+ */
+public interface FileManager {
+
+ public InputStream readResource(String resource) throws FileManagerException;
+
+ public OutputStream writeResource(String string) throws FileManagerException;
+
+ public void rollbackTransaction(Exception ex) throws FileManagerException;
+
+ public void commitTransaction() throws FileManagerException;
+
+}
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java?rev=383144&r1=383143&r2=383144&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java Sat Mar 4 07:47:41 2006
@@ -1,24 +1,24 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.deployer.filemanager;
-
-public class FileManagerException extends Exception {
-
- public FileManagerException(Throwable e) {
- super(e);
- }
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.deployer.filemanager;
+
+public class FileManagerException extends Exception {
+
+ public FileManagerException(Throwable e) {
+ super(e);
+ }
+
+}
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/FileManagerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java?rev=383144&r1=383143&r2=383144&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java Sat Mar 4 07:47:41 2006
@@ -1,99 +1,99 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.deployer.filemanager;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cocoon.deployer.DeploymentException;
-import org.apache.cocoon.deployer.util.FileUtils;
-import org.apache.commons.lang.Validate;
-
-/**
- * This implementation provides non-transaction file system operations.
- */
-public class NontransactionalFileManager implements FileManager {
-
- private File basedir;
- private List fosList = new ArrayList();
-
- public NontransactionalFileManager(URI basedir) {
- Validate.notNull(basedir, "basedir mustn't be null.");
- this.basedir = new File(basedir);
- if(!this.basedir.exists()) {
- if(!this.basedir.mkdirs()) {
- throw new DeploymentException("Can't create the base directory '" + this.basedir + "'.");
- }
- }
- }
-
- public InputStream readResource(String resource) throws FileManagerException {
- Validate.notNull(resource, "resource mustn't be null.");
- try {
- return new FileInputStream(new File(this.basedir, cleanResource(resource)));
- } catch (FileNotFoundException e) {
- throw new FileManagerException(e);
- }
- }
-
- public OutputStream writeResource(String resource) throws FileManagerException {
- Validate.notNull(resource, "resource mustn't be null.");
- try {
- FileOutputStream fos = new FileOutputStream(FileUtils.createDirectory(new File(this.basedir, resource)));
- fosList.add(fos);
- return fos;
- } catch (FileNotFoundException e) {
- throw new FileManagerException(e);
- } catch (IOException e) {
- throw new FileManagerException(e);
- }
- }
-
- public void rollbackTransaction(Exception ex) throws FileManagerException {
- closeFileOutputStreams();
- throw new DeploymentException("Can't rollback when using a nontransactional implementation.", ex);
- }
-
- public void commitTransaction() throws FileManagerException {
- closeFileOutputStreams();
- }
-
- private void closeFileOutputStreams() throws FileManagerException {
- for(int i = 0; i < fosList.size(); i++) {
- try {
- ((FileOutputStream) fosList.get(i)).close();
- } catch (IOException e) {
- throw new FileManagerException(e);
- }
- }
- }
-
- protected String cleanResource(String resource) {
- if(resource.startsWith("\\") || resource.startsWith("/")) {
- return resource.substring(1);
- }
- return resource;
- }
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.deployer.filemanager;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cocoon.deployer.DeploymentException;
+import org.apache.cocoon.deployer.util.FileUtils;
+import org.apache.commons.lang.Validate;
+
+/**
+ * This implementation provides non-transaction file system operations.
+ */
+public class NontransactionalFileManager implements FileManager {
+
+ private File basedir;
+ private List fosList = new ArrayList();
+
+ public NontransactionalFileManager(URI basedir) {
+ Validate.notNull(basedir, "basedir mustn't be null.");
+ this.basedir = new File(basedir);
+ if(!this.basedir.exists()) {
+ if(!this.basedir.mkdirs()) {
+ throw new DeploymentException("Can't create the base directory '" + this.basedir + "'.");
+ }
+ }
+ }
+
+ public InputStream readResource(String resource) throws FileManagerException {
+ Validate.notNull(resource, "resource mustn't be null.");
+ try {
+ return new FileInputStream(new File(this.basedir, cleanResource(resource)));
+ } catch (FileNotFoundException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+ public OutputStream writeResource(String resource) throws FileManagerException {
+ Validate.notNull(resource, "resource mustn't be null.");
+ try {
+ FileOutputStream fos = new FileOutputStream(FileUtils.createDirectory(new File(this.basedir, resource)));
+ fosList.add(fos);
+ return fos;
+ } catch (FileNotFoundException e) {
+ throw new FileManagerException(e);
+ } catch (IOException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+ public void rollbackTransaction(Exception ex) throws FileManagerException {
+ closeFileOutputStreams();
+ throw new DeploymentException("Can't rollback when using a nontransactional implementation.", ex);
+ }
+
+ public void commitTransaction() throws FileManagerException {
+ closeFileOutputStreams();
+ }
+
+ private void closeFileOutputStreams() throws FileManagerException {
+ for(int i = 0; i < fosList.size(); i++) {
+ try {
+ ((FileOutputStream) fosList.get(i)).close();
+ } catch (IOException e) {
+ throw new FileManagerException(e);
+ }
+ }
+ }
+
+ protected String cleanResource(String resource) {
+ if(resource.startsWith("\\") || resource.startsWith("/")) {
+ return resource.substring(1);
+ }
+ return resource;
+ }
+
+}
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java?rev=383144&r1=383143&r2=383144&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java Sat Mar 4 07:47:41 2006
@@ -1,131 +1,131 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.deployer.filemanager;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Random;
-import java.util.logging.Logger;
-
-import org.apache.cocoon.deployer.DeploymentException;
-import org.apache.cocoon.deployer.util.FileUtils;
-import org.apache.commons.transaction.file.FileResourceManager;
-import org.apache.commons.transaction.file.ResourceManagerException;
-import org.apache.commons.transaction.file.ResourceManagerSystemException;
-import org.apache.commons.transaction.util.Jdk14Logger;
-
-/**
- * This implementation provides transactional file system operations.
- */
-public class TransactionalFileManager implements FileManager {
-
- private static final Logger logger = Logger.getLogger(TransactionalFileManager.class.getName());
-
- /**
- * The FileResourceManager that actually provides transactional filesystem operations
- */
- private FileResourceManager frm;
-
- /**
- * The transaction id for all operations of this object.
- */
- private String txId;
-
- /**
- * The working directory of the FileResourceManager
- */
- private File workdir;
-
- public TransactionalFileManager(URI basedir) {
- // create the output directory
- File outputdir = new File(basedir);
-
- if(!outputdir.exists()) {
- if(!outputdir.mkdirs()) {
- throw new DeploymentException("Can't create server directory: " + outputdir.getAbsolutePath());
- }
- }
-
- // create the workdir for the FileResourceManager
- try {
- this.workdir = new File(new URI(basedir + "_WORK"));
- } catch (URISyntaxException ue) {
- throw new DeploymentException("Can't create work directory", ue);
- }
- if(workdir.exists()) {
- FileUtils.deleteDirRecursivly(workdir);
- }
-
- if(!workdir.mkdirs()) {
- throw new DeploymentException("Can't create work directory");
- }
-
- // create a random transaction id
- Random rand = new Random();
- txId = Long.toString(rand.nextLong());
- System.out.println("txId: " + txId);
-
- // create transaction context
- frm = new FileResourceManager(outputdir.getAbsolutePath(), workdir.getAbsolutePath(), false, new Jdk14Logger(logger));
- try {
- frm.start();
- frm.startTransaction(txId);
- } catch (ResourceManagerSystemException e) {
- throw new DeploymentException("A problem while starting the filesystem transaction manager occurred.");
- } catch (ResourceManagerException e) {
- throw new DeploymentException("A problem while starting the filesystem transaction manager occurred.");
- }
- }
-
- public InputStream readResource(String resource) throws FileManagerException {
- try {
- return frm.readResource(this.txId, resource);
- } catch (ResourceManagerException e) {
- throw new FileManagerException(e);
- }
- }
-
- public OutputStream writeResource(String resource) throws FileManagerException {
- try {
- return frm.writeResource(this.txId, resource);
- } catch (ResourceManagerException e) {
- throw new FileManagerException(e);
- }
- }
-
- public void rollbackTransaction(Exception ex) throws FileManagerException {
- // do nothing with exception
- try {
- frm.rollbackTransaction(this.txId);
- FileUtils.deleteDirRecursivly(this.workdir);
- } catch (ResourceManagerException e) {
- throw new FileManagerException(e);
- }
- }
-
- public void commitTransaction() throws FileManagerException {
- try {
- frm.commitTransaction(this.txId);
- FileUtils.deleteDirRecursivly(this.workdir);
- } catch (ResourceManagerException e) {
- throw new FileManagerException(e);
- }
- }
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.deployer.filemanager;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Random;
+import java.util.logging.Logger;
+
+import org.apache.cocoon.deployer.DeploymentException;
+import org.apache.cocoon.deployer.util.FileUtils;
+import org.apache.commons.transaction.file.FileResourceManager;
+import org.apache.commons.transaction.file.ResourceManagerException;
+import org.apache.commons.transaction.file.ResourceManagerSystemException;
+import org.apache.commons.transaction.util.Jdk14Logger;
+
+/**
+ * This implementation provides transactional file system operations.
+ */
+public class TransactionalFileManager implements FileManager {
+
+ private static final Logger logger = Logger.getLogger(TransactionalFileManager.class.getName());
+
+ /**
+ * The FileResourceManager that actually provides transactional filesystem operations
+ */
+ private FileResourceManager frm;
+
+ /**
+ * The transaction id for all operations of this object.
+ */
+ private String txId;
+
+ /**
+ * The working directory of the FileResourceManager
+ */
+ private File workdir;
+
+ public TransactionalFileManager(URI basedir) {
+ // create the output directory
+ File outputdir = new File(basedir);
+
+ if(!outputdir.exists()) {
+ if(!outputdir.mkdirs()) {
+ throw new DeploymentException("Can't create server directory: " + outputdir.getAbsolutePath());
+ }
+ }
+
+ // create the workdir for the FileResourceManager
+ try {
+ this.workdir = new File(new URI(basedir + "_WORK"));
+ } catch (URISyntaxException ue) {
+ throw new DeploymentException("Can't create work directory", ue);
+ }
+ if(workdir.exists()) {
+ FileUtils.deleteDirRecursivly(workdir);
+ }
+
+ if(!workdir.mkdirs()) {
+ throw new DeploymentException("Can't create work directory");
+ }
+
+ // create a random transaction id
+ Random rand = new Random();
+ txId = Long.toString(rand.nextLong());
+ System.out.println("txId: " + txId);
+
+ // create transaction context
+ frm = new FileResourceManager(outputdir.getAbsolutePath(), workdir.getAbsolutePath(), false, new Jdk14Logger(logger));
+ try {
+ frm.start();
+ frm.startTransaction(txId);
+ } catch (ResourceManagerSystemException e) {
+ throw new DeploymentException("A problem while starting the filesystem transaction manager occurred.");
+ } catch (ResourceManagerException e) {
+ throw new DeploymentException("A problem while starting the filesystem transaction manager occurred.");
+ }
+ }
+
+ public InputStream readResource(String resource) throws FileManagerException {
+ try {
+ return frm.readResource(this.txId, resource);
+ } catch (ResourceManagerException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+ public OutputStream writeResource(String resource) throws FileManagerException {
+ try {
+ return frm.writeResource(this.txId, resource);
+ } catch (ResourceManagerException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+ public void rollbackTransaction(Exception ex) throws FileManagerException {
+ // do nothing with exception
+ try {
+ frm.rollbackTransaction(this.txId);
+ FileUtils.deleteDirRecursivly(this.workdir);
+ } catch (ResourceManagerException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+ public void commitTransaction() throws FileManagerException {
+ try {
+ frm.commitTransaction(this.txId);
+ FileUtils.deleteDirRecursivly(this.workdir);
+ } catch (ResourceManagerException e) {
+ throw new FileManagerException(e);
+ }
+ }
+
+}
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/filemanager/TransactionalFileManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java?rev=383144&r1=383143&r2=383144&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java Sat Mar 4 07:47:41 2006
@@ -1,70 +1,70 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.deployer.filemanager;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.cocoon.deployer.AbstractDeployerTestCase;
-import org.apache.cocoon.deployer.util.FileUtils;
-
-public class NontransactionalFileManagerTest extends AbstractDeployerTestCase {
-
- private static final String EXISTING_RESOURCE = "lib-01/lib-01.jar";
- private static final String NOT_EXISTING_RESOURCE = "lib-01/lib-01.jar_______";
-
- public void testWrite() throws Exception {
- File basedir = new File(AbstractDeployerTestCase.OUTPUT_DIR, "/xyz/abc");
- String fileName = "x.txt";
-
- FileManager fm = new NontransactionalFileManager(basedir.toURI());
-
- OutputStream os = fm.writeResource(fileName);
- InputStream is = new FileInputStream(this.getMockArtefact(EXISTING_RESOURCE));
- FileUtils.copy(is, os);
- fm.commitTransaction();
-
- assertTrue(new File(basedir, fileName).exists());
- }
-
- public void testRead() throws Exception {
- File basedir = new File(this.MOCKS_DIR);
- InputStream is = new NontransactionalFileManager(basedir.toURI()).readResource(EXISTING_RESOURCE);
- }
-
- public void testReadNotExistingFile() throws Exception {
- File basedir = new File(this.MOCKS_DIR);
- try {
- InputStream is = new NontransactionalFileManager(basedir.toURI()).readResource(NOT_EXISTING_RESOURCE);
- fail("A non-existing file has to throw an exception.");
- } catch(FileManagerException fme) {
- // expected
- }
-
- }
-
- public void testNontransactionFileManagerWithNullBasedir() throws Exception {
- try {
- FileManager fm = new NontransactionalFileManager(null);
- fail("Null basedir mustn't be allowed.");
- } catch(IllegalArgumentException iae) {
- // expected
- }
- }
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.deployer.filemanager;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.cocoon.deployer.AbstractDeployerTestCase;
+import org.apache.cocoon.deployer.util.FileUtils;
+
+public class NontransactionalFileManagerTest extends AbstractDeployerTestCase {
+
+ private static final String EXISTING_RESOURCE = "lib-01/lib-01.jar";
+ private static final String NOT_EXISTING_RESOURCE = "lib-01/lib-01.jar_______";
+
+ public void testWrite() throws Exception {
+ File basedir = new File(AbstractDeployerTestCase.OUTPUT_DIR, "/xyz/abc");
+ String fileName = "x.txt";
+
+ FileManager fm = new NontransactionalFileManager(basedir.toURI());
+
+ OutputStream os = fm.writeResource(fileName);
+ InputStream is = new FileInputStream(this.getMockArtefact(EXISTING_RESOURCE));
+ FileUtils.copy(is, os);
+ fm.commitTransaction();
+
+ assertTrue(new File(basedir, fileName).exists());
+ }
+
+ public void testRead() throws Exception {
+ File basedir = new File(this.MOCKS_DIR);
+ InputStream is = new NontransactionalFileManager(basedir.toURI()).readResource(EXISTING_RESOURCE);
+ }
+
+ public void testReadNotExistingFile() throws Exception {
+ File basedir = new File(this.MOCKS_DIR);
+ try {
+ InputStream is = new NontransactionalFileManager(basedir.toURI()).readResource(NOT_EXISTING_RESOURCE);
+ fail("A non-existing file has to throw an exception.");
+ } catch(FileManagerException fme) {
+ // expected
+ }
+
+ }
+
+ public void testNontransactionFileManagerWithNullBasedir() throws Exception {
+ try {
+ FileManager fm = new NontransactionalFileManager(null);
+ fail("Null basedir mustn't be allowed.");
+ } catch(IllegalArgumentException iae) {
+ // expected
+ }
+ }
+
+}
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/filemanager/NontransactionalFileManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native