The ConfigParams class is, I believe, derived from the Configuration
class.  So, you can create a ConfigParams object instead of a
Configuration object if you want to use the API in the manner you
describe.

The reason your commented-out code doesn't work is because the
setParameter() method isn't doing quite what you are expecting.  It's
creating a node named "_PARAMETER_" with a "name" attribute and a
value area, and you are creating nodes named by the parameter name.

Karl

On Wed, Aug 3, 2011 at 12:41 PM, Piergiorgio Lucidi
<piergiorgioluc...@gmail.com> wrote:
> I'm trying to implement tests but I found a problem to set all the needed
> parameters to the CMIS Repository Connector that needs: an username, a
> password and the endpoint (url).
>
> I need to know how to create the configuration nodes for the connector, in
> the connector code I managed the configuration parameters in this way in the
> processConfigurationPost method:
>
>  public String processConfigurationPost(IThreadContext threadContext,
>>       IPostParameters variableContext, ConfigParams parameters)
>>       throws ManifoldCFException {
>>     String username = variableContext.getParameter(CONFIG_PARAM_USERNAME);
>>     if (StringUtils.isNotEmpty(username))
>>       parameters.setParameter(CONFIG_PARAM_USERNAME, username);
>>     String password = variableContext.getParameter(CONFIG_PARAM_PASSWORD);
>>     if (StringUtils.isNotEmpty(password))
>>       parameters.setParameter(CONFIG_PARAM_PASSWORD, password);
>>     String endpoint = variableContext.getParameter(CONFIG_PARAM_ENDPOINT);
>>     if (StringUtils.isNotEmpty(endpoint) && endpoint.length() > 0)
>>       parameters.setParameter(CONFIG_PARAM_ENDPOINT, endpoint);
>>     String repositoryId = variableContext
>>         .getParameter(CONFIG_PARAM_REPOSITORY_ID);
>>     if (StringUtils.isNotEmpty(repositoryId))
>>       parameters.setParameter(CONFIG_PARAM_REPOSITORY_ID, repositoryId);
>>     return null;
>>   }
>
>
> Now I have to setup the same parameters inside my test class APISanityTest
> that doesn't like the following snippet, it works only if CMIS parameters
> are commented as the following:
>
>  @Test
>>   public void sanityCheck()
>>     throws Exception
>>   {
>>     try
>>     {
>>       // Hey, we were able to install the file system connector etc.
>>       // Now, create a local test job and run it.
>>       IThreadContext tc = ThreadContextFactory.make();
>>       int i;
>>       IJobManager jobManager = JobManagerFactory.make(tc);
>>       // Create a basic file system connection, and save it.
>>       ConfigurationNode connectionObject;
>>       ConfigurationNode child;
>>       Configuration requestObject;
>>       Configuration result;
>>
>>       connectionObject = new ConfigurationNode("repositoryconnection");
>>
>>       child = new ConfigurationNode("name");
>>       child.setValue("CMIS Connection");
>>       connectionObject.addChild(connectionObject.getChildCount(),child);
>>
>>       child = new ConfigurationNode("class_name");
>>       child.setValue(
>> "org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector");
>>       connectionObject.addChild(connectionObject.getChildCount(),child);
>>
>>       child = new ConfigurationNode("description");
>>       child.setValue("CMIS Connection");
>>       connectionObject.addChild(connectionObject.getChildCount(),child);
>>       child = new ConfigurationNode("max_connections");
>>       child.setValue("10");
>>       connectionObject.addChild(connectionObject.getChildCount(),child);
>>
>>       //setting the CMIS specific parameters
>> //      child = new ConfigurationNode("username");
>> //      child.setValue(CMIS_USERNAME);
>> //      connectionObject.addChild(connectionObject.getChildCount(),child);
>> //
>> //      child = new ConfigurationNode("password");
>> //      child.setValue(CMIS_PASSWORD);
>> //      connectionObject.addChild(connectionObject.getChildCount(),child);
>> //
>> //      child = new ConfigurationNode("endpoint");
>> //      child.setValue(CMIS_ENDPOINT_TEST_SERVER);
>> //      connectionObject.addChild(connectionObject.getChildCount(),child);
>>       requestObject = new Configuration();
>>       requestObject.addChild(0,connectionObject);
>>
>>       result = performAPIPutOperationViaNodes(
>> "repositoryconnections/CMIS%20Connection",201,requestObject);
>
>
> How can I set the username, password and endpoint for the CMIS Repository
> Connector parameters in this test class?
>
> Thank you.
>
> Piergiorgio
>
>
> 2011/8/2 Karl Wright <daddy...@gmail.com>
>
>> Thanks for the status report.  I hope to see your patch soon!
>>
>> Also, FWIW, once the documentation is also done I'd like to consider
>> solidifying the 0.3 release.  It's got a lot of good stuff in it and I
>> think as soon as we've finished off the new CMIS connector in all
>> dimensions we should go ahead.  Thoughts, anyone?
>>
>> Karl
>>
>>
>> On Tue, Aug 2, 2011 at 5:00 AM, Piergiorgio Lucidi
>> <piergiorgioluc...@gmail.com> wrote:
>> > Yesterday I started to work on end-to-end integration test for the CMIS
>> > Connector and now I have a full running OpenCMIS test server integrated
>> with
>> > the ManifoldCF Maven build process.
>> >
>> > Now I have to implement:
>> > - a setup method to create the test documents in the CMIS server
>> > - a null output connector using the ManifoldCF api
>> > - tests using the ManifoldCF api to create a mock configuration against
>> the
>> > test CMIS server
>> >
>> > I'll let you know when it works.
>> >
>> > Regards,
>> > Piergiorgio
>> >
>> > 2011/7/29 Piergiorgio Lucidi <piergiorgioluc...@gmail.com>
>> >
>> >> Hi Karl,
>> >>
>> >> thank you for the details and as soon as I finish a first version of
>> >> integration and/or unit test I will create a new ticket in the CMIS
>> >> Component to release the patch.
>> >>
>> >> I hope to release this new patch soon.
>> >> I'll let you know during the next week.
>> >>
>> >> Piergiorgio
>> >>
>> >>
>> >> 2011/7/28 Karl Wright <daddy...@gmail.com>
>> >>
>> >>> The tests/filesystem/src/test/java area are end-to-end tests
>> >>> principally designed to test the filesystem connector.  (They also
>> >>> involve other connectors because, obviously, an end-to-end test is not
>> >>> going going to work without them.  This is why they are at the root
>> >>> level.)
>> >>>
>> >>> There are also unit tests you can use as models under
>> >>> connectors/filesystem/connector/src/test/....  These tests use only
>> >>> the filesystem connector, no others.
>> >>>
>> >>> If you would be so kind as to create a ticket to cover your test work,
>> >>> that would be great.
>> >>>
>> >>> Also, another workitem I've been meaning to get to but haven't
>> >>> involves the conversion of a python-based HTML browser and Javascript
>> >>> engine I wrote for MetaCarta into a Java equivalent.  This would allow
>> >>> direct testing of the UI components of the framework and connectors.
>> >>> The python sources are in:
>> >>>
>> >>> legacy-tests/VirtualBrowser.py
>> >>> and
>> >>> legacy-tests/Javascript.py
>> >>>
>> >>> You may not have time to get that far for a while, but I thought you'd
>> >>> want to know where my thoughts were headed. ;-)
>> >>>
>> >>> Karl
>> >>>
>> >>> On Thu, Jul 28, 2011 at 2:03 PM, Piergiorgio Lucidi
>> >>> <piergiorgioluc...@gmail.com> wrote:
>> >>> > I'm starting to think a way to implement tests for the CMIS
>> Connector,
>> >>> > probably I can use the Apache Chemistry (OpenCMIS) local binding to
>> >>> create a
>> >>> > mock of a CMIS Server (an InMemory repository), but I have to check
>> this
>> >>> > possibility because I'm not sure that all the features are now
>> >>> implemented.
>> >>> >
>> >>> > Anyway I saw some test classes for the filesystem connector at the
>> >>> following
>> >>> > package:
>> >>> >
>> >>> > tests/filesystem/src/test/java
>> >>> >
>> >>> > Could you please confirm that these classes could be taken as an
>> example
>> >>> for
>> >>> > tests?
>> >>> > Or do I need to take a look at other classes?
>> >>> >
>> >>> > Thank you.
>> >>> > Piergiorgio
>> >>> >
>> >>> > --
>> >>> > Piergiorgio Lucidi
>> >>> > Web: http://about.me/piergiorgiolucidi
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Piergiorgio Lucidi
>> >> Web: http://about.me/piergiorgiolucidi
>> >>
>> >>
>> >
>> >
>> > --
>> > Piergiorgio Lucidi
>> > Web: http://about.me/piergiorgiolucidi
>> >
>>
>
>
>
> --
> Piergiorgio Lucidi
> Web: http://about.me/piergiorgiolucidi
>

Reply via email to