import org.jutils.log.Log;
// New variant in cvs (coming release):
//import org.xmlBlaster.util.Log;
import org.xmlBlaster.client.CorbaConnection;
import org.xmlBlaster.client.LoginQosWrapper;
import org.xmlBlaster.client.I_Callback;
import org.xmlBlaster.client.UpdateKey;
import org.xmlBlaster.client.UpdateQoS;
import org.xmlBlaster.util.XmlBlasterException;
import org.xmlBlaster.util.XmlBlasterProperty;
import org.xmlBlaster.engine.helper.MessageUnit;
public class TestBlaster {
/*******************************************/
private final static String ME = "TestBlaster";
private final String senderName = "Manpreet";
private String publishOid = "";
private CorbaConnection senderConnection = null;
private String senderContent;
private final String receiverName = "Harish";
private String passwd = "secret";
/********************************************/
public void login()
{
try {
senderConnection = new CorbaConnection(); // Find orb
String passwd = "secret";
senderConnection.login(senderName, passwd, null); // Login to xmlBlaster
}
catch (Exception e) {
e.printStackTrace();
Log.panic(ME, e.toString());
}
}
public void sendMsg() {
if (Log.TRACE) Log.trace(ME, "Testing point to a unknown destination with NO set ...");
String xmlKey = "\n" +
"";
String qos = "" +
" " +
receiverName +
" " +
"";
senderContent = "Hi " + receiverName + ", who are you? " + senderName;
MessageUnit msgUnit = new MessageUnit(xmlKey, senderContent.getBytes(), qos);
try {
publishOid = senderConnection.publish(msgUnit);
Log.error(ME, "Publishing to a not logged in client should throw an exception");
} catch(XmlBlasterException e){
Log.info(ME, "Exception is correct, client is not logged in");
} //catch ends
}// sendMsg ends
public void clean(){
if (senderConnection != null) senderConnection.logout();
}
public static void main(String args[]){
System.out.println("Hi!");
try { // Initialize command line argument handling (this is optional)
boolean help = XmlBlasterProperty.init(args);
if (help) {
CorbaConnection.usage();
Log.usage();
Log.exit("main", "Example: jaco TestBlaster -iorHost -iorPort 7609\n");
}
} catch(org.jutils.JUtilsException e) {
Log.panic(ME, e.toString());
}
try{
TestBlaster TB = new TestBlaster();
TB.login();
TB.sendMsg();
TB.clean();
}catch(Exception e){
e.printStackTrace();
Log.panic("main", e.getMessage());
}
}
}