TestUnit

Hi everybody,
I'm implementing a new program in Java and i wish to test it by using TestUnit; a test frame for java.
The problem is that I never did that before. Can anybody tell me where can find some documentation/manual about "Using TestUnit".
Thnx,

I don't know much about "TestUnit", but for unit testing the best that I found is JUnit. I would highly recommend it.
http://www.junit.org/index.htm

Similar Messages

  • Generate XML file with Elements and attributes from Oracle table

    Hi,
    I have the following table structure.
    CREATE TABLE COIL
    COIL_ID                         NUMBER(10),
    COIL_NUMBER                    VARCHAR2(40),
    COIL_PO_OPERATING_UNIT     VARCHAR2(20),
    COIL_PO_NUMBER               VARCHAR2(40),
    MILL_NUMBER                    VARCHAR2(2),
    MILL_COIL_STATUS          VARCHAR2(15),
    ITEM_NUMBER                    VARCHAR2(40),
    COIL_WEIGHT                    NUMBER(38),
    WEIGHT_UOM                    VARCHAR2(10),
    DOCUMENT_NUMBER               VARCHAR2(40),
    DOCUMENT_DATE               DATE,
    DOCUMENT_STATUS               VARCHAR2(15),
    DOCUMENT_TYPE               VARCHAR2(20),
    DOCUMENT_SOURCE               VARCHAR2(20),
    TEST_ID                         NUMBER(38),
    VALUE                         NUMBER,
    TEST_UOM                    VARCHAR2(20),
    TEST_STATUS               VARCHAR2(70),
    TESTER_LOGIN               VARCHAR2(20),
    EQUIPMENT_CODE               VARCHAR2(50),
    DOC_STS_MSG               VARCHAR2(600)
    For each COILID record, there could be multiple records baased on TEST_ID/VALUE/TEST_UOM etc.
    And I would like to prepare xml file in the following format by selecting data from COIL?
    <?xml version="1.0"?>
    -<Coil xsi:noNamespaceSchemaLocation="www.tempel.com/COIL.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdb="http://xmlns.oracle.com/xdb">
    <CoilId>1419532</CoilId>
    <CoilNo>D2221050010A0</CoilNo>
    <CoilPOOperatingUnit>Changzhou</CoilPOOperatingUnit>
    <CoilPONo>4619</CoilPONo>
    <MillNo>86</MillNo>
    <MillCoilStatus>Test</MillCoilStatus>
    <ItemNo>050FP800 C5</ItemNo>
    <Weight>7076</Weight>
    <UOM>KILOGRAM</UOM>
    <DocumentNo>0</DocumentNo>
    <DocumentDate>2013-01-11</DocumentDate>
    <DocumentStatus>NonProcessed</DocumentStatus>
    <DocumentType>Tests</DocumentType>
    <DocumentSource>CHIGMA1</DocumentSource>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.4992" TestUnit="mm" Status="NonProcessed" TestId="135"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.0128" TestUnit="mm" Status="NonProcessed" TestId="124"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="12" TestUnit="mm" Status="NonProcessed" TestId="125"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.5095" TestUnit="mm" Status="NonProcessed" TestId="127"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.5042" TestUnit="mm" Status="NonProcessed" TestId="128"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.5058" TestUnit="mm" Status="NonProcessed" TestId="129"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.4967" TestUnit="mm" Status="NonProcessed" TestId="130"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.5049" TestUnit="mm" Status="NonProcessed" TestId="131"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.4972" TestUnit="mm" Status="NonProcessed" TestId="132"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.4960" TestUnit="mm" Status="NonProcessed" TestId="133"/>
    <Tests DocStsMsg="0" EquipmentCode="CHIGMA1" TesterLogin="dpkrueger" Value="0.4996" TestUnit="mm" Status="NonProcessed" TestId="134"/>
    </Coil>
    Can you please guide me how to do it in a single query?
    Thanks in advance.

    Hi Odie,
    Thanks for the quick offer.Sure,No problem.I expect the format to be as follows
    <Coil xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="www.tempel.com/COIL.xsd">
    <CoilId>97239</CoilId>
    <CoilNo>777078</CoilNo>
    <CoilPOOperatingUnit>TSUSA</CoilPOOperatingUnit>
    <CoilPONo>3407</CoilPONo>
    <MillNo>31</MillNo>
    <MillCoilStatus>Test</MillCoilStatus>
    <ItemNo>0140SP150 C5A</ItemNo>
    <Weight>17365</Weight>
    <UOM>POUNDS</UOM>
    <DocumentNo>0</DocumentNo>
    <DocumentDate>2008-10-13</DocumentDate>
    <DocumentStatus>Processed</DocumentStatus>
    <DocumentType>Tests</DocumentType>
    <DocumentSource>MILL</DocumentSource>
    <Tests EquipmentCode="MILLEDI" TesterLogin="MILLEDI" Value="84" TestUnit="15T" Status="Processed" TestId="65"></Tests>
    <Tests EquipmentCode="MILLEDI" TesterLogin="MILLEDI" Value="1.39" TestUnit="W/Lb" Status="Processed" TestId="48"></Tests>
    <Tests EquipmentCode="MILLEDI" TesterLogin="MILLEDI" Value="1979" TestUnit="W/Lb" Status="Processed" TestId="49"></Tests>
    </Coil>
    But instead it came with below format
    <Coil xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSch
    emaLocation="www.tempel.com/COIL.xsd"><CoilId>97239</CoilId><CoilNo>777078</Co
    ilNo><CoilPOOperatingUnit>TSUSA</CoilPOOperatingUnit><CoilPONo>3407</CoilPONo>
    <MillNo>31</MillNo><MillCoilStatus>Test</MillCoilStatus><ItemNo>0140SP150 C5A<
    /ItemNo><Weight>17365</Weight><UOM>POUNDS</UOM><DocumentNo>0</DocumentNo><Docu
    mentDate>2008-10-13</DocumentDate><DocumentStatus>Processed</DocumentStatus><Do
    cumentType>Tests</DocumentType><DocumentSource>MILL</DocumentSource><Tests Equ
    ipmentCode="MILLEDI" TesterLogin="MILLEDI" Value="84" TestUnit="15T" Status="P
    rocessed" TestId="65"></Tests><Tests EquipmentCode="MILLEDI" TesterLogin="MILL
    EDI" Value="1.39" TestUnit="W/Lb" St atus="Processed" TestId="48"></Tests><Tes
    ts EquipmentCode="MILLEDI" TesterLog in="MILLEDI" Value="1979" TestUnit="W/Lb"
    Status="Processed" TestId="49"></Tests></Coil>
    The sample insert records are as follows
    insert into COIL (coil_id, coil_number, coil_po_operating_unit, coil_po_number, mill_number, mill_coil_status, item_number, coil_weight, weight_uom, document_number, document_date, document_status, document_type, document_source, test_id, value, test_uom, test_status, tester_login, equipment_code, doc_sts_msg)
    values (97239, '777078', 'USA', '3407', '31', 'Test', '0140SP150 C5A', 17365, 'POUNDS', '0', to_date('13-10-2008', 'dd-mm-yyyy'), 'Processed', 'Tests', 'MILL', 65, 84, '15T', 'Processed', 'MILLEDI', 'MILLEDI', null);
    insert into COIL (coil_id, coil_number, coil_po_operating_unit, coil_po_number, mill_number, mill_coil_status, item_number, coil_weight, weight_uom, document_number, document_date, document_status, document_type, document_source, test_id, value, test_uom, test_status, tester_login, equipment_code, doc_sts_msg)
    values (97239, '777078', 'USA', '3407', '31', 'Test', '0140SP150 C5A', 17365, 'POUNDS', '0', to_date('13-10-2008', 'dd-mm-yyyy'), 'Processed', 'Tests', 'MILL', 48, 1.39, 'W/Lb', 'Processed', 'MILLEDI', 'MILLEDI', null);
    insert into COIL (coil_id, coil_number, coil_po_operating_unit, coil_po_number, mill_number, mill_coil_status, item_number, coil_weight, weight_uom, document_number, document_date, document_status, document_type, document_source, test_id, value, test_uom, test_status, tester_login, equipment_code, doc_sts_msg)
    values (97239, '777078', 'USA', '3407', '31', 'Test', '0140SP150 C5A', 17365, 'POUNDS', '0', to_date('13-10-2008', 'dd-mm-yyyy'), 'Processed', 'Tests', 'MILL', 49, 1979, 'W/Lb', 'Processed', 'MILLEDI', 'MILLEDI', null);
    commit;
    Thanks in Advance.

  • Extremely low message throughput with MQ 3.6

    We performed some load tests to determine maximum throughput of the Sun JMS framework when used in conditions similar to our application.
    The achieved throughput is extremely low: around 10 messages / second while we expected around 100. Could you please verify what may be the reason?
    We encountered one particular problem: the time of closing JMS producers increases much during the test. Message throughput decreases proportionally. Time periods of other phases of the JMS API usage remain constant. What can be the reason?
    detailed information:
    Our configuration used:
    server machine:
    cpu: Intel Celeron 2.8 Ghz
    ram: 1GB
    os: CentOS release 4.4 (Final), 2.6.9-42.0.3.EL
    application server: Sun Java System Application Server Enterprise Edition 8.1 2005Q2 UR2
    java version: 1.5.0_04
    we use default imqbroker configuration
    client machine:
    Intel Celeron 2Ghz
    ram: 512MB
    os: Fedora Core release 3, 2.6.12-1.1381_FC3
    java version: 1.4.02
    Test description (find attached test unit sources presenting our way of using JMS API):
    Load test is performed by running a number of concurrent test units against the JMS broker. Number of units is constant in time. Additionally, every unit test at the end of its life cycle launches another unit to keep long test time perspective.
    Each test unit is self-contained. It contains of a producer and a consumer (MessageListener). It sends messages to itself . Also each message unit sleeps for some time to simulate message processing.
    Messages are non-persistent, no durable subscriptions are used. All units are using one shared Queue for whole messaging. Message selectors are utilized to guarantee that messages are delivered to intended receiver.
    By this test we wanted to determine a maximum value of message throughput for which all messages are delivered successfully and in some reasonable time (say less than 1 minute).
    Some variations of test units are possible, e.g. JMS connections and/or sessions can be open/closed for every sent message or shared among multiple producers. But (contrary to our expectations) we encountered no visible differences in message throughput and message delivery time.
    Code of test units:
    Sender.java
    package pl.ericpol.jmstest;
    import javax.jms.Connection;
    import javax.jms.JMSException;
    import javax.jms.MessageProducer;
    import javax.jms.Session;
    public class Sender{
         private UnitTest unitTest = null;
         private Connection connection = null;
         private Session session = null;
         private MessageProducer producer = null;
         private String selector = null;
         public Sender(Connection con, Session session, MessageProducer producer, String selector, UnitTest unitTest){
         public void send() {
              try {
                   boolean closeSession = false;
                   boolean closeProducer = false;
                   if(this.session == null){
                        this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                        closeSession = true;
                   if(this.producer == null){
                        this.producer = this.unitTest.createProducer(this.session);
                        closeProducer = true;
                   this.producer.send(this.unitTest.createMessage(this.session, this.selector));
                   if(closeProducer){
                        this.producer.close();
                        this.producer = null;
                   if(closeSession){
                        this.session.close();
                        this.session = null;
              } catch (JMSException e) {
                   e.printStackTrace();
    Receiver.java
    package pl.ericpol.jmstest;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.MessageProducer;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    public class Receiver extends Thread implements MessageListener{
         private Connection connection = null;
         private Session session = null;
         private Destination destination = null;
         private MessageConsumer consumer = null;
         private Connection sendConnection = null;
         private Session sendSession = null;
         private MessageProducer producer = null;
         private String qname = null;
         private String selector = null;
         private int messagesToReceive = -1;
         private int delay = -1;
         private UnitTest unitTest = null;
         private boolean active = true;
         private long[][] localStats = null;
         private Boolean monitor = new Boolean(true);
         public Receiver(ConnectionFactory cf, Connection sendConnection, Session sendSession, MessageProducer producer,
                   String code, UnitTest unit){
              try {
                   this.connection = cf.createConnection();
                   this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                   this.destination = this.session.createQueue(this.qname);
                   this.consumer = this.session.createConsumer(this.destination, UnitTest.KEY + " = '" + code + "'");
                   this.consumer.setMessageListener(this);
                   this.connection.start();
                   this.producer = producer;
                   this.sendSession = sendSession;
                   this.sendConnection = sendConnection;
              } catch (JMSException e) {
                   e.printStackTrace();
              } catch (NumberFormatException e1) {
                   e1.printStackTrace();
         public void run() {
              if(this.consumer == null){
              } else {
                   this.sleep(0);
                   this.close();
                   TestManager.getInstance().unitTestFinished();
         public synchronized void onMessage(Message arg0) {
              Message message = arg0;
              if(this.active){
                   if(message == null){
                   } else {
                        if(message instanceof TextMessage){
                                  this.registerDeliveryTime(this.localStats.length - this.messagesToReceive, message);
                                  this.sleep(this.delay);
                                  synchronized(this.monitor){
                                       if(--this.messagesToReceive == 0){
                                            this.unitTest.messagesReceived();
                                       } else {
                                            if(this.active){
                                                 this.send();     
                        } else {
              } else {
              if(! this.active){
                   this.notify();
         public synchronized void deactivate(){
         public int getMessagesToReceive(){
              return this.messagesToReceive;
         private void send(){
              try {
                   boolean closeSession = false;
                   boolean closeProducer = false;
                   if(this.sendSession == null){
                        this.sendSession = this.sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                        closeSession = true;
                   if(this.producer == null){
                        this.producer = this.unitTest.createProducer(this.sendSession);
                        closeProducer = true;
                   this.producer.send(this.unitTest.createMessage(this.sendSession, this.selector));
                   if(closeProducer){
                        this.producer.close();
                        this.producer = null;
                   if(closeSession){
                        this.sendSession.close();
                        this.sendSession = null;
              } catch (JMSException e) {
                   e.printStackTrace();
         private synchronized void sleep(int delay){
         private void registerDeliveryTime(int index, Message message){
         private synchronized void close(){
              try {
                   if(this.producer != null){
                        this.producer.close();
                   if(this.sendSession != null){
                        this.sendSession.close();
                        this.sendSession = null;
                   if(this.sendConnection != null){
                        this.sendConnection.close();
                        this.sendConnection = null;
                   if(this.consumer != null){
                        this.consumer.close();
                        this.consumer = null;
                   if(this.session != null){
                        this.session.close();
                        this.session = null;
                   if(this.connection != null){
                        this.connection.close();
                        this.connection = null;
              } catch (JMSException e) {
                   e.printStackTrace();
    TestUnit.java
    package pl.ericpol.jmstest;
    import java.util.HashMap;
    import java.util.Iterator;
    import javax.jms.Connection;
    import javax.jms.DeliveryMode;
    import javax.jms.JMSException;
    import javax.jms.MessageProducer;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import com.sun.messaging.ConnectionFactory;
    import com.sun.messaging.QueueConnectionFactory;
    public class UnitTest extends Thread{
         public static final String KEY = "Type";
         private ConnectionFactory cf = null;
         private Connection sendConnection = null;
         private Session sendSession = null;
         private MessageProducer producer = null;
         private int delay = -1;
         private int messagesPerCall = -1;
         private int loop = -1;
         private int timeOut = -1;
         private int maxLoops = -1;
         private boolean waitingFlag = false;
         private boolean messagesReceived = false;
         public UnitTest(int loop){
              try {               
                   this.cf = new QueueConnectionFactory();
                   this.applyProps(this.cf, Properties.getInstance().getSunProps());
                   this.sendConnection = this.cf.createConnection();
                   if(sharedProducer){
                        this.sendSession = this.sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                        this.producer = this.createProducer(this.sendSession);
                   } else if(sharedSession){
                        this.sendSession = this.sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                   this.sendConnection.start();
              } catch (NumberFormatException e){
                   MyLogger.logger.error("number format exception!!");
              } catch (JMSException e) {
                   e.printStackTrace();
         public void run(){
              String selector = String.valueOf(Randomizer.getRandInt(Integer.MAX_VALUE));
              Receiver receiver = new Receiver(this.cf, this.sendConnection, this.sendSession, this.producer, selector, this);
              receiver.start();
              long startTime = System.currentTimeMillis();
              this.send(selector);
              synchronized (this) {
                   if(! this.messagesReceived){
                        this.sleep(this.timeOut);     
              long finishTime = System.currentTimeMillis();
              receiver.deactivate();
              if(++this.loop < this.maxLoops && TestManager.getInstance().getStatus()){
                   UnitTest newTest = new UnitTest(this.loop);
                   newTest.start();
              } else {
                   TestManager.getInstance().workerFinished();
         public void messagesReceived(){
         private synchronized void sleep(int delay){
         private void applyProps(ConnectionFactory cf, HashMap props){
         private void send(String selector){
              Sender sender = new Sender(this.sendConnection, this.sendSession, this.producer, selector, this);
              sender.send();
         public MessageProducer createProducer(Session session){
              MessageProducer producer = null;
              String qname = (String) Properties.getInstance().getOtherProps().get(Properties.JMS_QUEUE_NAME);
              try {
                   producer = session.createProducer(session.createQueue(qname));
                   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
              } catch (JMSException e) {
                   e.printStackTrace();
              return producer;
         public TextMessage createMessage(Session session, String selector){
              try {
                   TextMessage message = session.createTextMessage();
                   message.setStringProperty(UnitTest.KEY, selector);
                   String messageLenAsString = (String) Properties.getInstance().getOtherProps().get(Properties.JMS_MESSAGE_LENGTH);
                   int messageLen = Integer.parseInt(messageLenAsString);
                   StringBuffer buf = new StringBuffer();
                   buf.append(selector).append("-");
                   for(int i = 0; i < messageLen; i++){
                        buf.append("x");
                   message.setText(buf.toString());
                   return message;
              } catch(NumberFormatException e){
                   MyLogger.logger.error("bad message length!!");
              } catch (JMSException e) {
                   e.printStackTrace();
              return null;
    }

    If you go here:
    http://www.sun.com/software/solaris/get.jsp
    and
    1.Check Sun Java Enterprise (or the Sun Java Application Platform Suite),
    2.Click Get Download and Media
    3. Then select Systems for windows (the bar at the top)
    I beleive you can get Message Queue 3.6 SP3 from it, by only installing the Message Queue component.
    Note: it is a large download (500 Mb for Application Platform), especially for Sun Java Enterprise...
    TE

  • Ant tools: converter java card -  class file  not belonging to the package!

    Hi
    I have another problem with converter. Could you help me please again if you have the time?
    I have created a directory when I save the class files generated by javac. After That , I use convert in this way:
    <convert
    JCA="true"
    EXP="true"
    CAP="true"
    packagename="testUn/classes/testUn"
    packageaid="0x01:0x01:0x01:0x01:0x01:0x01:0x01:0x01:0x02:0x00"
    majorminorversion="1.0"
    verbose = "true">
    <AppletNameAID
    appletname="testUn.classes.testUn.PorteAppUn"
    aid="0x01:0x01:0x01:0x01:0x01:0x01:0x01:0x01:0x02:0x00:0x00"/>
    <classpath refid="classpath"/>
    </convert>
    Here is the answer of the computer:
    [echo] Generation of the CAP,JCA and EXP files...
    [convert] Java Card Ant Tasks, Version 1.0
    [convert] Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    [convert] Note: Usage of Java Card Ant Tasks is optional. Java Card Ant Tasks are not supported by Sun Microsystems, Inc.
    [convert] Java Card 2.2.2 Class File Converter, Version 1.3
    [convert] Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    [convert] parsing /home/ehoudart/app-manager/VersionZero/src/testUn/classes/testUn/PorteAppUn.class
    [convert] converting testUn.PorteAppUn
    [*convert] error: class PorteAppUn does not belong to package testUn.classes.testUn.*
    [convert] conversion completed with 1 errors and 0 warnings.
    I do not understand why this unique applet class file does not belong to its own package. Is someone an idea?
    Thanks very much in advance for your answer.

    Here is a complete example build.xml (I think I have posted this before).
    <?xml version="1.0" encoding="UTF-8" ?>
    <project default="convert" name="javacard-starter">
      <!-- Build specific properties -->
      <property name="target.classes" location="${basedir}/target/classes" />
      <property name="target.javacard" location="${basedir}/target/javacard" />
      <property name="source.java" location="${basedir}/src/main/java" />
      <!-- Must point to the folder containing the JAR files from the JCDK -->
      <property name="javacard.libs" location="${basedir}/lib" />
      <!-- Must point to the folder containing the JAR file from the JCDK ant task -->
      <property name="javacard.ant-task" location="${basedir}/lib" />
      <!-- Must point to the folder containing the API export files from the JCDK -->
      <property name="javacard.export" location="${basedir}/src/main/export" />
      <property name="verbose" value="true" />
      <property name="noverify" value="false" />
      <!-- Path for JC tasks -->
      <path id="classpath">
        <fileset dir="${javacard.ant-task}">
          <include name="*.jar" />
        </fileset>
        <fileset dir="${javacard.libs}">
          <include name="*.jar" />
        </fileset>
      </path>
      <!-- set the export path to the Java Card export files -->
      <path id="export" description="set the export file path">
        <fileset dir="${javacard.export}">
          <include name="**/*.exp" />
        </fileset>
        <pathelement path="${javacard.export}" />
        <pathelement path="${target.classes}" />
        <pathelement path="${target.javacard}" />
      </path>
      <!-- Definitions for tasks for Java Card tools -->
      <taskdef name="capgen" classname="com.sun.javacard.ant.tasks.CapgenTask" classpathref="classpath" />
      <taskdef name="deploycap" classname="com.sun.javacard.ant.tasks.DeployCapTask" classpathref="classpath" />
      <taskdef name="convert" classname="com.sun.javacard.ant.tasks.ConverterTask" classpathref="classpath" />
      <taskdef name="verifyexport" classname="com.sun.javacard.ant.tasks.VerifyExpTask" classpathref="classpath" />
      <taskdef name="verifycap" classname="com.sun.javacard.ant.tasks.VerifyCapTask" classpathref="classpath" />
      <taskdef name="verifyrevision" classname="com.sun.javacard.ant.tasks.VerifyRevTask" classpathref="classpath" />
      <typedef name="appletnameaid" classname="com.sun.javacard.ant.types.AppletNameAID" classpathref="classpath" />
      <typedef name="jcainputfile" classname="com.sun.javacard.ant.types.JCAInputFile" classpathref="classpath" />
      <target name="init">
        <mkdir dir="${target.classes}" />
        <mkdir dir="${target.javacard}" />
      </target>
      <target name="clean">
        <delete dir="${target.classes}" />
        <delete dir="${target.javacard}" />
        <delete dir="${javacard.eeprom}" />
      </target>
      <target name="compile" depends="init" description="Compile source code to class files">
        <!-- Compile the java code from ${src} to ${classes} -->
        <javac debug="yes" optimize="no" srcdir="${source.java}" destdir="${target.classes}" source="1.5" target="1.5">
          <classpath refid="classpath" />
        </javac>
      </target>
      <target name="convert" depends="compile" description="Convert class files to cap files">
              <convert packagename="chaining" packageaid="0xF0:0x00:0x00:0x01:0x00:0x01" majorminorversion="1.0" classdir="${target.classes}" outputdirectory="${target.classes}" jca="true" exp="true" cap="true" debug="true" verbose="${verbose}" noverify="${noverify}">
                   <appletnameaid aid="0xF0:0x00:0x00:0x01:0x00:0x01:0x00:0x01" appletname="chaining.ChainingApplet" />
                   <exportpath refid="export" />
                   <classpath refid="classpath" />
              </convert>
      </target>
      <target name="copy-debug">
        <mkdir dir="${target.debug}" />
        <echo>Copying cap files</echo>
        <copy flatten="true" todir="${target.debug}" verbose="true">
          <fileset dir="${target.classes}" includes="**/*.cap" />
          <fileset dir="${target.classes}" includes="**/*.exp" />
          <fileset dir="${target.classes}" includes="**/*.jca" />
        </copy>
      </target>
      <target name="all" depends="clean, convert" />
    </project>

  • WebServer does not update parameter and looses objects

    - Please struggle through my loooong explanation - THANKS
    Hi all,
    I've got a problem with my servlets/JSPs.
    I try to build a homepage where the content is displayed dynamically and the start-page is for each link the same.
    The content of the pages are stored in HTMLs and XMLs --> the HTMLs contain the static content and also contains identifier for the XMLs which contain the dynamic content. Problem is, that there can be more than one XML. So I've cretaed a properties-file which maps 1-HTML to n-XMLs. So I've generated code which parses (with SAX) through the XMLs and takes the information and stores these information to an object. This object itself is stored with an ID in a hashmap.
    Then I go through the HTML (read in a String) and replace the keys (HTML) with the matching value from the Hashmap.
    When a page is displayed and the client clicks on a link the same page should be called with parameter http://..../start?lang=de&page=link then I should get the information and the HTML for the "link".
    - When I call the "start"-page the first time it is displayed correct. But when I refresh the page it seems as if an object is lost - the information of the Hashmap (which is stored in another object) is lost. I cannot get the information although I got the information before.
    Also the parameters are not updated if I change them, there is always the same exception shown, that the key is not available.
    I've also changed the parameters (for lang) and just displayed them. But they did not change...
    - I'm absolutely helpless
    here the servlet:
    import java.io.*;
    import java.util.HashMap;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class Start extends HttpServlet {
         private String mPathOfPropertiesFile=IConstants.PROPERTIES_ROOT;
         private String mLanguage;
         private String mIdentifier;
         private String mHtmlAsString;
    //class created on my own reads the XML-file and stores all files in a Collection
         private PropertiesXmlReader vXmlPropertiesForIdentifier;
         private HashMap vMapOfFilenames;
         private HashMap vTransUnitId;
         //cretaed on my own. Parses the Collection of XMLfiles and puts necessary information on the FileDisc as Hashmap
    private XmlPageParser vParseXmls;
         private FileDesc vFileDesc;
    * Implements the HTTP GET method.
    * @param request the request object, containing
    * data from the browser
    * @param repsonse the response object to send
    * data to the browser
    public void Service (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException{
              mLanguage = request.getParameter("lang");
              if (mLanguage == null){
                   mLanguage = "";
              mIdentifier = request.getParameter("page");
              if (mIdentifier == null){
                   mIdentifier = "";
                   try {
                        // get the relevant Filenames from the Parser
                        vXmlPropertiesForIdentifier = new PropertiesXmlReader(
                                  mPathOfPropertiesFile, mLanguage, mIdentifier);
                        // get Filenames
                        vMapOfFilenames = vXmlPropertiesForIdentifier
                                  .getFielnames();
                        // parse all XML-Files found in the Properties
                        vParseXmls = new XmlPageParser(vMapOfFilenames);
                        vFileDesc = vParseXmls.getDesv();
                        vTransUnitId = vFileDesc.getMTransUnit();
                        FileReader reader = null;
                        int c;
                        File file = new File(IConstants.HTML_ROOT + mIdentifier);
                        try {
                             // cretae new StringBuffer and read content of the File to the
                             // StringBuffer
                             StringBuffer vHtmlFileBuffer = new StringBuffer();
                             reader = new FileReader(file);
                             while ((c = reader.read()) != -1) {
                                  vHtmlFileBuffer.append((char) c);
                             // cretae String to modify
                             String vHtmlAsString = vHtmlFileBuffer.toString();
                             // if not available (-1) = returnvalue
                             boolean vNoMoreReplacements = false;
                             while (!vNoMoreReplacements) {
                                  int indexOfStart = vHtmlAsString.indexOf(IConstants.HTML_COMMENT_START);
                                  int indexOfEnd = vHtmlAsString.indexOf(IConstants.HTML_COMMENT_END);
                                  if (indexOfEnd != -1 && indexOfStart != -1) {
                                       String key = vHtmlAsString.substring(indexOfStart + 3,
                                                 indexOfEnd);
                                       TransUnit testUnit = vFileDesc.getTransUnitById(key);
                                       vHtmlAsString = vHtmlAsString.replaceAll(IConstants.HTML_COMMENT_START + key
                                                 + IConstants.HTML_COMMENT_END, testUnit.getMSource());
                                  } else {
                                       vNoMoreReplacements = true;
                             mHtmlAsString = vHtmlAsString;
                        } catch (FileNotFoundException fileNotFound) {
                             mHtmlAsString = "The HTML-file could not be found, please control root:" + IConstants.HTML_ROOT;
                        } catch (IOException ioErr) {
                             mHtmlAsString = "Exception during output: " + ioErr.getMessage();
                        } finally {
                             if (reader != null) {
                                  try {
                                       reader.close();
                                  } catch (IOException e) {
                                       e.printStackTrace();
                   } catch (Exception e) {
                        mHtmlAsString = "Unexpected exception with text: " + e.getMessage();
              // Returns a writer to write to the browser
         PrintWriter out = response.getWriter();
         // Writes the string to the browser.
         out.print(mHtmlAsString);
         out.close();
    Hopefully someone can help me out.
    by the way - I'm using a Resin WebbApp Vers 3.0.17
    Thanks for help, in advance,
    brgds, Steffen

    Since you didn't post the XML parser class, I'm not sure exactly what your problem is but I see lots of things that should be changed.
    First of all, get rid of the empty Service() method. Fortunately, you named it wrong so it isn't overriding the service() method in the HttpServlet class. If it were overriding the service() method, your servlet wouldn't even work the first time since there would be nothing to invoke doGet().
    You shouldn't be using instance variables for processing requests (i.e. mLanguage, mIdentifier) because your servlet needs to be thread-safe. Essentially, there is usually one instance of your servlet around (this is up to the application server) and that one instance must be capable of handling multiple requests simalteously. This isn't causing your problem right now because you are just testing but once the application goes live, this will be a big problem.
    Now for what might be causing your problem. Since you didn't post the XML parsers, I suspect that they might be leaving the files open so the second time through, it can't do the parsing. Anyway, your design isn't right because you seem to be reparsing the XML files for each request. All servlets can have an init() method which is invoked when the application server first loads the servlet. You should do all your XML parsing in the init() method. This is much more efficient since it will only be done once (usually when the application server first starts up) not each time the user requests a page. The only potential drawback to this is if you frequently add new XML files, you will have to recycle the server to get the servlet to pick up the new files.

  • Remote Deployment permissions

    Hi all,
    I want to do a remote deployment from my pc to a cluster on different machines using the admin_client.jar file.
    The example in the OC4J Deployment Guide is this :
    java -jar admin_client.jar
    deployer:oc4j:opmn://test-cycle.oracle.com/testunit
    oc4jadmin_ welcome1+
    -deploy
    -file d:\temp\rupg\testru.ear
    -deploymentName testru –bindAllWebApps
    As you can see the example uses the oc4jadmin account to do a remote deployment.
    That also works for me. However, when I use another test account that is not a member of the oc4j-administrators+ role (see system-jazn-data.xml) I get the following error:
    +FINER: RMIConnection.writeDisconnectMessage Preparing to send disconnect message: Login failed Not authorized*+
    FINE: RMIClient.lookup Failed during lookupjavax.naming.AuthenticationException: Not authorized
    at oracle.oc4j.rmi.ClientRmiTransport.connectToServer(ClientRmiTransport.java:100)
    +...+
    I already tried making the test account a member of the oc4j-app-administrators+ role. This gives the test account only com.evermind.server.rmi.RMIPermission Login.
    However, a -validateURI or -deploy using the admin_client.jar still failes.
    So my question is : Is there a list available somewhere of all the (jazn) permissions needed to do a remote deployment ? I couldn't find such a list in the deployment guide (10.1.3.4.0) ...
    Regards,
    Ronald Wouters

    I found a solution to this problem.
    The problem was that I was trying to do a remote deploy NOT to the default "home" oc4j instance but to another oc4j instance that I created in the same application server instance. I had given my test user only "RMIPermission login". However, this test user was defined only in the system-jazn-data.xml of the "home" oc4j instance.
    I simply copied this xml over to the other oc4j instance, thereby setting up the same users, roles and permissions in the new oc4j instance as in the home instance.
    After restarting the appserver, remote deployment using my test account worked just fine.
    I'm pretty sure this is not the "official" way to do this because in a production environment you would probably not even have write permissions to the directory containing these xml files.
    Can anyone tell me if the javasso stuff that I read about in the config and admin manual could be the "official" way to solve this kind of problem ? Or am I way off base here ?
    Any insight would be much appreciated.
    Regards.

  • Maven JPA Testing

    Hi,
    I am a maven newbie, and I have a project with two modules: EjbProject and TestProject.
    The error that I have to perform the test is : javax.persistence.PersistenceException: No Persistence provider for EntityManager named testUnit
    These are my codes:
    persistence.xml into the Test Module
    <?xml version="1.0" encoding="UTF8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
                 version="1.0">
          <persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
            <jar-file>${project.build.directory}/classes</jar-file>
            <properties>
                <property name="eclipselink.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
                <property name="eclipselink.jdbc.url" value="jdbc:hsqldb:mem:test"/>
                <property name="eclipselink.jdbc.user" value="sa"/>
                <property name="eclipselink.jdbc.password" value=""/>
                <property name="eclipselink.target-database"
                          value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
                <property name="eclipselink.logging.level" value="OFF"/>
                <property name="eclipselink.orm.throw.exceptions" value="true"/>
                <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                <property name="eclipselink.ddl-generation.output-mode" value="database"/>
                <property name="hibernate.show_sql" value="${hibernate.show_sql}"/>
            </properties>
        </persistence-unit>
    </persistence>the test:
    public class AbstractJPATestCase extends TestCase {
        @Before
        protected void setUp() throws Exception {
            log.debug("setUp");
            try {
            emf = Persistence.createEntityManagerFactory("testUnit");
            //EntityManager em = emf.createEntityManager();
            //EntityHolder.setEM(em);
            }catch (Exception e) {
              e.printStackTrace();
              throw e;
    }These are the locations:
    Test Module: src/test/resources/META-INF/persistence.xml
    Anyway, this is the first approximation of the solution, because what I hope to do eventually is to run the test: the file is copied persistence.xml of ejb module to test module, and modify the lines that indicate it is a jta congiruarción a local configuration.
    have suggestions
    Thanks!
    Felipe

    A little reasoning time.
    - you have a META-INF/persistence.xml file
    - this persistence.xml file contains a persistence unit 'unitTest'
    - yet the code still reports that this persistent unit cannot be found
    My conclusion right now is that the file is actually not on the test classpath. Do you perhaps have a conflicting test resources setup in your maven pom? The file must somehow be excluded if it is not found.

  • WL tries to deploy utility jar file in .ear as an EJB

    I have an ear containing two ejb jars, one webapp war and a utility jar
    (common.jar). Deploying to
    WebLogic 6.1 sp2 results in deployment errors because WebLogic thinks
    the common.jar in a
    lib directory in the ear is an ejb jar:
    ==================================================================
    ><Apr 22, 2002 4:42:36 PM MDT> <Error> <J2EE> <Error deploying
    >application lib/common:
    >
    >Unable to deploy EJB: lib/common.jar from lib/common.jar:
    >
    >An error occurred while reading the deployment descriptor. The error was:
    > java.io.FileNotFoundException: META-INF/ejb-jar.xml not found in jar file
    > at weblogic.ejb20.dd.xml.DDUtils.getEntry(DDUtils.java:332)
    > at weblogic.ejb20.dd.xml.DDUtils.getEjbJarXml(DDUtils.java:236)
    >.........
    >===================================================================
    Why does it think common.jar contains an EJB? My application.xml is:
    >
    ><application>
    > <display-name>TestUnit</display-name>
    > <module>
    > <ejb>TestUnit1.jar</ejb>
    > </module>
    > <module>
    > <ejb>TestUnit2.jar</ejb>
    > </module>
    > <module>
    > <web>
    > <web-uri>WebApp1.war</web-uri>
    > <context-root>WebApp1</context-root>
    > </web>
    > </module>
    ></application>

    Hi.
    Please open a case with support.
    Regards,
    Michael
    Rick Holland wrote:
    I have an ear containing two ejb jars, one webapp war and a utility jar
    (common.jar). Deploying to
    WebLogic 6.1 sp2 results in deployment errors because WebLogic thinks
    the common.jar in a
    lib directory in the ear is an ejb jar:
    ==================================================================
    <Apr 22, 2002 4:42:36 PM MDT> <Error> <J2EE> <Error deploying
    application lib/common:
    Unable to deploy EJB: lib/common.jar from lib/common.jar:
    An error occurred while reading the deployment descriptor. The error was:
    java.io.FileNotFoundException: META-INF/ejb-jar.xml not found in jar file
    at weblogic.ejb20.dd.xml.DDUtils.getEntry(DDUtils.java:332)
    at weblogic.ejb20.dd.xml.DDUtils.getEjbJarXml(DDUtils.java:236)
    ===================================================================Why does it think common.jar contains an EJB? My application.xml is:
    <application>
    <display-name>TestUnit</display-name>
    <module>
    <ejb>TestUnit1.jar</ejb>
    </module>
    <module>
    <ejb>TestUnit2.jar</ejb>
    </module>
    <module>
    <web>
    <web-uri>WebApp1.war</web-uri>
    <context-root>WebApp1</context-root>
    </web>
    </module>
    </application>
    Michael Young
    Developer Relations Engineer
    BEA Support

  • CAF Datasource

    Hi all,
    When we develop a new BusinessObject (Local Persistence) the CAF uses the database of system. Does anybody knows if is possible to specify a DataSource to CAF uses?
    I'm thinking about High Availability environment, if i have the following scenario:
    SAP Web Dispatcher and server1, server2 and server3, with each server with the CAF Application deployed the database will be created for each one, and it isn't desired. How to says to CAF uses the specific datasource that points to single Database server?
    Its a good practice change the persistence.xml of CAF ejbmodule project:
    - Default-
    <?xml version="1.0"?>
    <persistence version="1.0">
         <persistence-unit name="testunit">
              <jta-data-source>SAP/CAF_RT</jta-data-source>
              <jar-file>sap.comcafcoreearpersistence.jar</jar-file>
         </persistence-unit>
    </persistence>
    - Custom--
    <?xml version="1.0"?>
    <persistence version="1.0">
         <persistence-unit name="testunit">
              <jta-data-source>MY_DATASOURCE</jta-data-source>
              <jar-file>sap.comcafcoreearpersistence.jar</jar-file>
         </persistence-unit>
    </persistence>
    Best regards

    Hi Isaias,
    Since CAF uses Portal database, you must just to configure your portals to use a central (commom) database.
    Check this useful (old) document:
    http://help.sap.com/bp_epv260/EP_JA/documentation/How-to_Guides/03_EP6SP2_TechInfr_v2_final.pdf
    Best Regards,
    Pedro Nunes

  • Java ServiceUnavailableException with iPlanet

    Hi,
    There is a piece of Java code like that:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://"+hostname+":389/");
    env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
    env.put(Context.SECURITY_CREDENTIALS, "password");
    ctx = new InitialDirContext(env);
    NamingEnumeration names = null;
    SearchControls sc = new SearchControls();
    sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
    for (i=0;i<1000;i++){
    names = ctx.search(" ou=TestUnit, ou=domain.com,
    o=NetscapeRoot","objectclass=*",sc);
    For some reason a javax.naming.ServiceUnavailableException is thrown
    sometimes while executing the loop with no visible reason. Does anyone know
    why it happens? iPlanet server is located on remote machine and accessed
    through network. OS is HP-UX 11.0
    Thanks in advance.
    Kiril Kamenev

    You are either running out of available threads to handle the requests
    on your directory server or your network connection is failing you.
    Check that your ldap server has sufficient connections to handle your
    requests. You might need to tune your directory server and increase the
    number of concurrent requests it can handle.
    But also make sure your network is not causing you problems. It could be
    your network is overloaded as well.
    Kiril Kamenev wrote:
    >
    Hi,
    There is a piece of Java code like that:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://"+hostname+":389/");
    env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
    env.put(Context.SECURITY_CREDENTIALS, "password");
    ctx = new InitialDirContext(env);
    NamingEnumeration names = null;
    SearchControls sc = new SearchControls();
    sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
    for (i=0;i<1000;i++){
    names = ctx.search(" ou=TestUnit, ou=domain.com,
    o=NetscapeRoot","objectclass=*",sc);
    For some reason a javax.naming.ServiceUnavailableException is thrown
    sometimes while executing the loop with no visible reason. Does anyone know
    why it happens? iPlanet server is located on remote machine and accessed
    through network. OS is HP-UX 11.0
    Thanks in advance.
    Kiril Kamenev--
    Han-Dat Luc ([email protected])
    Senior Consultant
    SUN Professional Services (iPlanet)
    iPlanet e-commerce Solutions
    Sun Microsystems Australia Pty Ltd

Maybe you are looking for