krysalis-update/src/test/java/org/apache/depot/update/util/xml TestParent.java,NONE,1.1 test.xml,NONE,1.1 XMLParserTests.java,NONE,1.1 TestChild.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:34 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/update/util/xml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/update/util/xml
Added Files:
TestParent.java test.xml XMLParserTests.java TestChild.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: test.xml ---
<?xml version="1.0"?>
<!-- Test File -->
<parent attribute1="att1" attribute2="att2">
<child childAttribute="childAtt" />
</parent>
--- NEW FILE: XMLParserTests.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.depot.update.util.xml;
import java.io.File;
import java.util.HashMap;
import junit.framework.TestCase;
import org.apache.depot.common.log.Logger;
import org.apache.depot.common.util.envsafe.ClassLoaderContext;
public class XMLParserTests extends TestCase {
public XMLParserTests(String name) {
super(name);
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
public void testXMLParse() throws Exception {
XMLEntryTable xmlEntryTable = new XMLEntryTable();
xmlEntryTable.put("parent", "org.apache.depot.update.util.xml.TestParent");
xmlEntryTable.put("child", "org.apache.depot.update.util.xml.TestChild");
ClassLoaderContext helper = new ClassLoaderContext(xmlEntryTable);
XMLParser parser = new XMLParser(xmlEntryTable, helper);
XMLContext xmlContext =
parser.parse(
new File("src/test/org/apache/depot/update/util/xml/test.xml"));
HashMap map = xmlContext.getCreatedTagObjects();
assertNotNull("Has Parent Object", map.get("parent"));
assertNotNull("Has Child Object", map.get("child"));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(XMLParserTests.class);
}
}
--- NEW FILE: TestChild.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.depot.update.util.xml;
/**
* @author anou_mana
*/
public class TestChild
{
private String m_childAttribute;
/**
*
*/
public TestChild()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @return
*/
public String getChildAttribute()
{
return m_childAttribute;
}
/**
* @param string
*/
public void setChildAttribute(String string)
{
m_childAttribute = string;
}
public String toString()
{
StringBuffer buff = new StringBuffer();
buff.append("ClassName : ");
buff.append(this.getClass().getName());
buff.append("\n\tChildAttribute1 : ");
buff.append(this.m_childAttribute);
return buff.toString();
}
}
--- NEW FILE: TestParent.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.depot.update.util.xml;
/**
* @author anou_mana
*/
public class TestParent
{
private String m_attribute1;
private String m_attribute2;
private TestChild m_testChild;
/**
*
*/
public TestParent()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @return
*/
public String getAttribute1()
{
return m_attribute1;
}
/**
* @return
*/
public String getAttribute2()
{
return m_attribute2;
}
/**
* @return
*/
public TestChild getTestChild()
{
return m_testChild;
}
/**
* @param string
*/
public void setAttribute1(String string)
{
m_attribute1 = string;
}
/**
* @param string
*/
public void setAttribute2(String string)
{
m_attribute2 = string;
}
/**
* @param child
*/
public void setTestChild(TestChild child)
{
m_testChild = child;
}
public TestChild createTestChild()
{
m_testChild = new TestChild();
return this.m_testChild;
}
public String toString()
{
StringBuffer buff = new StringBuffer();
buff.append("ClassName : ");
buff.append(this.getClass().getName());
buff.append("\n\tAttribute1 : ");
buff.append(this.m_attribute1);
buff.append("\n\tAttribute2 : ");
buff.append(this.m_attribute2);
buff.append("\n\t\tChildClass");
buff.append(this.m_testChild.toString());
return buff.toString();
}
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/