Value classes moved to their own package: net.azib.ipscan.core.values.

NumericListValue introduced (for port ranges and stuff), PortFetcher now returns them instead of Strings.
Config classes are now registered with pico container, so can be injected.


git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@100 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2007-01-02 00:11:11 +00:00
parent 2855cdf53d
commit 80552fa97f
8 changed files with 52 additions and 19 deletions

View File

@ -7,6 +7,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import net.azib.ipscan.config.Labels;
import net.azib.ipscan.core.values.IntegerWithUnit;
import org.junit.Test;

View File

@ -18,6 +18,8 @@ import java.util.HashSet;
import java.util.Set;
import net.azib.ipscan.config.Config;
import net.azib.ipscan.core.values.NotAvailableValue;
import net.azib.ipscan.core.values.NotScannedValue;
import net.azib.ipscan.fetchers.Fetcher;
import net.azib.ipscan.fetchers.FetcherRegistry;

View File

@ -1,10 +1,12 @@
/**
*
*/
package net.azib.ipscan.core;
package net.azib.ipscan.core.values;
import static org.junit.Assert.*;
import net.azib.ipscan.config.Labels;
import net.azib.ipscan.core.values.NotAvailableValue;
import org.junit.Test;
/**

View File

@ -1,10 +1,12 @@
/**
*
*/
package net.azib.ipscan.core;
package net.azib.ipscan.core.values;
import static org.junit.Assert.*;
import net.azib.ipscan.config.Labels;
import net.azib.ipscan.core.values.NotScannedValue;
import org.junit.Test;
/**

View File

@ -0,0 +1,30 @@
/**
*
*/
package net.azib.ipscan.core.values;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import java.util.TreeSet;
import org.junit.Test;
/**
* @author Anton Keks
*/
public class NumericListValueTest {
@Test
public void testToString() {
assertEquals("", new NumericListValue(Collections.EMPTY_LIST, true).toString());
assertEquals("1", new NumericListValue(Arrays.asList(new Object[] {1}), true).toString());
assertEquals("1-3", new NumericListValue(Arrays.asList(new Object[] {1, 2, 3}), true).toString());
assertEquals("1-3", new NumericListValue(new TreeSet<Integer>(Arrays.asList(new Integer[] {2, 3, 1})), true).toString());
assertEquals("1,2,3", new NumericListValue(Arrays.asList(new Object[] {1, 2, 3}), false).toString());
assertEquals("1,5-6,15", new NumericListValue(Arrays.asList(new Object[] {1, 5, 6, 15}), true).toString());
assertEquals("1,85,89,103", new NumericListValue(Arrays.asList(new Object[] {103, 85, 89, 1}), true).toString());
}
}

View File

@ -3,6 +3,8 @@
*/
package net.azib.ipscan.fetchers;
import net.azib.ipscan.config.Config;
import org.junit.Before;
/**
@ -14,7 +16,7 @@ public class PingFetcherTest extends AbstractFetcherTestCase {
@Before
public void setUp() throws Exception {
fetcher = new PingFetcher(null);
fetcher = new PingFetcher(null, Config.getGlobal());
}
}

View File

@ -3,6 +3,8 @@
*/
package net.azib.ipscan.fetchers;
import net.azib.ipscan.config.Config;
import org.junit.Before;
/**
@ -14,7 +16,7 @@ public class PingTTLFetcherTest extends AbstractFetcherTestCase {
@Before
public void setUp() throws Exception {
fetcher = new PingTTLFetcher(null);
fetcher = new PingTTLFetcher(null, Config.getGlobal());
}
}

View File

@ -3,28 +3,20 @@
*/
package net.azib.ipscan.fetchers;
import static org.junit.Assert.assertEquals;
import net.azib.ipscan.config.Config;
import java.util.Arrays;
import java.util.Collections;
import java.util.TreeSet;
import org.junit.Test;
import org.junit.Before;
/**
* PortsFetcherTest
*
* @author anton
*/
public class PortsFetcherTest {
public class PortsFetcherTest extends AbstractFetcherTestCase {
@Test
public void testPortListToRange() {
assertEquals("", PortsFetcher.portListToRange(Collections.EMPTY_LIST, true));
assertEquals("1", PortsFetcher.portListToRange(Arrays.asList(new Object[] {1}), true));
assertEquals("1-3", PortsFetcher.portListToRange(Arrays.asList(new Object[] {1, 2, 3}), true));
assertEquals("1-3", PortsFetcher.portListToRange(new TreeSet<Integer>(Arrays.asList(new Integer[] {2, 3, 1})), true));
assertEquals("1,2,3", PortsFetcher.portListToRange(Arrays.asList(new Object[] {1, 2, 3}), false));
assertEquals("1,5-6,15", PortsFetcher.portListToRange(Arrays.asList(new Object[] {1, 5, 6, 15}), true));
@Before
public void setUp() throws Exception {
fetcher = new PortsFetcher(Config.getGlobal());
}
}