/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.activemq.openwire.tool;

import org.codehaus.jam.JAnnotation;
import org.codehaus.jam.JAnnotationValue;
import org.codehaus.jam.JClass;
import org.codehaus.jam.JProperty;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @version $Revision: 381410 $
 */
public class AmqCppTestMarshallingClassesGenerator extends AmqCppTestMarshallingHeadersGenerator {

    protected String getFilePostFix() {
        return ".cpp";
    }

    protected void generateFile(PrintWriter out) throws Exception {
        generateLicence(out);

out.println("");
out.println("#include <activemq/connector/openwire/marshal/v"+getOpenwireVersion()+"/"+className+".h>");
out.println("");
out.println("#include <activemq/connector/openwire/commands/"+jclass.getSimpleName()+".h>");
out.println("");
out.println("CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::marshal::v"+getOpenwireVersion()+"::"+className+" );");
out.println("");
out.println("#include <activemq/io/DataInputStream.h>");
out.println("#include <activemq/io/DataOutputStream.h>");
out.println("#include <activemq/io/IOException.h>");
out.println("#include <activemq/connector/openwire/OpenWireFormat.h>");
out.println("#include <activemq/connector/openwire/commands/DataStructure.h>");
out.println("#include <activemq/connector/openwire/utils/BooleanStream.h>");
out.println("//");
out.println("//     NOTE!: This file is autogenerated - do not modify!");
out.println("//            if you need to make a change, please see the Java Classes in the");
out.println("//            activemq-core module");
out.println("//");
out.println("");
out.println("using namespace std;");
out.println("using namespace activemq;");
out.println("using namespace activemq::io;");
out.println("using namespace activemq::connector;");
out.println("using namespace activemq::connector::openwire;");
out.println("using namespace activemq::connector::openwire::commands;");
out.println("using namespace activemq::connector::openwire::marshal;");
out.println("using namespace activemq::connector::openwire::utils;");
out.println("using namespace activemq::connector::openwire::marshal::v"+getOpenwireVersion()+";");
out.println("");
out.println("///////////////////////////////////////////////////////////////////////////////");
out.println("void "+className+"::test() {");
out.println("");
out.println("    "+ super.getClassName() + " myMarshaller;");
out.println("    "+ jclass.getSimpleName() + " myCommand;");
out.println("}");
    }

}

@@ -1464,16 +1464,63 @@
 (out);%0A%0A
+        String target = super.getClassName();%0A%0A
 out.prin
@@ -3332,30 +3332,80 @@
 %22    %22+ 
-super.getClass
+target + %22 myMarshaller;%22);%0Aout.println(%22    %22+ jclass.getSimple
 Name() +
@@ -3405,34 +3405,31 @@
 ame() + %22 my
-Marshaller
+Command
 ;%22);%0Aout.pri
@@ -3459,32 +3459,33 @@
 SimpleName() + %22
+*
  myCommand;%22);%0Ao
@@ -3470,33 +3470,338 @@
 ) + %22* myCommand
-;
+2;%22);%0Aout.println(%22%22);%0Aout.println(%22    CPPUNIT_ASSERT( myMarshaller.getDataStructureType() == myCommand.getDataStructureType() );%22);%0Aout.println(%22    myCommand2 = myMarshaller.createObject();%22);%0Aout.println(%22    CPPUNIT_ASSERT( myCommand2 != NULL );%22);%0Aout.println(%22    delete myCommand2;%22);%0Aout.println(%22
 %22);%0Aout.println(

https://issues.apache.org/activemq/browse/AMQCPP-139