For the readability I havetitled these
*Do a sleep for 10000 in each test before search happens.*
*
*+ @Test(groups = {"wso2.greg.resource"})
+ public void addResource() {
+ try {
+ String resource = frameworkPath + File.separator + ".." +
File.separator + ".." + File.separator + ".." +
+ File.separator + "src" + File.separator + "test" +
File.separator + "java" + File.separator +
+ "resources" + File.separator + resourceName;
+ resourceAdminServiceStub.addResource(wsdlPath + resourceName,
+ "application/wsdl+xml", "test resource", new
DataHandler(new URL("file:///" + resource)), null);
+
+ } catch (Exception e) {
+ fail("Unable to get file content: " + e);
+ log.error("Unable to get file content: " + e.getMessage());
+ }
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
+ }
+ }
+
+
}
*Editing registry xml before server starts*
Index: src/test/java/org/wso2/carbon/registry/RegistryTestServerManager.java
===================================================================
--- src/test/java/org/wso2/carbon/registry/RegistryTestServerManager.java
(revision 122829)
+++ src/test/java/org/wso2/carbon/registry/RegistryTestServerManager.java
(working copy)
@@ -1,7 +1,10 @@
package org.wso2.carbon.registry;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.jaxen.JaxenException;
import org.wso2.carbon.integration.framework.TestServerManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -20,6 +23,7 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.List;
import static org.junit.Assert.fail;
import static org.wso2.carbon.registry.resource.test.TestUtils.*;
@@ -57,8 +61,50 @@
//edit registry xml and add new handle
// editRegistryXML(carbonHome);
+ increaseSearchIndexStartTimeDelay(carbonHome);
}
+ private void increaseSearchIndexStartTimeDelay(String carbonHome) {
+ try {
+
+ String registryXmlPath = carbonHome + File.separator +
"repository" + File.separator
+ + "conf" + File.separator + "registry.xml";
+
+ File registryFile = new File(registryXmlPath);
+ assert registryFile.exists() : registryFile.getAbsolutePath()
+ " does not exist";
+ FileInputStream inputStream = new
FileInputStream(registryFile);
+ OMElement documentElement = new
StAXOMBuilder(inputStream).getDocumentElement();
+ AXIOMXPath xpathExpression = new
AXIOMXPath("/wso2registry/indexingConfiguration/startingDelayInSeconds");
+ OMElement indexConfigNode =
(OMElement)xpathExpression.selectSingleNode(documentElement);
+ indexConfigNode.setText("5");
+
+ AXIOMXPath xpathExpression1 = new
AXIOMXPath("/wso2registry/indexingConfiguration/indexingFrequencyInSeconds");
+ OMElement indexConfigNode1 =
(OMElement)xpathExpression1.selectSingleNode(documentElement);
+ indexConfigNode1.setText("5");
+
+
+ FileOutputStream fileOutputStream = new
FileOutputStream(registryFile);
+ XMLStreamWriter writer =
+
XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream);
+ documentElement.serialize(writer);
+ Thread.sleep(2000);
+
+ } catch (FileNotFoundException e) {
+ log.error("Registry.xml file not found" + e.getMessage());
+ fail("Registry.xml file not found" + e.getMessage());
+ } catch (XMLStreamException e) {
+ log.error("XML stream exception" + e.getMessage());
+ fail("XML stream exception" + e.getMessage());
+ } catch (InterruptedException ignored) {
+
+ } catch (JaxenException e) {
+ log.error("Jaxen exception " + e.getMessage());
+ fail("Jaxen exception" + e.getMessage());
+ }
+
+ }
+
On Sun, Mar 18, 2012 at 12:59 AM, Senaka Fernando <[email protected]> wrote:
> Hi Subash,
>
> Can I see the svn diff of this?
>
> Thanks,
> Senaka.
>
>
> On Sun, Mar 18, 2012 at 12:56 AM, Subash Chaturanga <[email protected]>
wrote:
>>
>> On Sun, Mar 18, 2012 at 12:48 AM, Senaka Fernando <[email protected]>
wrote:
>> > Hi Subash,
>> >
>> > Depends on the timeouts, because it takes sometime for the indexing to
>> > kick-in. But, the waiting time will not make a big difference from
>> > machine
>> > to machine, because if the number of files changed in each run is small
>> > (which is the case for the tests), indexing happens very fast. Can I
>> > also
>> > see the diff of this?
>>
>> This is the original config inside <indexingConfiguration>.
>>
>> <startingDelayInSeconds>300</startingDelayInSeconds>
>> <indexingFrequencyInSeconds>60</indexingFrequencyInSeconds>
>>
>> Changed to
>>
>> <startingDelayInSeconds>5</startingDelayInSeconds>
>> <indexingFrequencyInSeconds>5</indexingFrequencyInSeconds>
>>
>>
>> And also a Thread.sleep(10000); for both tests just before search
>> happens.
>>
>> >
>> > Thanks,
>> > Senaka.
>> >
>> >
>> > On Sun, Mar 18, 2012 at 12:40 AM, Subash Chaturanga <[email protected]>
>> > wrote:
>> >>
>> >> Hi Senaka,
>> >>
>> >> I locally tried $subject as you instructed. And now the content and
>> >> metadata search integration tests runs successfully for greg.
>> >>
>> >> There I have set startingDelayInSeconds and
>> >> indexingFrequencyInSeconds both to 5 seconds and add a 10sec delay for
>> >> tests before search takes place.
>> >> This works fine for me. Shall we include this to the build (which
>> >> should done) ? but AFAIU there can be a chance of failing those tests
>> >> based on the running hardware ?
>> >>
>> >>
>> >> Thanks
>> >> --
>> >>
>> >> Subash Chaturanga
>> >> Software Engineer
>> >> WSO2 Inc. http://wso2.com
>> >>
>> >> email - [email protected]
>> >> phone - 077 2225922
>> >
>> >
>> >
>> >
>> > --
>> > Senaka Fernando
>> > Product Manager - WSO2 Governance Registry;
>> > Associate Technical Lead; WSO2 Inc.; http://wso2.com
>> > Member; Apache Software Foundation; http://apache.org
>> >
>> > E-mail: senaka AT wso2.com
>> > P: +1 408 754 7388; ext: 51736; M: +94 77 322 1818
>> > Linked-In: http://linkedin.com/in/senakafernando
>> >
>> > Lean . Enterprise . Middleware
>> >
>>
>>
>>
>> --
>>
>> Subash Chaturanga
>> Software Engineer
>> WSO2 Inc. http://wso2.com
>>
>> email - [email protected]
>> phone - 077 2225922
>
>
>
>
> --
> Senaka Fernando
> Product Manager - WSO2 Governance Registry;
> Associate Technical Lead; WSO2 Inc.; http://wso2.com
> Member; Apache Software Foundation; http://apache.org
>
> E-mail: senaka AT wso2.com
> P: +1 408 754 7388; ext: 51736; M: +94 77 322 1818
> Linked-In: http://linkedin.com/in/senakafernando
>
> Lean . Enterprise . Middleware
>
--
Subash Chaturanga
Software Engineer
WSO2 Inc. http://wso2.com
email - [email protected]
phone - 077 2225922
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev