Browse Source

Extract fixtures

master
Gintas Grigelionis 7 years ago
parent
commit
6589c7b1f3
2 changed files with 20 additions and 10 deletions
  1. +12
    -6
      src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java
  2. +8
    -4
      src/tests/junit/org/apache/tools/ant/util/GlobPatternMapperTest.java

+ 12
- 6
src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java View File

@@ -17,6 +17,7 @@
*/
package org.apache.tools.ant.util;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
@@ -27,17 +28,22 @@ import static org.junit.Assert.assertEquals;
*/
public class Base64ConverterTest {

private Base64Converter base64Converter;

@Before
public void setUp() {
base64Converter = new Base64Converter();
}

@Test
public void testOneValue() {
byte[] mybytes = {0, 0, (byte) 0xFF};
Base64Converter base64Converter = new Base64Converter();
assertEquals("AAD/", base64Converter.encode(mybytes));
assertEquals("AAD/",
base64Converter.encode(new byte[]{0, 0, (byte) 0xFF}));
}

@Test
public void testHelloWorld() {
byte[] mybytes = "Hello World".getBytes();
Base64Converter base64Converter = new Base64Converter();
assertEquals("SGVsbG8gV29ybGQ=", base64Converter.encode(mybytes));
assertEquals("SGVsbG8gV29ybGQ=",
base64Converter.encode("Hello World".getBytes()));
}
}

+ 8
- 4
src/tests/junit/org/apache/tools/ant/util/GlobPatternMapperTest.java View File

@@ -18,6 +18,7 @@

package org.apache.tools.ant.util;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
@@ -30,9 +31,15 @@ import static org.junit.Assert.assertNull;
*/
public class GlobPatternMapperTest {

private GlobPatternMapper m;

@Before
public void setUp() {
m = new GlobPatternMapper();
}

@Test
public void testNoPatternAtAll() {
GlobPatternMapper m = new GlobPatternMapper();
m.setFrom("foobar");
m.setTo("baz");
assertNull("Shouldn\'t match foobar", m.mapFileName("plonk"));
@@ -44,7 +51,6 @@ public class GlobPatternMapperTest {

@Test
public void testPostfixOnly() {
GlobPatternMapper m = new GlobPatternMapper();
m.setFrom("*foo");
m.setTo("*plonk");
assertNull("Shouldn\'t match *foo", m.mapFileName("bar.baz"));
@@ -61,7 +67,6 @@ public class GlobPatternMapperTest {

@Test
public void testPrefixOnly() {
GlobPatternMapper m = new GlobPatternMapper();
m.setFrom("foo*");
m.setTo("plonk*");
assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz"));
@@ -78,7 +83,6 @@ public class GlobPatternMapperTest {

@Test
public void testPreAndPostfix() {
GlobPatternMapper m = new GlobPatternMapper();
m.setFrom("foo*bar");
m.setTo("plonk*pling");
assertNull("Shouldn\'t match foo*bar", m.mapFileName("bar.baz"));


Loading…
Cancel
Save