/*
* 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.
*
* $Id: ResourceIteratorImplTest.java 512591 2007-02-28 03:35:44Z vgritsenko $
*/
package org.apache.xindice.client.xmldb;
import junit.framework.TestCase;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.XMLDBException;
import java.util.List;
import java.util.Vector;
/**
* @version $Revision: 512591 $, $Date: 2007-02-27 22:35:44 -0500 (Tue, 27 Feb 2007) $
* @author Vladimir R. Bossicard <vladimir@apache.org>
*/
public class ResourceIteratorImplTest
extends TestCase {
List vct = new Vector();
public void setUp() {
for (int i = 0; i < 3; i++) {
vct.add(new MockResource());
}
}
public void testIterate()
throws Exception {
ResourceIterator iterator = new ResourceIteratorImpl(vct);
assertEquals(true, iterator.hasMoreResources());
assertNotNull(iterator.nextResource());
assertEquals(true, iterator.hasMoreResources());
assertNotNull(iterator.nextResource());
assertEquals(true, iterator.hasMoreResources());
assertNotNull(iterator.nextResource());
assertEquals(false, iterator.hasMoreResources());
try {
iterator.nextResource();
fail();
} catch (XMLDBException e) {
return;
}
}
private static class MockResource
implements Resource {
public Collection getParentCollection()
throws XMLDBException {
return null;
}
public String getId()
throws XMLDBException {
return null;
}
public String getResourceType()
throws XMLDBException {
return null;
}
public Object getContent()
throws XMLDBException {
return null;
}
public void setContent(Object value)
throws XMLDBException {
}
}
}