Skip to content

Commit

Permalink
Issue #168: Adds prefab values for InetAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Apr 3, 2017
1 parent 624621a commit fab51a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 Jan Ouwens
* Copyright 2010-2017 Jan Ouwens
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,6 +138,12 @@ private void addClasses() {
addValues(TimeZone.class, TimeZone.getTimeZone("GMT+1"), TimeZone.getTimeZone("GMT+2"));
addValues(Throwable.class, new Throwable(), new Throwable());
addValues(UUID.class, new UUID(0, -1), new UUID(1, 0));

// Constructing InetAddress reflectively, because it might throw a awkward exception otherwise.
ConditionalInstantiator inetAddress = new ConditionalInstantiator("java.net.InetAddress");
addValues(inetAddress.resolve(),
inetAddress.callFactory("getByName", classes(String.class), objects("127.0.0.1")),
inetAddress.callFactory("getByName", classes(String.class), objects("127.0.0.42")));
}

@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2015 Jan Ouwens
* Copyright 2009-2015,2017 Jan Ouwens
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import org.junit.Test;

import java.io.File;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.BlockingDeque;
Expand Down Expand Up @@ -133,14 +134,15 @@ static final class CommonClassesContainer {
private final Pattern pattern;
private final SimpleDateFormat simpleDateFormat;
private final UUID uuid;
private final InetAddress inetAddress;

// CHECKSTYLE: ignore ParameterNumber for 1 line.
public CommonClassesContainer(String string, Integer integer, Class<?> type, ArrayList<String> arrayList, BitSet bitset,
Calendar calendar, Date date, File file, GregorianCalendar gregorianCalendar, Pattern pattern,
SimpleDateFormat simpleDateFormat, UUID uuid) {
SimpleDateFormat simpleDateFormat, UUID uuid, InetAddress inetAddress) {
this.string = string; this.integer = integer; this.type = type; this.arrayList = arrayList; this.bitset = bitset;
this.calendar = calendar; this.date = date; this.file = file; this.gregorianCalendar = gregorianCalendar; this.pattern = pattern;
this.simpleDateFormat = simpleDateFormat; this.uuid = uuid;
this.simpleDateFormat = simpleDateFormat; this.uuid = uuid; this.inetAddress = inetAddress;
}

@Override public boolean equals(Object obj) { return defaultEquals(this, obj); }
Expand Down

0 comments on commit fab51a1

Please sign in to comment.