id stringlengths 8 13 | source stringlengths 164 33.1k | target stringlengths 36 5.98k |
|---|---|---|
11383343_1 | class MyAction extends ActionSupport {
public String save() {
System.out.println(id);
System.out.println(name);
return SUCCESS;
}
public String getId();
public void setId(String id);
public String getName();
public void setName(String name);
public String view();
... | // request.setParameter("id", "1");
// request.setParameter("name", "Test Desc");
request.setContent("{\"id\":\"1\",\"name\":\"nitin\"}".getBytes());
// request.setContentType("application/json");
request.addHeader("Content-Type", "application/json");
// request.setContent("... |
11585818_2 | class Sampling {
public static Sampling valueOf(String samplerName) {
if ("off".equalsIgnoreCase(samplerName)) return OFF;
if ("on".equalsIgnoreCase(samplerName)) return ON;
return null;
}
public abstract boolean trace();
}
class SamplingTest {
@Test
public void testSamp... | assertNull(Sampling.valueOf(null));
assertNull(Sampling.valueOf("unknown"));
assertEquals(Sampling.ON, Sampling.valueOf("on"));
assertEquals(Sampling.ON, Sampling.valueOf("ON"));
assertEquals(Sampling.ON, Sampling.valueOf("oN"));
assertEquals(Sampling.OFF, Sampling.valu... |
11585818_4 | class AsynchronousSpanSink implements SpanSink {
@Override
public void record(SpanData spanData) {
Runnable job = jobFactory.createJob(spanData);
executor.execute(job);
}
public AsynchronousSpanSink(JobFactory jobFactory);
public AsynchronousSpanSink(ExecutorService executor, Job... | ExecutorService executor = mock(ExecutorService.class);
AsynchronousSpanSink.JobFactory jobFactory = mock(AsynchronousSpanSink.JobFactory.class);
SpanSink sink = new AsynchronousSpanSink(executor, jobFactory);
SpanData spanData = new BeanSpanData();
Runnable runnable = new Runn... |
11614244_0 | class RawImageReader {
public String getDcrawBin() {
// Check field
if (dcrawBin != null) {
return dcrawBin;
}
// Check environment
String dcrawEnv = System.getenv().get(DCRAW_ENV_VAR);
if (dcrawEnv != null) {
return dcrawEnv;
}
... | RawImageReader r = new RawImageReader("test-path");
String dcrawBin = r.getDcrawBin();
assertEquals("test-path", dcrawBin);
}
} |
11614244_1 | class ParameterReader {
public List<String> readParameters(final String baseKey, final boolean otherRaw) {
if (otherRaw) {
return readParameters(baseKey + RAW_KEY);
} else {
return readParameters(baseKey + NON_RAW_KEY);
}
}
private List<String> readParameter... | ParameterReader pr = new ParameterReader();
List<String> expectedRaw = new ArrayList<String>();
List<String> paramsRaw = pr.readParameters("invalid.key", true);
assertThat(paramsRaw, is(expectedRaw));
List<String> expectedNonRaw = new ArrayList<String>();
List<String> p... |
11614244_2 | class ParameterReader {
public List<String> readParameters(final String baseKey, final boolean otherRaw) {
if (otherRaw) {
return readParameters(baseKey + RAW_KEY);
} else {
return readParameters(baseKey + NON_RAW_KEY);
}
}
private List<String> readParameter... | ParameterReader pr = new ParameterReader();
List<String> expectedRaw = Arrays.asList("-6");
List<String> paramsRaw = pr.readParameters("key1", true);
assertThat(paramsRaw, is(expectedRaw));
List<String> expectedNonRaw = Arrays.asList("-6", "-T", "-o", "1", "-w");
List<S... |
11614244_7 | class ScaleToNearestFactorPreprocessor extends ScalePreprocessor {
@Override
public void process() {
if (widthFactor1 < THRESHOLD || heightFactor1 < THRESHOLD || widthFactor2 < THRESHOLD ||
heightFactor2 < THRESHOLD) {
LOGGER.info("Scaling image with factors [{}], [{}]", wid... | BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0));
BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0));
ScaleToNearestFactorPreprocessor pp = new ScaleToNearestFactorPreprocessor(img1, img2, 500);
pp.process();
Assert.assertE... |
11614244_8 | class ScaleToNearestFactorPreprocessor extends ScalePreprocessor {
@Override
public void process() {
if (widthFactor1 < THRESHOLD || heightFactor1 < THRESHOLD || widthFactor2 < THRESHOLD ||
heightFactor2 < THRESHOLD) {
LOGGER.info("Scaling image with factors [{}], [{}]", wid... | BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0));
BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0));
ScaleToNearestFactorPreprocessor pp = new ScaleToNearestFactorPreprocessor(img1, img2,
... |
11614244_9 | class ScaleToNearestFactorPreprocessor extends ScalePreprocessor {
@Override
public void process() {
if (widthFactor1 < THRESHOLD || heightFactor1 < THRESHOLD || widthFactor2 < THRESHOLD ||
heightFactor2 < THRESHOLD) {
LOGGER.info("Scaling image with factors [{}], [{}]", wid... | BufferedImage img1 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 400, 200);
BufferedImage img2 = BufferedImageHelper.createSolidImage(new Color(0, 0, 0), 100, 50);
ScaleToNearestFactorPreprocessor pp = new ScaleToNearestFactorPreprocessor(img1, img2, 200);
pp.process();
... |
11919447_0 | class QueryController {
int skipToLast(int cursorLength, int limit)
{
if (cursorLength > limit)
{
return cursorLength - limit;
}
return 0;
}
@Secured(Roles.ROLE_ADMIN) @RequestMapping(value = "/{collection}/{id}", method = RequestMethod.DELETE) public Respon... | QueryController queryController = new QueryController();
int actualNrOfSkips = queryController.skipToLast(cursorLength, lastNrOfDocuments);
assertEquals(actualNrOfSkips, expectedNrOfSkips);
}
} |
11919447_1 | class MimeTypeToExtensionsUtil {
public static String getExtension(final String mimeType)
{
if (MIME_TYPES_EXTENSIONS.containsKey(mimeType))
{
return MIME_TYPES_EXTENSIONS.get(mimeType);
}
return mimeType.substring(mimeType.indexOf("/") + 1);
}
}
class MimeType... | String extension = MimeTypeToExtensionsUtil.getExtension("application/zip");
Assert.assertEquals("zip", extension);
}
} |
11919447_2 | class MimeTypeToExtensionsUtil {
public static String getExtension(final String mimeType)
{
if (MIME_TYPES_EXTENSIONS.containsKey(mimeType))
{
return MIME_TYPES_EXTENSIONS.get(mimeType);
}
return mimeType.substring(mimeType.indexOf("/") + 1);
}
}
class MimeType... | String extension = MimeTypeToExtensionsUtil.getExtension("image/png");
Assert.assertEquals("png", extension);
}
} |
11919447_3 | class MimeTypeToExtensionsUtil {
public static String getExtension(final String mimeType)
{
if (MIME_TYPES_EXTENSIONS.containsKey(mimeType))
{
return MIME_TYPES_EXTENSIONS.get(mimeType);
}
return mimeType.substring(mimeType.indexOf("/") + 1);
}
}
class MimeType... | String extension = MimeTypeToExtensionsUtil.getExtension("image/jpeg");
Assert.assertEquals("jpg", extension);
}
} |
11919447_4 | class MimeTypeToExtensionsUtil {
public static String getExtension(final String mimeType)
{
if (MIME_TYPES_EXTENSIONS.containsKey(mimeType))
{
return MIME_TYPES_EXTENSIONS.get(mimeType);
}
return mimeType.substring(mimeType.indexOf("/") + 1);
}
}
class MimeType... | String extension = MimeTypeToExtensionsUtil.getExtension("text/plain");
Assert.assertEquals("log", extension);
}
} |
13040953_0 | class License {
public static License findByValue(final String uri) {
License found = License.lookupLicense.get(uri);
// No I am going to try an guess about unknown licenses
// This is try and match known CC licenses of other versions or various URLs to
// current licenses, then ma... | final AtomicBoolean run = new AtomicBoolean(true);
final AtomicLong type = new AtomicLong(0);
// Tracking any problems.
final AtomicBoolean hadProblem = new AtomicBoolean(false);
final AtomicBoolean hadException = new AtomicBoolean(false);
// This thread keeps on adding ... |
13040953_1 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"TEST\"?>", "UTF-8");
final String guessedEncoding = "UTF-8";
final String prologEncoding = XmlReader.getXmlProlog(input, guessedEncoding);
assertEquals("TEST", prologEncoding);
}
} |
13040953_2 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"UTF-8\"?>", "UTF-8");
final String guessedEncoding = "UTF-8";
final String prologEncoding = XmlReader.getXmlProlog(input, guessedEncoding);
assertEquals("UTF-8", prologEncoding);
}
} |
13040953_3 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"UTF-16\"?>", "UTF-16");
final String guessedEncoding = "UTF-16";
assertEquals("UTF-16", XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
13040953_4 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"CP1047\"?>", "CP1047");
final String guessedEncoding = "CP1047";
assertEquals("CP1047", XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
13040953_5 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml>", "UTF-8");
final String guessedEncoding = "UTF-8";
assertNull(XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
13040953_6 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"UTF-8\"?>", "UTF-8");
final String guessedEncoding = null;
assertNull(XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
13040953_7 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"utf-8\"?>", "UTF-8");
final String guessedEncoding = "UTF-8";
assertEquals("UTF-8", XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
13040953_8 | class XmlReader extends Reader {
static String getXmlProlog(final InputStream is, final String guessedEnc) throws IOException {
String encoding = null;
if (guessedEnc != null) {
final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
... | final InputStream input = stringToStream("<?xml encoding=\"TEST\"?>", "ISO-8859-1");
final String guessedEncoding = "UTF-8";
assertEquals("TEST", XmlReader.getXmlProlog(input, guessedEncoding));
}
} |
14892248_0 | class XMPMetaParser {
public static XMPMeta parse(Object input, ParseOptions options) throws XMPException
{
ParameterAsserts.assertNotNull(input);
options = options != null ? options : new ParseOptions();
Document document = parseXml(input, options);
boolean xmpmetaRequired = options.getRequireXMPMeta();
... | try {
XMPMetaParser.parse(XMP_WITH_XXE, null);
} catch (XMPException e) {
Assert.assertEquals("Children of resource property element must be XML elements", e.getMessage());
}
}
} |
14892248_1 | class XMPMetaParser {
public static XMPMeta parse(Object input, ParseOptions options) throws XMPException
{
ParameterAsserts.assertNotNull(input);
options = options != null ? options : new ParseOptions();
Document document = parseXml(input, options);
boolean xmpmetaRequired = options.getRequireXMPMeta();
... | try {
XMPMetaParser.parse(XMP_WITH_XXE.getBytes(), null);
} catch (XMPException e) {
Assert.assertEquals("Children of resource property element must be XML elements", e.getMessage());
}
}
} |
14892248_2 | class XMPMetaParser {
public static XMPMeta parse(Object input, ParseOptions options) throws XMPException
{
ParameterAsserts.assertNotNull(input);
options = options != null ? options : new ParseOptions();
Document document = parseXml(input, options);
boolean xmpmetaRequired = options.getRequireXMPMeta();
... | InputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(XMP_WITH_XXE.getBytes());
XMPMetaParser.parse(inputStream, null);
} catch (XMPException e) {
Assert.assertEquals("Children of resource property element must be XML elements", e.getMes... |
14892248_3 | class XmpWriter {
public void close() throws IOException {
if (outputStream == null)
return;
try {
XMPMetaFactory.serialize(xmpMeta, outputStream, serializeOptions);
outputStream = null;
} catch (XMPException xmpExc) {
throw new IOException(xm... | String fileName = "xmp_metadata_automatic.pdf";
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(OUT_FOLDER + fileName));
document.addTitle("Hello World example");
document.addSubject("... |
14892248_4 | class XmpWriter {
public void close() throws IOException {
if (outputStream == null)
return;
try {
XMPMetaFactory.serialize(xmpMeta, outputStream, serializeOptions);
outputStream = null;
} catch (XMPException xmpExc) {
throw new IOException(xm... | String fileName = "xmp_metadata_added.pdf";
PdfReader reader = new PdfReader(CMP_FOLDER + "pdf_metadata.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(OUT_FOLDER + fileName));
HashMap<String, String> info = reader.getInfo();
ByteArrayOutputStream baos = n... |
14892248_5 | class SimpleXMLParser {
public static void parse(final SimpleXMLDocHandler doc, final SimpleXMLDocHandlerComment comment, final Reader r, final boolean html) throws IOException {
SimpleXMLParser parser = new SimpleXMLParser(doc, comment, html);
parser.go(r);
}
private SimpleXMLParser(final Simp... | String whitespace = "<p>sometext\r moretext</p>";
String expected = "sometext moretext";
final StringBuilder b = new StringBuilder();
SimpleXMLParser.parse(new SimpleXMLDocHandler() {
public void text(final String str) {
b.append(str);
}
public void startElement(final String tag, final Map<Strin... |
14892248_6 | class ArrayRandomAccessSource implements RandomAccessSource {
public int get(long offset) {
if (offset >= array.length) return -1;
return 0xff & array[(int)offset];
}
public ArrayRandomAccessSource(byte[] array);
public int get(long offset, byte[] bytes, int off, int len);
public long length();
public voi... | ArrayRandomAccessSource s = new ArrayRandomAccessSource(data);
try{
for(int i = 0; i < data.length; i++){
int ch = s.get(i);
Assert.assertFalse(ch == -1);
Assert.assertEquals("Position " + i, data[i], (byte)ch);
}
Assert.assertEquals(-1, s.get(data.length));
} finally {
s.close();
}
}
... |
14892248_7 | class PagedChannelRandomAccessSource extends GroupedRandomAccessSource implements RandomAccessSource {
@Override
/**
* {@inheritDoc}
* Cleans the mapped bytebuffers and closes the channel
*/
public void close() throws IOException {
super.close();
channel.close();
}
publ... | PagedChannelRandomAccessSource s = new PagedChannelRandomAccessSource(channel);
try{
for(int i = 0; i < data.length; i++){
int ch = s.get(i);
Assert.assertFalse("EOF hit unexpectedly at " + i + " out of " + data.length, ch == -1);
Assert.assertEquals("Position " + i, data[i], (byte)ch);
}
Asser... |
14892248_8 | class PagedChannelRandomAccessSource extends GroupedRandomAccessSource implements RandomAccessSource {
@Override
/**
* {@inheritDoc}
* Cleans the mapped bytebuffers and closes the channel
*/
public void close() throws IOException {
super.close();
channel.close();
}
publ... | byte[] chunk = new byte[257];
PagedChannelRandomAccessSource s = new PagedChannelRandomAccessSource(channel, data.length/10, 1);
try{
int pos = 0;
int count = s.get(pos, chunk, 0, chunk.length-1);
while (count != -1){
assertArrayEqual(data, pos, chunk, 0, count);
pos += count;
count = s.get(p... |
14892248_9 | class PagedChannelRandomAccessSource extends GroupedRandomAccessSource implements RandomAccessSource {
@Override
/**
* {@inheritDoc}
* Cleans the mapped bytebuffers and closes the channel
*/
public void close() throws IOException {
super.close();
channel.close();
}
publ... | byte[] chunk = new byte[257];
PagedChannelRandomAccessSource s = new PagedChannelRandomAccessSource(channel, data.length/10, 7);
try{
int pos = 0;
int count = s.get(pos, chunk, 0, chunk.length-1);
while (count != -1){
assertArrayEqual(data, pos, chunk, 0, count);
pos += count;
count = s.get(p... |
14960307_5 | class NumberRadixUtil {
static public String normalizeLeadingHexZeroes(String v, int length) throws ConversionException {
if (v == null || v.length() == 0) {
throw new ConversionException("Empty or null value detected; unable to convert");
} else if (v.length() == length) {
... | // appending digits or equal
Assert.assertEquals("00", NumberRadixUtil.normalizeLeadingHexZeroes("0", 2));
Assert.assertEquals("00", NumberRadixUtil.normalizeLeadingHexZeroes("00", 2));
Assert.assertEquals("0F", NumberRadixUtil.normalizeLeadingHexZeroes("F", 2));
Assert.assertEqu... |
17537835_0 | class ServiceInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, final Method m, Object[] params) throws Throwable {
if (OBJECT_METHODS.contains(m)) {
if (m.getName().equals("equals")) {
params = new Object[] {Proxy.getInvocationHand... | ServiceInvocationHandler sih = new ServiceInvocationHandler("hello", String.class);
Method m = String.class.getMethod("length");
assertEquals(5, sih.invoke(null, m, new Object[] {}));
}
} |
17537835_1 | class ServiceInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, final Method m, Object[] params) throws Throwable {
if (OBJECT_METHODS.contains(m)) {
if (m.getName().equals("equals")) {
params = new Object[] {Proxy.getInvocationHand... | final List<String> called = new ArrayList<>();
ServiceInvocationHandler sih = new ServiceInvocationHandler("hi", String.class) {
@Override
public boolean equals(Object obj) {
called.add("equals");
return super.equals(obj);
}
... |
17537835_2 | class PropertyHelper {
@SuppressWarnings("unchecked")
public static Collection<String> getMultiValueProperty(Object property) {
if (property == null) {
return Collections.emptyList();
} else if (property instanceof Collection) {
return (Collection<String>)property;
... | assertEquals(Collections.singleton("hi"),
PropertyHelper.getMultiValueProperty("hi"));
}
} |
17537835_3 | class PropertyHelper {
@SuppressWarnings("unchecked")
public static Collection<String> getMultiValueProperty(Object property) {
if (property == null) {
return Collections.emptyList();
} else if (property instanceof Collection) {
return (Collection<String>)property;
... | assertEquals(Arrays.asList("a", "b"),
PropertyHelper.getMultiValueProperty(new String[]{"a", "b"}));
}
} |
17537835_4 | class PropertyHelper {
@SuppressWarnings("unchecked")
public static Collection<String> getMultiValueProperty(Object property) {
if (property == null) {
return Collections.emptyList();
} else if (property instanceof Collection) {
return (Collection<String>)property;
... | List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
list.add("3");
assertEquals(list, PropertyHelper.getMultiValueProperty(list));
}
} |
17537835_5 | class PropertyHelper {
@SuppressWarnings("unchecked")
public static Collection<String> getMultiValueProperty(Object property) {
if (property == null) {
return Collections.emptyList();
} else if (property instanceof Collection) {
return (Collection<String>)property;
... | assertTrue(PropertyHelper.getMultiValueProperty(null).isEmpty());
}
} |
17537835_7 | class IntentManagerImpl implements IntentManager {
@Override
public List<Object> getIntentsFromService(Object serviceBean) {
List<Object> intents = new ArrayList<>();
if (serviceBean instanceof IntentsProvider) {
intents.addAll(((IntentsProvider)serviceBean).getIntents());
}... | IntentManagerImpl im = new IntentManagerImpl();
List<Object> intents = im.getIntentsFromService(new DummyServiceWithLogging());
Assert.assertEquals(1, intents.size());
Object feature = intents.iterator().next();
Assert.assertEquals(GZIPFeature.class, feature.getClass());
}
} |
17537835_8 | class IntentManagerImpl implements IntentManager {
@Override
public List<Object> getIntentsFromService(Object serviceBean) {
List<Object> intents = new ArrayList<>();
if (serviceBean instanceof IntentsProvider) {
intents.addAll(((IntentsProvider)serviceBean).getIntents());
}... | IntentManagerImpl im = new IntentManagerImpl();
List<Object> intents = im.getIntentsFromService(new DummyServiceWithLoggingIP());
Assert.assertEquals(1, intents.size());
Object feature = intents.iterator().next();
Assert.assertEquals(GZIPFeature.class, feature.getClass());
}
... |
17537835_9 | class HttpServiceManager {
public String getAbsoluteAddress(String contextRoot, String endpointAddress) {
if (endpointAddress.startsWith("http")) {
return endpointAddress;
}
String effContextRoot = contextRoot == null ? cxfServletAlias : contextRoot;
return this.httpBase... | HttpServiceManager manager = new HttpServiceManager();
manager.initFromConfig(null);
String address1 = manager.getAbsoluteAddress(null, "/myservice");
assertEquals("http://localhost:8181/cxf/myservice", address1);
String address2 = manager.getAbsoluteAddress("/mycontext", "/mys... |
18203743_0 | class JMSAppender implements PaxAppender {
public void doAppend(final PaxLoggingEvent paxLoggingEvent) {
if (exclude(paxLoggingEvent) || jmsConnectionFactory == null) {
return;
}
Runnable worker = new Runnable() {
public void run() {
try {
... | MockEndpoint events = getMockEndpoint("mock:events");
events.expectedMessageCount(1);
appender.doAppend(MockEvents.createInfoEvent());
assertMockEndpointsSatisfied();
}
} |
18203743_1 | class LogstashEventFormat implements LoggingEventFormat {
public String toString(PaxLoggingEvent event) {
JsonObjectBuilder object = Json.createObjectBuilder();
try {
object.add(MESSAGE, event.getMessage());
object.add(SOURCE, event.getLoggerName());
object.add(T... | PaxLoggingEvent event = MockEvents.createInfoEvent();
JsonObject object = Json.createReader(new StringReader(format.toString(event))).readObject();
assertEquals(MockEvents.LOG_MESSAGE, object.getString(LogstashEventFormat.MESSAGE));
assertEquals(MockEvents.LOGGER_NAME, object.getString(... |
18242149_0 | class AsmApi {
static int value() {
return Opcodes.ASM7;
}
private AsmApi();
}
class AsmApiTest {
@Test
public void testValue() {
| assertEquals(Opcodes.ASM7, AsmApi.value());
}
} |
18467626_0 | class CommandApdu {
public byte[] toBytes() {
int length = 4; // CLA, INS, P1, P2
if (mData != null && mData.length != 0) {
length += 1; // LC
length += mData.length; // DATA
}
if (mLeUsed) {
length += 1; // LE
}
byte[] apdu = new byte[length];
int index = 0;
apdu[index] = (byte) mCla;
in... | Assertions.assertThat(BytesUtils.bytesToString(new CommandApdu(CommandEnum.GPO, 0x01, 0x02, 0x01).toBytes())).isEqualTo(
"80 A8 01 02 01");
Assertions.assertThat(BytesUtils.bytesToString(new CommandApdu(CommandEnum.GPO, new byte[] {}, 0x01).toBytes()))
.isEqualTo("80 A8 00 00 01");
Assertions.assertThat(B... |
18467626_1 | class ResponseUtils {
public static boolean isSucceed(final byte[] pByte) {
return contains(pByte, SwEnum.SW_9000);
}
private ResponseUtils();
public static boolean isEquals(final byte[] pByte, final SwEnum pEnum);
public static boolean contains(final byte[] pByte, final SwEnum... pEnum);
}
class ResponseU... | Assertions.assertThat(ResponseUtils.isSucceed(new byte[] { (byte) 0x90, 0 })).isEqualTo(true);
Assertions.assertThat(ResponseUtils.isSucceed(new byte[] { 0, (byte) 0x90, 0 })).isEqualTo(true);
Assertions.assertThat(ResponseUtils.isSucceed(new byte[] { (byte) 0x00, 0 })).isEqualTo(false);
Assertions.assertThat(R... |
18467626_2 | class ResponseUtils {
public static boolean isEquals(final byte[] pByte, final SwEnum pEnum) {
return contains(pByte, pEnum);
}
private ResponseUtils();
public static boolean isSucceed(final byte[] pByte);
public static boolean contains(final byte[] pByte, final SwEnum... pEnum);
}
class ResponseUtilsTest ... | Assertions.assertThat(ResponseUtils.isEquals(new byte[] { (byte) 0x90, 0 }, SwEnum.SW_9000)).isEqualTo(true);
Assertions.assertThat(ResponseUtils.isEquals(new byte[] { (byte) 0x6D, 18 }, SwEnum.SW_6D)).isEqualTo(true);
Assertions.assertThat(ResponseUtils.isEquals(new byte[] { (byte) 0x00, 0 }, SwEnum.SW_6D)).isEq... |
18467626_4 | class TlvUtil {
public static String prettyPrintAPDUResponse(final byte[] data) {
return prettyPrintAPDUResponse(data, 0);
}
private TlvUtil();
private static ITag searchTagById(final int tagId);
public static String getFormattedTagAndLength(final byte[] data, final int indentLength);
public static TLV getN... |
String expResult = "\n"//
+ "70 63 -- Record Template (EMV Proprietary)\n" //
+ " 61 13 -- Application Template\n" //
+ " 4F 09 -- Application Identifier (AID) - card\n" //
+ " A0 00 00 03 15 10 10 05 28 (BINARY)\n" //
+ " 50 03 -- Application Label\n" ... |
18467626_5 | class TlvUtil {
public static String prettyPrintAPDUResponse(final byte[] data) {
return prettyPrintAPDUResponse(data, 0);
}
private TlvUtil();
private static ITag searchTagById(final int tagId);
public static String getFormattedTagAndLength(final byte[] data, final int indentLength);
public static TLV getN... | // Assertions.assertThat(TlvUtil.prettyPrintAPDUResponse(BytesUtils.fromString(""))).isEqualTo("");
Assertions.assertThat(TlvUtil.prettyPrintAPDUResponse(BytesUtils.fromString("00 00 00 00 46 00 40 02 50 09 78 14 03 16 20 90 00")))
.isEqualTo("");
}
} |
18467626_6 | class TlvUtil {
private static ITag searchTagById(final int tagId) {
return EmvTags.getNotNull(TLVUtil.getTagAsBytes(tagId));
}
private TlvUtil();
public static String getFormattedTagAndLength(final byte[] data, final int indentLength);
public static TLV getNextTLV(final TLVInputStream stream);
private stat... |
ITag tag = (ITag) ReflectionTestUtils.invokeMethod(TlvUtil.class, "searchTagById", 0x9F6B);
Assertions.assertThat(tag).isEqualTo(EmvTags.TRACK2_DATA);
tag = (ITag) ReflectionTestUtils.invokeMethod(TlvUtil.class, "searchTagById", 0xFFFF);
Assertions.assertThat(tag.getName()).isEqualTo("[UNKNOWN TAG]");
Assert... |
18467626_7 | class TlvUtil {
public static String getFormattedTagAndLength(final byte[] data, final int indentLength) {
StringBuilder buf = new StringBuilder();
String indent = getSpaces(indentLength);
TLVInputStream stream = new TLVInputStream(new ByteArrayInputStream(data));
boolean firstLine = true;
try {
while (... |
byte[] data = BytesUtils.fromString("9f6b01");
Assertions.assertThat(TlvUtil.getFormattedTagAndLength(data, 1)).isEqualTo(" 9F 6B 01 -- Track 2 Data");
}
} |
18467626_8 | class TlvUtil {
public static List<TLV> getlistTLV(final byte[] pData, final ITag pTag, final boolean pAdd) {
List<TLV> list = new ArrayList<TLV>();
TLVInputStream stream = new TLVInputStream(new ByteArrayInputStream(pData));
try {
while (stream.available() > 0) {
TLV tlv = TlvUtil.getNextTLV(stream)... | Assertions.assertThat(TlvUtil.getlistTLV(DATA, EmvTags.APPLICATION_TEMPLATE, false).size()).isEqualTo(12);
Assertions.assertThat(TlvUtil.getlistTLV(DATA, EmvTags.RECORD_TEMPLATE, false).size()).isEqualTo(4);
Assertions.assertThat(TlvUtil.getlistTLV(DATA, EmvTags.TRANSACTION_CURRENCY_CODE, false).size()).isEqualTo... |
18467626_9 | class TlvUtil {
public static List<TagAndLength> parseTagAndLength(final byte[] data) {
List<TagAndLength> tagAndLengthList = new ArrayList<TagAndLength>();
if (data != null) {
TLVInputStream stream = new TLVInputStream(new ByteArrayInputStream(data));
try {
while (stream.available() > 0) {
if (st... | Assertions.assertThat(TlvUtil.parseTagAndLength(null)).isEqualTo(new ArrayList<TagAndLength>());
}
} |
20043683_0 | class SnomedDescriptionComparator implements Comparator<SnomedConcept> {
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
if (o1 == o2) return 0;
if (o1 != null) {
if (o2 == null) return 1;
else return o1.candidatePreferred.compareTo(o2.candidatePreferred... | // sort just the descriptions to get the comparative order
final Collection<String> sortedDescriptionsColl = new TreeSet<>();
for (final SnomedConcept concept : TEST_DATA) {
sortedDescriptionsColl.add(concept.candidatePreferred);
}
final List<String> sortedDescription... |
20043683_1 | class SnomedCodeComparator implements Comparator<SnomedConcept> {
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
if (o1 == o2) return 0;
if (o1 != null) {
if (o2 == null) return 1;
// need to use BigInteger to compare SNOMED codes since some are fan... | final List<SnomedConcept> sorted = new ArrayList<>(TestData.TEST_DATA);
Collections.sort(sorted, new SnomedCodeComparator());
for (int i = 0; i < sorted.size(); i++) {
assertEquals(sorted.get(i).candidateScore, i);
}
}
} |
20043683_2 | class MappingGroupComparator implements Comparator<SnomedConcept> {
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
if (o1 == o2) return 0;
if (o1 != null) {
if (o2 == null) return 1;
// sort shorter mapping groups first
else if (o1.mappi... | final List<SnomedConcept> sorted = new ArrayList<>(TestData.TEST_DATA);
Collections.sort(sorted, new MappingGroupComparator());
for (int i = 0; i < sorted.size(); i++) {
assertEquals(sorted.get(i).candidateScore, i);
}
}
} |
20043683_3 | class SnomedRequestCallback implements RequestCallback {
static String nextMappingGroup(final String mappingGroup) {
if (mappingGroup == null || "".equals(mappingGroup)) return "A";
final char[] cs = mappingGroup.toCharArray();
boolean incrementFurther = true;
// step through the ... | assertEquals(SnomedRequestCallback.nextMappingGroup(null), "A");
assertEquals(SnomedRequestCallback.nextMappingGroup(""), "A");
assertEquals(SnomedRequestCallback.nextMappingGroup("A"), "B");
assertEquals(SnomedRequestCallback.nextMappingGroup("B"), "C");
assertEquals(SnomedRequ... |
20043683_5 | class MetaMapOptions {
@SuppressWarnings("ReturnOfNull")
public static Option strToOpt(final String optStr) {
final String[] parts = SPACE.split(optStr, 2);
final String name = parts[0];
final String param = 1 < parts.length ? parts[1] : null;
final Option opt = OPTS.get(name);... | final Option o1 = MetaMapOptions.strToOpt("foobar");
assertNull(o1);
final Option o2 = MetaMapOptions.strToOpt("word_sense_disambiguation");
assertNotNull(o2);
assertEquals(o2.getClass(), WordSenseDisambiguation.class);
assertEquals(o2.name(), "word_sense_disambiguation"... |
20043683_6 | class SemanticTypes {
public static Collection<String> sanitiseSemanticTypes(final Collection<String> semanticTypes) {
if (semanticTypes == null) return ImmutableList.of();
// check that each of the given types are in the map we have, otherwise throw it away
final Set<String> s = new Linke... | assertEquals(sanitiseSemanticTypes(null), of());
assertEquals(sanitiseSemanticTypes(ImmutableList.<String>of()), of());
assertEquals(sanitiseSemanticTypes(of("foobar")), of());
assertEquals(sanitiseSemanticTypes(of("dsyn")), of("dsyn"));
assertEquals(sanitiseSemanticTypes(of("ds... |
20043683_7 | class JaxbLoader {
public static MMOs loadXml(final File xmlFile)
throws JAXBException, SAXException, ParserConfigurationException, FileNotFoundException {
final JAXBContext jaxbContext = JAXBContext.newInstance(MMOs.class);
final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmars... | final MMOs root = JaxbLoader.loadXml(TEST_XML);
assertNotNull(root);
final MMO mmo = root.getMMO().get(0);
assertNotNull(mmo);
final Utterance utterance = mmo.getUtterances().getUtterance().get(0);
assertNotNull(utterance);
final Phrase phrase = utterance.getPh... |
20043683_8 | class JaxbLoader {
public static MMOs loadXml(final File xmlFile)
throws JAXBException, SAXException, ParserConfigurationException, FileNotFoundException {
final JAXBContext jaxbContext = JAXBContext.newInstance(MMOs.class);
final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmars... | //noinspection OverlyBroadCatchBlock
try {
JaxbLoader.loadXml(new File("noSuchFile"));
fail("We should have had an exception before now.");
}
catch (final FileNotFoundException ignored) {
// do nothing
}
catch (final Throwable t) {
... |
20186852_0 | class SelectUtils {
public static void addExpression(Select select, final Expression expr) {
select.getSelectBody().accept(new SelectVisitor() {
public void visit(PlainSelect plainSelect) {
plainSelect.getSelectItems().add(new SelectExpressionItem(expr));
}
public void visit(SetOperationList setOpL... | Select select = (Select) CCJSqlParserUtil.parse("select a from mytable");
SelectUtils.addExpression(select, new Column("b"));
assertEquals("SELECT a, b FROM mytable", select.toString());
Addition add = new Addition();
add.setLeftExpression(new LongValue(5));
add.setRightExpression(new LongValue(6));
Se... |
20186852_1 | class SelectUtils {
public static Join addJoin(Select select, final Table table, final Expression onExpression) {
if (select.getSelectBody() instanceof PlainSelect) {
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
List<Join> joins = plainSelect.getJoins();
if (joins == null) {
joins = ... | Select select = (Select)CCJSqlParserUtil.parse("select a from mytable");
final EqualsTo equalsTo = new EqualsTo();
equalsTo.setLeftExpression(new Column("a"));
equalsTo.setRightExpression(new Column("b"));
Join addJoin = SelectUtils.addJoin(select, new Table("mytable2"), equalsTo);
addJoin.setLeft(true);
... |
20186852_3 | class SelectUtils {
public static Select buildSelectFromTable(Table table) {
return buildSelectFromTableAndSelectItems(table, new AllColumns());
}
private SelectUtils();
public static Select buildSelectFromTableAndExpressions(Table table, Expression ... expr);
public static Select buildSelectFromTableAndExpr... | Select select = SelectUtils.buildSelectFromTable(new Table("mytable"));
assertEquals("SELECT * FROM mytable", select.toString());
}
} |
20186852_5 | class CCJSqlParserUtil {
public static Expression parseExpression(String expression) throws JSQLParserException {
CCJSqlParser parser = new CCJSqlParser(new StringReader(expression));
try {
return parser.SimpleExpression();
} catch (Exception ex) {
throw new JSQLParserException(ex);
}
}
private CCJ... | Expression result = CCJSqlParserUtil.parseExpression("a+b");
assertEquals("a + b", result.toString());
assertTrue(result instanceof Addition);
Addition add = (Addition)result;
assertTrue(add.getLeftExpression() instanceof Column);
assertTrue(add.getRightExpression() instanceof Column);
}
} |
20186852_6 | class CCJSqlParserUtil {
public static Expression parseExpression(String expression) throws JSQLParserException {
CCJSqlParser parser = new CCJSqlParser(new StringReader(expression));
try {
return parser.SimpleExpression();
} catch (Exception ex) {
throw new JSQLParserException(ex);
}
}
private CCJ... | Expression result = CCJSqlParserUtil.parseExpression("2*(a+6.0)");
assertEquals("2 * (a + 6.0)", result.toString());
assertTrue(result instanceof Multiplication);
Multiplication mult = (Multiplication)result;
assertTrue(mult.getLeftExpression() instanceof LongValue);
assertTrue(mult.getRightExpression() ins... |
20186852_7 | class CCJSqlParserUtil {
public static Expression parseCondExpression(String condExpr) throws JSQLParserException {
CCJSqlParser parser = new CCJSqlParser(new StringReader(condExpr));
try {
return parser.Expression();
} catch (Exception ex) {
throw new JSQLParserException(ex);
}
}
private CCJSqlPar... | Expression result = CCJSqlParserUtil.parseCondExpression("a+b>5 and c<3");
assertEquals("a + b > 5 AND c < 3", result.toString());
}
} |
20186852_8 | class SignedExpression implements Expression {
public char getSign() {
return sign;
}
public SignedExpression(char sign, Expression expression);
public final void setSign(char sign);
public Expression getExpression();
public final void setExpression(Expression expression);
public void accept(ExpressionVisi... | new SignedExpression('*', CCJSqlParserUtil.parseExpression("a"));
fail("must not work");
}
} |
21267129_0 | class AbstractClient implements Closeable {
public static String getUrlEncodedValue(String value) {
try {
return StringUtils.replace(
new URLCodec().encode(StringUtils.trimToNull(value), getEncoding()),
"+", "%20");
} catch (UnsupportedEncodingExc... | Assert.assertEquals(
"1%2B2%3D3%20%C3%A4%C3%B6%C3%BC%C3%9F%20%2F%20%E2%82%AC%20%26",
AbstractClient.getUrlEncodedValue("1+2=3 äöüß / € &"));
}
} |
21267129_1 | class RandomStringUtils {
public static String random(int length) {
return new RandomStringGenerator.Builder()
.filteredBy(NUMBERS, LETTERS)
.build().generate(length);
}
private RandomStringUtils();
public static String randomLetters(int length);
public st... | for (int length = 1; length < 10; length++) {
String value = RandomStringUtils.random(length);
//LOGGER.debug( "random alphanumeric string: " + value );
Assert.assertEquals(
"random string has a length of " + length,
length, value.leng... |
21267129_2 | class RandomStringUtils {
public static String randomLetters(int length) {
return new RandomStringGenerator.Builder()
.filteredBy(LETTERS)
.build().generate(length);
}
private RandomStringUtils();
public static String random(int length);
public static Stri... | for (int length = 1; length < 10; length++) {
String value = RandomStringUtils.randomLetters(length);
//LOGGER.debug( "random alpha string: " + value );
Assert.assertEquals(
"random string has a length of " + length,
length, value.leng... |
21267129_3 | class RandomStringUtils {
public static String randomNumeric(int length) {
return new RandomStringGenerator.Builder()
.filteredBy(NUMBERS)
.build().generate(length);
}
private RandomStringUtils();
public static String random(int length);
public static Stri... | for (int length = 1; length < 10; length++) {
String value = RandomStringUtils.randomNumeric(length);
//LOGGER.debug( "random numeric string: " + value );
Assert.assertEquals(
"random string has a length of " + length,
length, value.le... |
22169673_0 | class ProxyHelper {
static boolean isHostMatchesNonProxyHostsPattern( String host, String nonProxyHostsPattern )
{
boolean matches = true;
if ( StringUtils.isNotBlank( nonProxyHostsPattern ) )
{
try
{
matches = host.matches( nonProxyHostsPattern );
... | String javaPattern = ProxyHelper.convertToJavaPattern( PATTERN );
boolean matches = ProxyHelper.isHostMatchesNonProxyHostsPattern( HOST, javaPattern );
String message = String.format( "host '%s' must match pattern '%s'", HOST, PATTERN );
assertTrue( message, matches );
}
} |
22169673_1 | class ProxyHelper {
static String convertToJavaPattern( String pattern )
{
String javaPattern = pattern;
if ( StringUtils.isNotBlank( pattern ) )
{
javaPattern = javaPattern.replaceAll( "\\.", "\\\\." );
javaPattern = javaPattern.replaceAll( "\\*", ".*" );
}
... | String javaPattern = ProxyHelper.convertToJavaPattern( PATTERN );
String expected = "localhost|.*\\.my\\.company|192\\.168\\..*|127\\.0\\.0\\.1";
assertEquals( "javaPattern", expected, javaPattern );
}
} |
22169673_2 | class ProxyHelper {
static boolean isUseProxyByPattern( String host, String nonProxyHostsPattern )
{
String nonProxyHostsPatternJava = convertToJavaPattern( nonProxyHostsPattern );
boolean useProxy = !isHostMatchesNonProxyHostsPattern( host, nonProxyHostsPatternJava );
log.info( "isUseProxyB... | boolean useProxyByPattern = ProxyHelper.isUseProxyByPattern( HOST, PATTERN );
assertFalse( "useProxyByPattern", useProxyByPattern );
}
} |
22169673_3 | class ProxyHelper {
static String getProtocol( String url )
{
log.debug( "getProtocol( url = '{}' )", url );
String protocol = DEFAULT_PROTOCOL;
try
{
URL u = new URL( url );
protocol = u.getProtocol( );
}
catch ( MalformedURLException e )
... | String protocol = ProxyHelper.getProtocol( SOURCE_URL );
assertEquals( "protocol", "https", protocol );
}
} |
22169673_4 | class ProxyHelper {
static String getHost( String url )
{
log.debug( "getHost( url = '{}' )", url );
String host = "";
try
{
URL u = new URL( url );
host = u.getHost( );
}
catch ( MalformedURLException e )
{
String message = Strin... | String host = ProxyHelper.getHost( SOURCE_URL );
assertEquals( "host", HOST, host );
}
} |
22430702_0 | class FormattedGraphParser {
public FormattedGraph parseFormattedGraph() throws InvalidConfigurationException {
if (formattedGraph != null) {
return formattedGraph;
}
parseBasicGraphConfiguration();
parseVertexPropertiesConfiguration();
parseEdgePropertiesConfiguration();
formattedGraph = new Formatt... | final String ROOT_DIR = "graph-root-dir";
final Fixture FIXTURE = constructBasicGraph(ROOT_DIR);
FormattedGraphParser parser = new FormattedGraphParser(FIXTURE.getConfiguration(),
FIXTURE.getGraphName(), ROOT_DIR);
assertGraphEqual(FIXTURE.getExpectedGraph(), parser.parseFormattedGraph());
}
} |
22430702_1 | class FormattedGraphParser {
public FormattedGraph parseFormattedGraph() throws InvalidConfigurationException {
if (formattedGraph != null) {
return formattedGraph;
}
parseBasicGraphConfiguration();
parseVertexPropertiesConfiguration();
parseEdgePropertiesConfiguration();
formattedGraph = new Formatt... | final String ROOT_DIR = "graph-root-dir";
final Fixture FIXTURE = constructVertexPropertyGraph(ROOT_DIR);
FormattedGraphParser parser = new FormattedGraphParser(FIXTURE.getConfiguration(),
FIXTURE.getGraphName(), ROOT_DIR);
assertGraphEqual(FIXTURE.getExpectedGraph(), parser.parseFormattedGraph());
}
} |
22430702_2 | class FormattedGraphParser {
public FormattedGraph parseFormattedGraph() throws InvalidConfigurationException {
if (formattedGraph != null) {
return formattedGraph;
}
parseBasicGraphConfiguration();
parseVertexPropertiesConfiguration();
parseEdgePropertiesConfiguration();
formattedGraph = new Formatt... | final String ROOT_DIR = "graph-root-dir";
final Fixture FIXTURE = constructEdgePropertyGraph(ROOT_DIR);
FormattedGraphParser parser = new FormattedGraphParser(FIXTURE.getConfiguration(),
FIXTURE.getGraphName(), ROOT_DIR);
assertGraphEqual(FIXTURE.getExpectedGraph(), parser.parseFormattedGraph());
}
} |
22430702_3 | class EdgeListStreamWriter implements AutoCloseable {
public void writeAll() throws IOException {
while (inputStream.hasNextEdge()) {
writeNextEdge();
}
outputWriter.flush();
}
public EdgeListStreamWriter(EdgeListStream inputStream, OutputStream outputStream);
private void writeNextEdge();
@Override p... | EdgeListStream edgeListStream = new MockEdgeListStream(edges);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (EdgeListStreamWriter writer = new EdgeListStreamWriter(edgeListStream, outputStream)) {
writer.writeAll();
assertEquals("Output of EdgeListStreamWriter is correct", expected... |
22430702_4 | class VertexListInputStreamReader implements VertexListStream {
@Override
public boolean hasNextVertex() throws IOException {
if (cacheValid) {
return true;
} else {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = line.trim();
if (line.isEmpty()) {
contin... | String input = "\n \n \n";
InputStream inputStream = new ByteArrayInputStream(input.getBytes());
try (VertexListInputStreamReader reader = new VertexListInputStreamReader(inputStream)) {
assertFalse(reader.hasNextVertex());
}
}
} |
22430702_5 | class EdgeListInputStreamReader implements EdgeListStream {
@Override
public boolean hasNextEdge() throws IOException {
if (cacheValid) {
return true;
} else {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = line.trim();
if (line.isEmpty()) {
continue;
... | String input = "\n \n \n";
InputStream inputStream = new ByteArrayInputStream(input.getBytes());
try (EdgeListInputStreamReader reader = new EdgeListInputStreamReader(inputStream)) {
assertFalse(reader.hasNextEdge());
}
}
} |
22430702_6 | class VertexListStreamWriter implements AutoCloseable {
public void writeAll() throws IOException {
while (inputStream.hasNextVertex()) {
writeNextVertex();
}
outputWriter.flush();
}
public VertexListStreamWriter(VertexListStream inputStream, OutputStream outputStream);
private void writeNextVertex();
... | VertexListStream vertexListStream = new MockVertexListStream(vertices);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (VertexListStreamWriter writer = new VertexListStreamWriter(vertexListStream, outputStream)) {
writer.writeAll();
assertEquals("Output of VertexListStreamWriter is c... |
22460817_0 | class Str {
public static String trim(String s) {
if (s == null)
return null;
s = s.trim();
return s.length() > 0 ? s : null;
}
public static String group(String text, String regexp);
public static String group(String text, String regexp, int group);
public stat... | assertNull(Str.trim(null));
assertNull(Str.trim(""));
assertNull(Str.trim(" "));
assertNull(Str.trim(" \t\n "));
assertNotNull(Str.trim("."));
assertNotNull(Str.trim(" . "));
}
} |
22460817_1 | class Str {
public static String group(String text, String regexp) {
return group(text, regexp, 1);
}
public static String trim(String s);
public static String group(String text, String regexp, int group);
public static Pair<String, String> groups(String text, String regexp, int group1, in... | assertNull("asdf : a -> null", Str.group("asdf", "a"));
assertNull("asdf : q -> null", Str.group("asdf", "q"));
assertEquals("asdf : (s) -> s", Str.group("asdf", "(s)"), "s");
assertEquals("asdf : ^.(..) -> sd", Str.group("asdf", "^.(..)"), "sd");
assertNull("asdf : ^.{5}(.+) -> ... |
2280644_13 | class FileUtils {
public static void saveFile(Resource file, String text, boolean append) throws IOException {
if(file.isDirectory()) {
throw new IOException(file+": Is a directory");
}
try (OutputStream out = file.write(append);) {
out.write(text.getBytes());
... | File file = File.createTempFile("tmp", ".tmp");
file.delete();
file.mkdir();
file.deleteOnExit();
File child = new File(file, "child.txt");
child.createNewFile();
child.deleteOnExit();
aeshContext.setCurrentWorkingDirectory(new FileResource(file));
... |
2280644_14 | class FileCompleterGenerator {
String generateCompleterFile(CommandLineParser<CommandInvocation> command) {
StringBuilder out = new StringBuilder();
out.append(generateHeader(command.getProcessedCommand().name()));
if(command.isGroupCommand())
out.append(generateArrContains()... |
CommandLineParser<CommandInvocation> parser = getParser(TestCommand1.class);
FileCompleterGenerator completerGenerator = new FileCompleterGenerator();
String out = completerGenerator.generateCompleterFile(parser);
assertTrue(out.contains("_complete_test1"));
assertTrue(out.co... |
2280644_15 | class FileCompleterGenerator {
String generateCompleterFile(CommandLineParser<CommandInvocation> command) {
StringBuilder out = new StringBuilder();
out.append(generateHeader(command.getProcessedCommand().name()));
if(command.isGroupCommand())
out.append(generateArrContains()... | CommandLineParser<CommandInvocation> parser = getParser(GutCommand1.class);
FileCompleterGenerator completerGenerator = new FileCompleterGenerator();
String out = completerGenerator.generateCompleterFile(parser);
assertTrue(out.contains("_complete_gut"));
assertTrue(out.contai... |
2280644_16 | class PathResolver {
@SuppressWarnings("IndexOfReplaceableByContains")
public static List<File> resolvePath(File incPath, File cwd) {
if(cwd == null)
cwd = new File(Config.getHomeDir());
//if incPath start with eg: ./, remove it
if(incPath.toString().startsWith(CURRENT_WITH... | File tmp = tempDir.toFile();
File child1 = new File(tmp + Config.getPathSeparator()+"child1");
File child2 = new File(tmp + Config.getPathSeparator()+"child2");
File child11 = new File(child1 + Config.getPathSeparator()+"child11");
File child12 = new File(child1 + Config.getPathS... |
2280644_17 | class PathResolver {
@SuppressWarnings("IndexOfReplaceableByContains")
public static List<File> resolvePath(File incPath, File cwd) {
if(cwd == null)
cwd = new File(Config.getHomeDir());
//if incPath start with eg: ./, remove it
if(incPath.toString().startsWith(CURRENT_WITH... | File tmp = tempDir.toFile();
File child1 = new File(tempDir + Config.getPathSeparator()+"child1");
File child2 = new File(tempDir + Config.getPathSeparator()+"child2");
File child3 = new File(tempDir + Config.getPathSeparator()+"child3");
if(Config.isOSPOSIXCompatible()) {
... |
2280644_18 | class PathResolver {
@SuppressWarnings("IndexOfReplaceableByContains")
public static List<File> resolvePath(File incPath, File cwd) {
if(cwd == null)
cwd = new File(Config.getHomeDir());
//if incPath start with eg: ./, remove it
if(incPath.toString().startsWith(CURRENT_WITH... | File child1 = new File(tempDir + Config.getPathSeparator()+"child1");
File child2 = new File(tempDir + Config.getPathSeparator()+"child2");
File child11 = new File(child1 + Config.getPathSeparator()+"child11");
File child111 = new File(child11 + Config.getPathSeparator()+"child111");
... |
2280644_19 | class NoDotNamesFilter implements ResourceFilter {
@Override
public boolean accept(Resource pathname) {
return !pathname.getName().startsWith(Character.toString(AeshConstants.DOT));
}
private Resource resource;
}
class NoDotNamesFilterTest {
private Resource resource;
@Test
pub... | NoDotNamesFilter noDotNamesFilter = new NoDotNamesFilter();
Assert.assertFalse(noDotNamesFilter.accept(resource));
}
} |
2280644_20 | class DirectoryResourceFilter implements ResourceFilter {
@Override
public boolean accept(Resource path) {
return path.isDirectory();
}
private Resource resource;
}
class DirectoryResourceFilterTest {
private Resource resource;
@Test
public void testDirectoryResourceFilter() {
| DirectoryResourceFilter directoryResourceFilter = new DirectoryResourceFilter();
Assert.assertTrue(directoryResourceFilter.accept(resource));
}
} |
2280644_21 | class LeafResourceFilter implements ResourceFilter {
@Override
public boolean accept(Resource path) {
return path.isLeaf();
}
private Resource resource;
}
class LeafResourceFilterTest {
private Resource resource;
@Test
public void testLeafResourceFilter() {
| LeafResourceFilter leafResourceFilter = new LeafResourceFilter();
Assert.assertFalse(leafResourceFilter.accept(resource));
}
} |
2280644_23 | class ExportManager {
public String addVariable(String line) {
Matcher variableMatcher = exportPattern.matcher(line);
if (variableMatcher.matches()) {
String name = variableMatcher.group(2);
String value = variableMatcher.group(3);
if (value.contains(String.value... |
ExportManager exportManager =
new ExportManager(new File(Config.getTmpDir()+Config.getPathSeparator()+"aesh_variable_test"));
exportManager.addVariable("export TEST=/foo/bar");
assertEquals("/foo/bar", exportManager.getValue("TEST"));
exportManager.addVariable("export F... |
2280644_24 | class ExportManager {
public String getValue(String key) {
if (key.indexOf(DOLLAR) == -1) {
String value = getVariable(key);
if (value == null)
return null;
if (value.indexOf(DOLLAR) == -1)
return value;
else
... | ExportManager exportManager =
new ExportManager(new File(Config.getTmpDir()+Config.getPathSeparator()+"aesh_variable_test"));
assertEquals("", exportManager.getValue("$FOO3"));
assertEquals(null, exportManager.getValue("FOO3"));
}
} |
2280644_25 | class ExportManager {
public String getValue(String key) {
if (key.indexOf(DOLLAR) == -1) {
String value = getVariable(key);
if (value == null)
return null;
if (value.indexOf(DOLLAR) == -1)
return value;
else
... |
ExportManager exportManager =
new ExportManager(new File(Config.getTmpDir()+Config.getPathSeparator()+"aesh_variable_test"), true);
String result = exportManager.getValue("PATH");
if (Config.isOSPOSIXCompatible()) {
assertTrue(result.contains("/usr"));
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.