hammant 2002/09/28 15:12:44
Modified: metagenerate build.xml
metagenerate/src/java/org/apache/avalon/excalibur/metagenerate
MetaGenerateQdoxTask.java
metagenerate/src/test/org/apache/avalon/excalibur/metagenerate
IntegrationTestCase.java
Added: metagenerate/src/java/org/apache/avalon/excalibur/metagenerate
ManifestFactory.java ManifestHelper.java
Log:
Manifests added with tests
Revision Changes Path
1.4 +2 -1 jakarta-avalon-excalibur/metagenerate/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/metagenerate/build.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build.xml 28 Sep 2002 21:43:38 -0000 1.3
+++ build.xml 28 Sep 2002 22:12:44 -0000 1.4
@@ -170,6 +170,7 @@
<fileset dir="build/metagenerate">
<include name="**/*.xinfo"/>
<include name="**/*.mxinfo"/>
+ <include name="**/*.mf"/>
</fileset>
</copy>
@@ -382,7 +383,7 @@
<classpath refid="test.class.path" />
</taskdef>
- <generatemeta dest="build/metagenerate">
+ <generatemeta dest="build/metagenerate" manifestName="TestManifest.mf">
<fileset dir="src/test">
<include name="**/*.java"/>
</fileset>
1.3 +16 -1
jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/MetaGenerateQdoxTask.java
Index: MetaGenerateQdoxTask.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/MetaGenerateQdoxTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MetaGenerateQdoxTask.java 28 Sep 2002 21:43:39 -0000 1.2
+++ MetaGenerateQdoxTask.java 28 Sep 2002 22:12:44 -0000 1.3
@@ -25,6 +25,7 @@
{
private File m_destDir;
+ private String m_manifestName;
/**
* Execute
@@ -54,11 +55,22 @@
}
/**
+ * Set the manifest name
+ * @param manifestName The Manifest Name
+ */
+ public void setManifestName(String manifestName)
+ {
+ m_manifestName = manifestName;
+ }
+
+ /**
* Output the classes
* @throws IOException If a problem writing output
*/
protected void outputClasses() throws IOException
{
+ ManifestFactory manifestFactory = new ManifestFactory(m_destDir,
m_manifestName);
+
for (int i = 0; i < allClasses.size(); i++)
{
JavaClass javaClass = (JavaClass) allClasses.get(i);
@@ -67,6 +79,7 @@
{
XinfoFactory factory = new XinfoFactory(m_destDir, javaClass);
factory.generate();
+ manifestFactory.addBlock(javaClass.getFullyQualifiedName());
}
DocletTag topic = javaClass.getTagByName("phoenix:mx-topic");
if (topic != null)
@@ -74,7 +87,9 @@
MxinfoFactory factory = new MxinfoFactory(m_destDir, javaClass);
factory.generate();
}
-
+ if (m_manifestName != null) {
+ manifestFactory.generate();
+ }
}
}
1.1
jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/ManifestFactory.java
Index: ManifestFactory.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.metagenerate;
import java.io.IOException;
import java.io.File;
import java.util.Vector;
/**
* A Xinfo Factory
* @author Paul Hammant
*/
public class ManifestFactory
{
private String m_manifestName;
private File m_destDir;
private Vector blocks = new Vector();
/**
* Construct a factory for a class.
* @param destDir
* @param mainfestName
*/
public ManifestFactory(File destDir, String mainfestName)
{
m_manifestName = mainfestName;
m_destDir = destDir;
}
/**
* Add a block
* @param className
*/
public void addBlock(String className)
{
blocks.add(className);
}
/**
* Generate the xinfo file
* @throws IOException If a problem writing output
*/
public void generate() throws IOException
{
File file = new File(m_destDir, m_manifestName);
file.getParentFile().mkdirs();
ManifestHelper manifest = new ManifestHelper(file);
manifest.writeHeader();
for (int i = 0; i < blocks.size(); i++)
{
String block = (String) blocks.elementAt(i);
manifest.writeBlockLines(block);
}
manifest.close();
}
}
1.1
jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/ManifestHelper.java
Index: ManifestHelper.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.metagenerate;
import java.io.FileWriter;
import java.io.IOException;
import java.io.File;
/**
* A Xinfo Helper.
* @author Paul Hammant
*/
public class ManifestHelper extends AbstractHelper
{
private FileWriter m_output;
private static final String[] HEADER = new String[]{
"Manifest-Version: 1.0",
"Created-By: Apache Avalon Project (Automatically via MetaGenerate)",
""};
private static final String[] BLOCK_LINES = new String[]{
"Name: @[email protected]",
"Avalon-Block: true"};
/**
* Construct
* @param file The File to create
* @throws IOException If a problem writing output
*/
public ManifestHelper(File file) throws IOException
{
m_output = new FileWriter(file);
}
/**
* Write the header
* @throws IOException If a problem writing output
*/
public void writeHeader() throws IOException
{
for (int i = 0; i < HEADER.length; i++)
{
m_output.write(HEADER[i] + "\n");
}
}
/**
* Write Block lines
* @param className The class name
* @throws IOException If a problem writing output
*/
public void writeBlockLines(String className) throws IOException
{
for (int i = 0; i < BLOCK_LINES.length; i++)
{
String line = BLOCK_LINES[i];
line = replaceString(line, "@FULL-CLASS-PATH@", className.replace('.',
'/'));
m_output.write(line + "\n");
}
}
/**
* Close the file.
* @throws IOException If a problem writing output
*/
public void close() throws IOException
{
m_output.close();
}
}
1.3 +51 -2
jakarta-avalon-excalibur/metagenerate/src/test/org/apache/avalon/excalibur/metagenerate/IntegrationTestCase.java
Index: IntegrationTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/metagenerate/src/test/org/apache/avalon/excalibur/metagenerate/IntegrationTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IntegrationTestCase.java 28 Sep 2002 21:43:39 -0000 1.2
+++ IntegrationTestCase.java 28 Sep 2002 22:12:44 -0000 1.3
@@ -29,7 +29,15 @@
fileName.replace('\\',File.separatorChar);
fileName.replace('/',File.separatorChar);
- LineNumberReader reader = new LineNumberReader(new FileReader(fileName));
+ LineNumberReader reader = null;
+ try
+ {
+ reader = new LineNumberReader(new FileReader(fileName));
+ }
+ catch (FileNotFoundException e)
+ {
+ fail("The generated xinfo file is missing");
+ }
String line = reader.readLine();
int ix =0;
while (line != null)
@@ -67,7 +75,15 @@
fileName.replace('\\',File.separatorChar);
fileName.replace('/',File.separatorChar);
- LineNumberReader reader = new LineNumberReader(new FileReader(fileName));
+ LineNumberReader reader = null;
+ try
+ {
+ reader = new LineNumberReader(new FileReader(fileName));
+ }
+ catch (FileNotFoundException e)
+ {
+ fail("The generated mxinfo file was missing");
+ }
String line = reader.readLine();
int ix =0;
while (line != null)
@@ -78,6 +94,32 @@
}
}
+ public void testManifest() throws Exception
+ {
+ String fileName
+ = "TestManifest.mf";
+ fileName.replace('\\',File.separatorChar);
+ fileName.replace('/',File.separatorChar);
+
+ LineNumberReader reader = null;
+ try
+ {
+ reader = new LineNumberReader(new FileReader(fileName));
+ }
+ catch (FileNotFoundException e)
+ {
+ fail("The generated manifest file is missing");
+ }
+ String line = reader.readLine();
+ int ix =0;
+ while (line != null)
+ {
+ assertEquals("Line not expected", line.trim(), MANIFEST[ix].trim());
+ ix++;
+ line = reader.readLine();
+ }
+ }
+
private static final String XINFO[] = new String[] {
" <?xml version=\"1.0\"?>",
@@ -145,5 +187,12 @@
" </topic>",
"",
"</mxinfo>" };
+
+ private static final String MANIFEST[] = new String[] {
+ "Manifest-Version: 1.0",
+ "Created-By: Apache Avalon Project (Automatically via MetaGenerate)",
+ "",
+ "Name: org/apache/avalon/excalibur/metagenerate/TestBlock.class",
+ "Avalon-Block: true" };
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>