krysalis-update/src/test/java/org/apache/depot/common/util/classpath PathWalkerTests.java,NONE,1.1 PathContextTests.java,NONE,1.1 PathWalkerFilterTests.java,NONE,1.1 PathSetTests.java,NONE,1.1 PathPartTests.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:07:16 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/test/java/org/apache/depot/common/util/classpath
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/test/java/org/apache/depot/common/util/classpath
Added Files:
PathWalkerTests.java PathContextTests.java
PathWalkerFilterTests.java PathSetTests.java
PathPartTests.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: PathWalkerTests.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.common.util.classpath;
import java.io.File;
import java.io.InputStream;
import java.util.jar.Manifest;
import junit.framework.TestCase;
import org.apache.depot.common.util.classpath.listener.DirectoryListener;
import org.apache.depot.common.util.classpath.listener.FileContentsListener;
import org.apache.depot.common.util.classpath.listener.FileListener;
import org.apache.depot.common.util.classpath.listener.JarListener;
import org.apache.depot.common.util.classpath.listener.ManifestListener;
import org.apache.depot.common.util.classpath.listener.NameFilter;
/**
* @author ajack
*/
public class PathWalkerTests
extends TestCase
implements
FileListener,
FileContentsListener,
JarListener,
ManifestListener,
DirectoryListener,
NameFilter {
private int m_filters = 0;
private int m_files = 0;
private int m_fileContents = 0;
private int m_jars = 0;
private int m_dirs = 0;
private int m_manifests = 0;
public PathWalkerTests(String arg0) {
super(arg0);
}
public void setUp() {
m_filters = 0;
m_files = 0;
m_fileContents = 0;
m_jars = 0;
m_dirs = 0;
m_manifests = 0;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PathWalkerTests.class);
}
public boolean filter(String name, Object context) {
m_filters++;
return false;
}
public void processDirectory(Object context, File file, String location) {
m_dirs++;
}
public void processFile(
Object context,
File file,
File root,
String location) {
m_files++;
}
public void processFile(
Object context,
File file,
File root,
InputStream contents,
String location) {
m_fileContents++;
}
public void processJar(Object context, File file, String location) {
m_jars++;
}
public void processManifest(Object context, File file, Manifest manifest) {
m_manifests++;
}
public void testWalking() {
PathSet pathSet = PathSet.getClasspath();
assertTrue("Some entries", pathSet.size() > 0);
//DebugUtils.dump(pathSet);
PathWalker walker = new PathWalker(pathSet);
walker.registerListener(this);
walker.walk();
assertTrue("Some filter events", m_filters > 0);
assertTrue("Some JAR events", m_jars > 0);
assertTrue("Some JAR Manifest events", m_manifests > 0);
assertTrue("Some File events", m_files > 0);
assertTrue("Some File Contents events", m_fileContents > 0);
//
// Kinda pointless, but there may be no directories
// in the path
//
assertTrue("Some Directory events", m_dirs >= 0);
}
}
--- NEW FILE: PathContextTests.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.common.util.classpath;
import junit.framework.TestCase;
/**
* @author ajack
*/
public class PathContextTests extends TestCase {
public PathContextTests(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PathContextTests.class);
}
public void testEquality() {
PathContext context1 = new PathContext();
PathContext context2 = new PathContext();
assertEquals("Same Context", context1, context1);
assertEquals("Same Context", context2, context2);
assertEquals("Same Context", context1, context2);
assertTrue(
"Same Context",
(context1.hashCode() == context2.hashCode()));
assertTrue("Not Same Object", (context1 != context2));
}
}
--- NEW FILE: PathWalkerFilterTests.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.common.util.classpath;
import java.io.File;
import java.io.InputStream;
import java.util.jar.Manifest;
import junit.framework.TestCase;
import org.apache.depot.common.util.classpath.listener.DirectoryListener;
import org.apache.depot.common.util.classpath.listener.FileContentsListener;
import org.apache.depot.common.util.classpath.listener.FileListener;
import org.apache.depot.common.util.classpath.listener.JarListener;
import org.apache.depot.common.util.classpath.listener.ManifestListener;
import org.apache.depot.common.util.classpath.listener.NameFilter;
/**
* @author ajack
*/
public class PathWalkerFilterTests
extends TestCase
implements
FileListener,
FileContentsListener,
JarListener,
ManifestListener,
DirectoryListener,
NameFilter {
private int m_filters = 0;
private int m_files = 0;
private int m_fileContents = 0;
private int m_jars = 0;
private int m_dirs = 0;
private int m_manifests = 0;
public PathWalkerFilterTests(String arg0) {
super(arg0);
}
public void setUp() {
m_filters = 0;
m_files = 0;
m_fileContents = 0;
m_jars = 0;
m_dirs = 0;
m_manifests = 0;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PathWalkerFilterTests.class);
}
public boolean filter(String name, Object context) {
m_filters++;
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
//
// NOTE: Filters out everything!!!
//
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
return true;
}
public void processDirectory(Object context, File file, String location) {
m_dirs++;
}
public void processFile(
Object context,
File file,
File root,
String location) {
m_files++;
}
public void processFile(
Object context,
File file,
File root,
InputStream contents,
String location) {
m_fileContents++;
}
public void processJar(Object context, File file, String location) {
m_jars++;
}
public void processManifest(Object context, File file, Manifest manifest) {
m_manifests++;
}
public void testWalking() {
PathSet pathSet = PathSet.getClasspath();
assertTrue("Some entries", pathSet.size() > 0);
//DebugUtils.dump(pathSet);
PathWalker walker = new PathWalker(pathSet);
walker.registerListener(this);
walker.walk();
assertTrue("No filter events", m_filters > 0);
assertTrue("No JAR events", m_jars == 0);
assertTrue("No JAR Manifest events", m_manifests == 0);
assertTrue("No File events", m_files == 0);
assertTrue("No File Contents events", m_fileContents == 0);
assertTrue("No Directory events", m_dirs == 0);
}
}
--- NEW FILE: PathSetTests.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.common.util.classpath;
import java.util.Iterator;
import junit.framework.TestCase;
/**
* @author ajack
*/
public class PathSetTests extends TestCase {
public PathSetTests(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PathWalkerTests.class);
}
public void testBoot() {
PathSet pathSet = PathSet.getSystemBootClasspath();
assertTrue("Some entries", pathSet.size() > 0);
}
public void testSystem() {
PathSet pathSet = PathSet.getSystemClasspath();
assertTrue("Some entries", pathSet.size() > 0);
}
public void testCombo() {
PathSet pathSet = PathSet.getClasspath();
assertTrue("Some entries", pathSet.size() > 0);
for ( Iterator i = pathSet.iterator(); i.hasNext(); )
{
Object entity = i.next();
assertTrue("Is a PathPart:", (entity instanceof PathPart));
}
}
public void testEquality() {
PathSet pathSet1 = PathSet.getSystemBootClasspath();
PathSet pathSet2 = PathSet.getSystemBootClasspath();
assertEquals("Same PathSet", pathSet1, pathSet1);
assertEquals("Same PathSet", pathSet2, pathSet2);
assertEquals("Same PathSet", pathSet1, pathSet2);
assertTrue(
"Same PathSet",
(pathSet1.hashCode() == pathSet2.hashCode()));
assertTrue("Not Same Object", (pathSet1 != pathSet2));
}
}
--- NEW FILE: PathPartTests.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.common.util.classpath;
import junit.framework.TestCase;
/**
* @author ajack
*/
public class PathPartTests extends TestCase {
public PathPartTests(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(PathWalkerTests.class);
}
public void testEquality() {
PathPart part1 = new PathPart("A");
PathPart part2 = new PathPart("A");
assertEquals("Same Part", part1, part1);
assertEquals("Same Part", part2, part2);
assertEquals("Same Part", part1, part2);
assertTrue(
"Same Part",
(part1.hashCode() == part2.hashCode()));
assertTrue("Not Same Object", (part1 != part2));
}
}
-------------------------------------------------------
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/