public class IdmGetSSOToken
{
public IdmGetSSOToken()
{
System.out.println("IdmGetSSOToken Default Constructor");
}
protected SSOToken getToken(String name, String password, String basedn)
throws Exception
{
System.out.println("INSIDE GETTOKEN");
String s = name;
String s1 = password;
String s2 = basedn;
System.out.println("name=" + name);
System.out.println("password=" + password);
System.out.println("basedn=" + basedn);
...
}
}
Here is my derived class:
@Test(sequential = true)
public class IdmCleanup extends IdmGetSSOToken
{
String s1 = null;
String s2 = null;
String s3 = null;
@Test(parameters={"amadmin.user","amadmin.password","basedn"})
public void IdmCleanup(String s1, String s2, String s3)
throws IdRepoException, SSOException
{
System.out.println("INSIDE CLEANUP CONST");
s1 = s1;
s2 = s2;
s3 = s3;
System.out.println("name1=" + s1);
System.out.println("password1=" + s2);
System.out.println("basedn1=" + s3);
}
public void Cleanup()
throws IdRepoException, SSOException
{
System.out.println("INSIDE CLEANUP");
ssotoken = getToken(s1, s2, s3); (defined in base class)
...
}
}
And here is my testing.xml:
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="server" >
<parameter name="amadmin.user" value="amadmin"/>
<parameter name="amadmin.password" value="secret12"/>
<parameter name="basedn" value="dc=red,dc=iplanet,dc=com"/>
<test name="idm1" >
<classes>
<class name="IdmCleanup"/>
</classes>
</test>
</suite>
And here is the problem:
When I execute the calling trace is as follows:
[java] IdmGetSSOToken Default Constructor (default constructor of base class)
[java] INSIDE CLEANUP (method in derived class)
[java] INSIDE GETTOKEN (method in base class)
[java] name=null
[java] password=null
[java] basedn=null
[java] INSIDE CLEANUP CONST (default constructor in derived class)
[java] name1=amadmin
[java] password1=secret12
[java] basedn1=dc=red,dc=iplanet,dc=com
What I am trying to do:
Basically pass some parameters to the derived class, which can be consumed by the program. But the problem I am facing is that the CONSTRUCTOR of the derived class is called last and hence I dont get access to parameters at the right time. It should have been called after the consrtuctor of the base class was called. I even tried the new (sequential=true) stuff but still got the same result. Why is the constructor of the derived class called last? It should have been called first? How can I solve this? I need access to passed parameters at the start of the program, not at the end of it.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=40655&messageID=80944#80944
Here is my base class:
public class IdmGetSSOToken
{
public IdmGetSSOToken()
{
System.out.println("IdmGetSSOToken Default Constructor");
}
protected SSOToken getToken(String name, String password, String basedn)
throws Exception
{
System.out.println("INSIDE GETTOKEN");
String s = name;
String s1 = password;
String s2 = basedn;
System.out.println ("name=" + name);
I changed the parameter names and it worked fine. But technically speaking it should have worked but I do agree with you; its a bad thing to do. Thanks
execute-common-server:
[java] IdmGetSSOToken Default Constructor (constructor in base class)
[java] INSIDE CLEANUP (method of interest in derived class)
[java] name=null
[java] password=null
[java] basedn=null
[java] name1=amadmin (constructor in derived class)
[java] password1=secret12
[java] basedn1=dc=red,dc=iplanet,dc=com
[java] ===============================================
[java] server
[java] Total tests run: 2, Failures: 1, Skips: 0
[java] ===============================================
[java] Java Result: 1
It still 1st calls the default constructor of the base class, than calls the method of interest in the derived class and than calls the constructor of the derived class. It should have been the other way round for the last two calls.
I was able to get what I want by using dependsonmethod, but thats a different way to go about it all together. The constructor calling issue still remains.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=40655&messageID=80955#80955
Hence the call order should be 1->2->3
Whats happening is 1->3->2.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=40655&messageID=80976#80976