Files
jlibzeroconf/src/test/java/com/softwarecraftsmen/dns/labels/ServiceProtocolLabelTest.java
2012-05-04 17:44:49 -07:00

46 lines
1.1 KiB
Java

/**
* This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
*/
package com.softwarecraftsmen.dns.labels;
import static com.softwarecraftsmen.dns.labels.ServiceProtocolLabel.TCP;
import static com.softwarecraftsmen.dns.labels.ServiceProtocolLabel.toServiceProtocolLabel;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ServiceProtocolLabelTest
{
@Test
public void isEmptyIsAlwaysFalse()
{
assertTrue(TCP.isEmpty());
}
@Test
public void toStringRepresentationHasAnUnderscore()
{
assertThat(TCP.toStringRepresentation(), is("_tcp"));
}
@Test
public void length()
{
assertThat(TCP.length(), is(4));
}
@Test
public void toServiceProtocolLabelPresent()
{
assertThat(toServiceProtocolLabel("tcp"), is(TCP));
assertThat(toServiceProtocolLabel("_tcp"), is(TCP));
}
@Test(expected = IllegalArgumentException.class)
public void toServiceProtocolLabelUnrecognised()
{
toServiceProtocolLabel("notrecognised");
}
}