Skip to content
Snippets Groups Projects
Commit cc9cda26 authored by felmer's avatar felmer
Browse files

LMS-210 Bugs fixed: No channels in format parameters.

SVN: 3571
parent 7d29920a
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,8 @@ import ch.systemsx.cisd.bds.storage.INode;
*
* @author Christian Ribeaud
*/
// TODO, 2008-01-16, Franz-Josef Elmer: This class should be removed or used differently because channels are
// annotations and no longer format parameters
public final class ChannelList implements IStorable, Iterable<Channel>
{
......@@ -108,10 +110,6 @@ public final class ChannelList implements IStorable, Iterable<Channel>
public final void saveTo(final IDirectory directory)
{
directory.addKeyValuePair(NUMBER_OF_CHANNELS, getChannelCount() + "");
for (Channel channel : channels)
{
channel.saveTo(directory);
}
}
//
......
/*
* Copyright 2007 ETH Zuerich, CISD
*
* 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 ch.systemsx.cisd.bds.hcs;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.*;
import ch.systemsx.cisd.bds.exception.DataStructureException;
import ch.systemsx.cisd.bds.storage.IDirectory;
import ch.systemsx.cisd.bds.storage.filesystem.NodeFactory;
import ch.systemsx.cisd.common.utilities.AbstractFileSystemTestCase;
/**
* Test cases for corresponding {@link ChannelList} class.
*
* @author Christian Ribeaud
*/
public final class ChannelListTest extends AbstractFileSystemTestCase
{
private final static ChannelList createChannelList()
{
final List<Channel> list = new ArrayList<Channel>();
list.add(new Channel(1, 123));
list.add(new Channel(2, 456));
return new ChannelList(list);
}
private final static void checkFile(final File file)
{
assertTrue(file.getName().equals(ChannelList.NUMBER_OF_CHANNELS) || file.getName().startsWith(Channel.CHANNEL));
}
private final static void checkChannelFile(final File channelFile)
{
assertNotNull(channelFile);
assertTrue(channelFile.isDirectory());
final File[] files = channelFile.listFiles();
assertEquals(1, files.length);
assertEquals(files[0].getName(), Channel.WAVELENGTH);
}
@Test
public final void testConstructor()
{
try
{
new ChannelList(null);
fail("Channel list can not be null.");
} catch (AssertionError ex)
{
}
try
{
new ChannelList(new ArrayList<Channel>());
fail("Channel list can not be empty.");
} catch (AssertionError ex)
{
}
final List<Channel> list = new ArrayList<Channel>();
list.add(new Channel(1, 123));
list.add(new Channel(1, 456));
try
{
new ChannelList(list);
fail("Duplicate channels are not allowed.");
} catch (DataStructureException e)
{
}
}
@Test
public final void testSaveTo()
{
final ChannelList channelList = createChannelList();
final IDirectory dir = NodeFactory.createDirectoryNode(workingDirectory);
channelList.saveTo(dir);
final File[] files = workingDirectory.listFiles();
assertEquals(3, files.length);
for (File file : files)
{
checkFile(file);
if (file.getName().startsWith(Channel.CHANNEL))
{
checkChannelFile(file);
}
}
}
@Test(dependsOnMethods = "testSaveTo")
public final void testLoadFrom()
{
testSaveTo();
final IDirectory dir = NodeFactory.createDirectoryNode(workingDirectory);
final ChannelList channelList = ChannelList.loadFrom(dir);
assertEquals(2, channelList.getChannelCount());
final Iterator<Channel> iterator = channelList.iterator();
Channel channel = iterator.next();
assertEquals(123, channel.getWavelength());
channel = iterator.next();
assertEquals(456, channel.getWavelength());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment