use of cn.taketoday.origin.TextResourceOrigin.Location in project today-infrastructure by TAKETODAY.
the class TextResourceOriginTests method locationToStringReturnsNiceString.
@Test
void locationToStringReturnsNiceString() {
Location location = new Location(1, 2);
assertThat(location.toString()).isEqualTo("2:3");
}
use of cn.taketoday.origin.TextResourceOrigin.Location in project today-infrastructure by TAKETODAY.
the class TextResourceOriginTests method equalsAndHashCodeUsesResourceAndLocation.
@Test
void equalsAndHashCodeUsesResourceAndLocation() {
TextResourceOrigin origin1 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(1, 2));
TextResourceOrigin origin2 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(1, 2));
TextResourceOrigin origin3 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(2, 2));
TextResourceOrigin origin4 = new TextResourceOrigin(new ClassPathResource("foo2.txt"), new Location(1, 2));
assertThat(origin1.hashCode()).isEqualTo(origin1.hashCode());
assertThat(origin1.hashCode()).isEqualTo(origin2.hashCode());
assertThat(origin1.hashCode()).isNotEqualTo(origin3.hashCode());
assertThat(origin1.hashCode()).isNotEqualTo(origin4.hashCode());
assertThat(origin1).isEqualTo(origin1);
assertThat(origin1).isEqualTo(origin2);
assertThat(origin1).isNotEqualTo(origin3);
assertThat(origin1).isNotEqualTo(origin4);
}
use of cn.taketoday.origin.TextResourceOrigin.Location in project today-infrastructure by TAKETODAY.
the class TextResourceOriginTests method toStringWhenResourceIsClasspathResourceReturnsToStringWithJar.
@Test
void toStringWhenResourceIsClasspathResourceReturnsToStringWithJar() {
ClassPathResource resource = new ClassPathResource("foo.txt") {
@Override
public URI getURI() throws IOException {
try {
return new URI("jar:file:/home/user/project/target/project-0.0.1-SNAPSHOT.jar" + "!/BOOT-INF/classes!/foo.txt");
} catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
}
}
};
Location location = new Location(1, 2);
TextResourceOrigin origin = new TextResourceOrigin(resource, location);
assertThat(origin.toString()).isEqualTo("class path resource [foo.txt] from project-0.0.1-SNAPSHOT.jar - 2:3");
}
use of cn.taketoday.origin.TextResourceOrigin.Location in project today-infrastructure by TAKETODAY.
the class OriginTrackedPropertiesLoader method loadValue.
private OriginTrackedValue loadValue(StringBuilder buffer, CharacterReader reader, boolean splitLists) throws IOException {
buffer.setLength(0);
while (reader.isWhiteSpace() && !reader.isEndOfLine()) {
reader.read();
}
Location location = reader.getLocation();
while (!reader.isEndOfLine() && !(splitLists && reader.isListDelimiter())) {
buffer.append(reader.getCharacter());
reader.read();
}
Origin origin = new TextResourceOrigin(this.resource, location);
return OriginTrackedValue.of(buffer.toString(), origin);
}
use of cn.taketoday.origin.TextResourceOrigin.Location in project today-framework by TAKETODAY.
the class TextResourceOriginTests method toStringReturnsNiceString.
@Test
void toStringReturnsNiceString() {
ClassPathResource resource = new ClassPathResource("foo.txt");
Location location = new Location(1, 2);
TextResourceOrigin origin = new TextResourceOrigin(resource, location);
assertThat(origin.toString()).isEqualTo("class path resource [foo.txt] - 2:3");
}
Aggregations