mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
For a small but representative subset of the API the remote AVM
interface works. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3502 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
18
config/alfresco/remote-avm-test-context.xml
Normal file
18
config/alfresco/remote-avm-test-context.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
|
||||||
|
"http://www.springframework.org/dtd/spring-beans.dtd">
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<!-- RMI Proxy bean. -->
|
||||||
|
|
||||||
|
<bean id="avmRemote" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
|
||||||
|
<property name="serviceUrl">
|
||||||
|
<value>rmi://localhost:1313/avm</value>
|
||||||
|
</property>
|
||||||
|
<property name="serviceInterface">
|
||||||
|
<value>org.alfresco.repo.avm.AVMRemote</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
106
source/java/org/alfresco/repo/avm/AVMTestRemote.java
Normal file
106
source/java/org/alfresco/repo/avm/AVMTestRemote.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* 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.alfresco.repo.avm;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests of Remote interface to AVM.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class AVMTestRemote extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The AVMRemote.
|
||||||
|
*/
|
||||||
|
private AVMRemote fAVMRemote;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application context.
|
||||||
|
*/
|
||||||
|
private FileSystemXmlApplicationContext fContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception
|
||||||
|
{
|
||||||
|
fContext = new FileSystemXmlApplicationContext("config/alfresco/remote-avm-test-context.xml");
|
||||||
|
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception
|
||||||
|
{
|
||||||
|
fContext.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do a simple hello world test.
|
||||||
|
*/
|
||||||
|
public void testSimple()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<AVMStoreDescriptor> stores = fAVMRemote.getAVMStores();
|
||||||
|
assertTrue(stores.size() > 0);
|
||||||
|
for (AVMStoreDescriptor store : stores)
|
||||||
|
{
|
||||||
|
System.out.println(store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test reading and writing.
|
||||||
|
*/
|
||||||
|
public void testReadWrite()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create a directory.
|
||||||
|
fAVMRemote.createDirectory("main:/", "a");
|
||||||
|
// Write out a file.
|
||||||
|
String outHandle = fAVMRemote.createFile("main:/a", "foo.txt");
|
||||||
|
byte [] buff = "This is a plain old text file.\n".getBytes();
|
||||||
|
fAVMRemote.writeOutput(outHandle, buff, buff.length);
|
||||||
|
buff = "It contains text.\n".getBytes();
|
||||||
|
fAVMRemote.writeOutput(outHandle, buff, buff.length);
|
||||||
|
fAVMRemote.closeOutputHandle(outHandle);
|
||||||
|
// Read back that file.
|
||||||
|
String inHandle = fAVMRemote.getInputHandle(-1, "main:/a/foo.txt");
|
||||||
|
buff = fAVMRemote.readInput(inHandle, 1024);
|
||||||
|
fAVMRemote.closeInputHandle(inHandle);
|
||||||
|
System.out.print(new String(buff));
|
||||||
|
fAVMRemote.removeNode("main:/", "a");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user